Browse files

Fix tcp.Direction assertion failure

Remove useless asserts from packet-bridging-the-gap scenario. It
turns out to be possible for the second chunk to merge onto the
new one without adding any new data, if it's completely inside
the newly merged chunk in front of it. The other condition is
impossible because of the sorting invariant (I think).

Also, somewhere in the merging, clear_data didn't get the news
that self.chunks is a SortedCollection and you can't del[] it.
  • Loading branch information...
Andrew Fleenor
Andrew Fleenor committed Jul 12, 2012
1 parent 41b9912 commit 007254b093bdd8de2f75ed5432e1adc40fe64ce0
Showing with 3 additions and 2 deletions.
  1. +3 −2 tcp/
@@ -60,8 +60,9 @@ def add(self, pkt):
# check if this packet bridged the gap between two chunks
if back and i < (len(self.chunks)-1):
overlapped2, result2 = chunk.merge(self.chunks[i+1])
+ # if the gap was bridged, the later chunk is obsolete
+ # so get rid of it.
if overlapped2:
- assert( (not result2[0]) and (result2[1]))
# if this is the main data chunk, calc final arrival
if self.seq_start and chunk.seq_start == self.seq_start:
@@ -102,7 +103,7 @@ def clear_data(self):
log.warn('tried to clear data on an unfinished tcp.Direction')
# clear the list, to make sure all chunks are orphaned to make it
# easier for GC. hopefully.
- del self.chunks[:]
+ self.chunks.clear()
self.chunks = None
self.final_data_chunk = None

0 comments on commit 007254b

Please sign in to comment.