summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-09-15 12:19:38 +0200
committerAleš Smodiš <aless@guru.si>2015-09-15 12:19:38 +0200
commitfc26c19e57faa7b22e76954e1d5243c82374125e (patch)
treeb499b3ae61997edcc8029aff86af4ee9103c5d24
parentcc3a807157d6d2d2c4830afcec90d6614e486b70 (diff)
Bugfix: invert the packet length comparison in the TCP packet decode loop.
-rw-r--r--server/socket.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/server/socket.py b/server/socket.py
index b184d4b..ce505e3 100644
--- a/server/socket.py
+++ b/server/socket.py
@@ -109,10 +109,10 @@ class JsonClientSocket(SocketHandler):
self.address = address
socket.setblocking(False)
self.status = 0 # registering
- self.receiving_header = True
- self.buffer = []
+ self.receiving_header = True # whether we're receiving the length of the next packet, or the packet itself
+ self.buffer = [] # chunks of the next packet (header or body)
self.received_length = 0 # the cumulative length of strings in buffer
- self.body_length = 0 # the length of the next packet, given in the header
+ self.body_length = 0 # the length of the next packet, which was given in the header
self._read_lock = threading.Lock()
self._write_lock = threading.Lock()
@@ -144,7 +144,7 @@ class JsonClientSocket(SocketHandler):
offset = i + 1
self.receiving_header = False
continue
- elif (self.received_length + N - offset) <= self.body_length:
+ elif (self.received_length + N - offset) >= self.body_length:
if self.received_length == 0:
# an optimized case
s = data[offset:offset+self.body_length]