-
Notifications
You must be signed in to change notification settings - Fork 105
Calls to Write() after calling Close() in sync mode reopen the connection #104
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
Comments
@fluent/team-golang Could someone check this idea? |
@tagomoris I'll take alook at this ticket this evening. |
@akerouanton So your suggestion is that an explicit call to In a design wise, I don't have any particular opposition to that proposal;
I'm thinking that probably the most streight forward way to implement We can set it to true in https://github.com/fluent/fluent-logger-golang/blob/master/fluent/fluent.go#L277 But do you have any suggestion on how it should be implemented? |
@fujimotos Yeah, that's it.
That's what I had in mind 🙂 I'd also rename |
Resolved by #105. |
Currently, in sync mode, the code reopens the connection when
Write()
is called afterClose()
. This could happen either because:In the first case, if
Write()
is serially called afterClose()
, it might seem legit to have to callClose()
once again but in the second case, it doesn't seem good to have to callClose()
multiple times to be really sure the connection is closed.This case doesn't happen in async mode because
f.Close()
takes care of settingf.chanClosed = true
andf.appendBuffer()
checks iff.chanClosed = true
and returns an error if that's the case.fluent-logger-golang/fluent/fluent.go
Lines 350 to 357 in c16ce5d
fluent-logger-golang/fluent/fluent.go
Lines 391 to 396 in c16ce5d
I suggest to change the code for sync mode to not accept any new messages when
f.Close()
has been called and document that change (as well as thread safety improvement done in #82).I've written the following test to confirm my findings (although I'm not sure how to test the inverse behavior). I ran it against the current master branch and on pre-#82 code to make sure this behavior wasn't introduced by that change. Both tests trigger the error.
The text was updated successfully, but these errors were encountered: