You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we enable compression (eg: GZIPCompressor) and send multiple messages (from server or client), the buffers seem to not be cleaned up properly causing inconsistent behavior.
stream.go
Checkout the serverStream.SendMsg and clientStream.SendMsg, both of these call encode() function with a buffer (cbuf) parameter.
Inside encode function, cbuf is only used as a transient variable to hold the compressed bytes. Eventually it still goes ahead and makes a new buffer to add the headers before the data.
The problem is, when the subsequent sendMsg gets called, the cbuf sometimes may or may not be empty, causing the issue. Completely removing the cbuf and replacing it with a sync.pool makes it work.. I wanted to check here for any suggestions. Thanks for your help!
The text was updated successfully, but these errors were encountered:
VenkateshSub
changed the title
Adding compressor (GZIPCompressor) cause inconsistent behavior
Adding compressor (GZIPCompressor) cause inconsistent behavior when sending message
Jun 24, 2016
This is a bit difficult to document, because the user typically works with the generated code that wraps this, and doesn't produce godocs. I hope to add some basic documentation in the next 2-3 months to cover this and other FAQs.
Hi,
When we enable compression (eg: GZIPCompressor) and send multiple messages (from server or client), the buffers seem to not be cleaned up properly causing inconsistent behavior.
stream.go
Checkout the
serverStream.SendMsg
andclientStream.SendMsg
, both of these call encode() function with a buffer (cbuf) parameter.rpc_util.go:
encode(c Codec, msg interface{}, cp Compressor, cbuf *bytes.Buffer) ([]byte, error) {
Inside encode function, cbuf is only used as a transient variable to hold the compressed bytes. Eventually it still goes ahead and makes a new buffer to add the headers before the data.
The problem is, when the subsequent sendMsg gets called, the cbuf sometimes may or may not be empty, causing the issue. Completely removing the cbuf and replacing it with a sync.pool makes it work.. I wanted to check here for any suggestions. Thanks for your help!
The text was updated successfully, but these errors were encountered: