Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure harvesterCounter 8-byte alignment (#3273) #3338

Merged
merged 2 commits into from
Jan 13, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion filebeat/prospector/prospector.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
)

type Prospector struct {
harvesterCounter uint64 // Must be 8-byte aligned. Ensured if first field in struct
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is quite likely that this is changed by accident in the future, I suggest to add a comment on top of the variable with the following content:

// harvesterCount MUST be first field in struct. See golang/go#599

Copy link
Contributor Author

@spacewrangler spacewrangler Jan 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @ruflin. Should I make the changelog entry under Added or Bugfixes? I know you wrote Added above but thought I'd double check since this is a bug fix.

Also, I agree this is brittle. I.e. someone could easily break this by changing the order of the fields. Should we add a test for this? I realize we may address the issue more generally per @urso's comment #3273 (comment) but not sure what the priority of that is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine putting it under Bugfixes.

Do you have some ideas on how to add a test? Would be great to have one.

cfg *common.Config // Raw config
config prospectorConfig
prospectorer Prospectorer
Expand All @@ -30,7 +31,6 @@ type Prospector struct {
states *file.States
wg sync.WaitGroup
channelWg sync.WaitGroup // Separate waitgroup for channels as not stopped on completion
harvesterCounter uint64
}

type Prospectorer interface {
Expand Down