Skip to content

Commit 7328fe8

Browse files
committed
fixed maxblobs bug in dshell.py
1 parent d144f8e commit 7328fe8

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

lib/dshell.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -386,21 +386,24 @@ def track(self, addr, data=None, ts=None, offset=None, **kwargs):
386386
else:
387387
direction = 'sc'
388388

389-
# check direction and blob count.
390-
# If we have switched direction but already have max blobs
391-
# close connection and replace it with a new one
392-
if self.maxblobs and (direction != conn.direction) and (len(conn.blobs) == self.maxblobs):
393-
self.close(conn) # close and call handlers
394-
# recurse to create a new connection for the next
395-
# request/response
396-
return self.track(addr, data, ts)
389+
original_direction = conn.direction
397390

398391
# update the connection to update current blob or start a new one
399392
# and return the last one
400393
# we will get a blob back if there is data to flush
401394
blob = conn.update(ts, direction, data, offset=offset)
402395
if blob and self.isBlobHandlerPresent:
403396
self.blobHandler(conn, blob)
397+
398+
# check direction and blob count.
399+
# If we have switched direction but already have max blobs
400+
# close connection and replace it with a new one
401+
if self.maxblobs and (direction != original_direction) and (len(conn.blobs) >= self.maxblobs):
402+
self.close(conn) # close and call handlers
403+
# recurse to create a new connection for the next
404+
# request/response
405+
return self.track(addr, ts=ts, **kwargs)
406+
404407
# we can discard all but the last blob
405408
if not self.isConnectionHandlerPresent:
406409
while len(conn.blobs) > 1:
@@ -637,9 +640,12 @@ def UDP(self, addr, data, pkt, ts=None, **kwargs):
637640
return self.packetHandler(udp=Packet(self, addr, pkt=pkt, ts=ts, **kwargs), data=data)
638641

639642
# if no PacketHandler, we need to track state
640-
if not self.find(addr):
643+
conn = self.find(addr)
644+
if not conn:
641645
conn = self.track(addr, ts=ts, state='init', **kwargs)
646+
if conn.nextoffset['cs'] is None:
642647
conn.nextoffset['cs'] = 0
648+
if conn.nextoffset['sc'] is None:
643649
conn.nextoffset['sc'] = 0
644650
self.track(addr, data, ts, **kwargs)
645651

0 commit comments

Comments
 (0)