-
Notifications
You must be signed in to change notification settings - Fork 24
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
fix counting of incoming streams #89
Conversation
session.go
Outdated
@@ -850,6 +847,12 @@ func (s *Session) deleteStream(id uint32) { | |||
return | |||
} | |||
s.memoryManager.ReleaseMemory(str.memory) | |||
if s.client == (id%2 == 0) { | |||
if s.numIncomingStreams == 0 { | |||
panic("yamux BUG: numIncomingStream would be negative") |
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 panic is not caught by our panic handlers if it was caused by the application calling Close
or Reset
on the stream. Not really sure what the best thing to do here is. We want to surface this bug, but we can't use the normal logger for that. Every user of this library will have logging turned off, because the amount of things we log is just crazy.
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.
lets just ERROR log BUG very loudly, panic is innapropriate for our our applications.
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.
we should just change the logging to use go-log, it is very much forked already.
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.
Change to use the normal logger now, will change to go-log in a follow-up PR.
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.
uh oh, lets use go-log and ERROR log loudly.
Maybe we should also remove most of the logging we have here. I haven't encountered a single case where it was useful. |
1e8dd76
to
b8eae95
Compare
b8eae95
to
b1d5347
Compare
b1d5347
to
a51e116
Compare
session.go
Outdated
if s.numIncomingStreams == 0 { | ||
s.logger.Printf("[ERR] yamux: numIncomingStream underflow") | ||
} | ||
s.numIncomingStreams-- |
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.
else decrement, lets not make it negative.
Plus, we'll see all occurences.
The existing code had a uint32 underflow, because we were decrementing the
numIncomingStreams
even if the stream was already removed from the map.