From e85c5e3b36f41fe28ba20637dc5a2b0b116b321d Mon Sep 17 00:00:00 2001 From: shortcutme Date: Tue, 13 Feb 2018 01:35:21 +0100 Subject: [PATCH] Rev3327, Add compatbility with new msgpack version --- src/Config.py | 2 +- src/Connection/Connection.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Config.py b/src/Config.py index 5bc8a2536..4c1dfad1d 100644 --- a/src/Config.py +++ b/src/Config.py @@ -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" diff --git a/src/Connection/Connection.py b/src/Connection/Connection.py index f0c825e6a..e7c43de35 100644 --- a/src/Connection/Connection.py +++ b/src/Connection/Connection.py @@ -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 = ""