This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new 4ad9cef Fixed reading from connection (#163)
4ad9cef is described below
commit 4ad9cef10d22a14e72b55dce64b971951f970a7f
Author: Matteo Merli <[email protected]>
AuthorDate: Sun Jan 5 07:23:48 2020 -0800
Fixed reading from connection (#163)
---
pulsar/internal/connection_reader.go | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/pulsar/internal/connection_reader.go
b/pulsar/internal/connection_reader.go
index d6e19c1..6cbf650 100644
--- a/pulsar/internal/connection_reader.go
+++ b/pulsar/internal/connection_reader.go
@@ -50,7 +50,11 @@ func (r *connectionReader) readFromConnection() {
}
// Process
- r.cnx.log.Debug("Got command! ", cmd, " with payload ",
headersAndPayload)
+ var payloadLen uint32 = 0
+ if headersAndPayload != nil {
+ payloadLen = headersAndPayload.ReadableBytes()
+ }
+ r.cnx.log.Debug("Got command! ", cmd, " with payload size: ",
payloadLen)
r.cnx.receivedCommand(cmd, headersAndPayload)
}
}
@@ -77,7 +81,8 @@ func (r *connectionReader) readSingleCommand() (cmd
*pb.BaseCommand, headersAndP
// Next, we read the rest of the frame
if r.buffer.ReadableBytes() < frameSize {
- if !r.readAtLeast(frameSize) {
+ remainingBytes := frameSize - r.buffer.ReadableBytes()
+ if !r.readAtLeast(remainingBytes) {
return nil, nil, errors.New("Short read when reading
frame")
}
}