-
Notifications
You must be signed in to change notification settings - Fork 0
Fixed goroutine leak, made tests deterministic #1
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
Conversation
|
|
||
| import ( | ||
| "os" | ||
| "sync" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the easiest way to test the linux version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a build tag for only running on linux (if necessary), then run on a linux machine (e.g. Jenkins)
|
|
||
| // we need to wait a little bit since the files get deleted on a different | ||
| // goroutine. | ||
| <-time.After(10 * time.Millisecond) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was waiting for something that shouldn't happen. Now we'll get a deadlock in the test is there's an extra remove because nobody reads the notifyRemove chan.
|
|
||
| // we need to wait a little bit since the files get deleted on a different | ||
| // goroutine. | ||
| <-time.After(10 * time.Millisecond) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| fileCount(dir, 2, t) | ||
| newFakeTime() | ||
|
|
||
| b2 := []byte("bar") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added data so we can see if the files are rotated correctly.
| defer l.mu.Unlock() | ||
|
|
||
| if l.millCh != nil { | ||
| close(l.millCh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the actual fix for the leak, right? (just making sure I grok it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
|
Is this based on natefinch#100 ? |
Yep. Added that to the description, but you were too fast for me. |
|
|
||
| import ( | ||
| "os" | ||
| "sync" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a build tag for only running on linux (if necessary), then run on a linux machine (e.g. Jenkins)
connyay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
|
@TimKingtonFC this good to land? |
|
Yes, but I haven't figured out how to run the linux tests. |
This is based on howbazaar's changes with 4a6f656c's comments here: https://github.com/natefinch/lumberjack/pull/100/files
I changed a few things, too.