Skip to content

Commit

Permalink
Rev3327, Add compatbility with new msgpack version
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Feb 13, 2018
1 parent 194d57c commit e85c5e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Config(object):

def __init__(self, argv):
self.version = "0.6.2"
self.rev = 3326
self.rev = 3327
self.argv = argv
self.action = None
self.config_file = "zeronet.conf"
Expand Down
14 changes: 11 additions & 3 deletions src/Connection/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,19 @@ def handleStream(self, message):

read_bytes = message["stream_bytes"] # Bytes left we have to read from socket
# Check if the unpacker has something left in buffer
extradata_len = min(self.unpacker._fb_buf_n - self.unpacker._fb_buf_o, read_bytes)
if hasattr(self.unpacker, "_buffer"): # New version of msgpack
bytes_buffer_left = len(self.unpacker._buffer) - self.unpacker.tell()
else:
bytes_buffer_left = self.unpacker._fb_buf_n - self.unpacker._fb_buf_o

extradata_len = min(bytes_buffer_left, read_bytes)
if extradata_len:
buff = self.unpacker.read_bytes(extradata_len)
self.unpacker._fb_consume()
self.log("Recovered: %r" % buff)
# Get rid of extra data from buffer
if hasattr(self.unpacker, "_consume"):
self.unpacker._consume()
else:
self.unpacker._fb_consume()
else:
buff = ""

Expand Down

0 comments on commit e85c5e3

Please sign in to comment.