Skip to content

Commit b17251c

Browse files
committed
Correct EOF handling of tnetraw; Version 4.2.4
1 parent a5f3e47 commit b17251c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

server/tnetraw.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ def recv( maxlen ):
6565
remains = latency if timeout is None else min( # If no timeout, wait for latency (or forever, if None)
6666
timeout if latency is None else latency, # Or, we know timeout is numeric; get min of any latency
6767
max( timeout - duration, 0 )) # ... and remaining unused timeout
68-
return network.recv( conn, maxlen=maxlen, timeout=remains )
68+
data = network.recv( conn, maxlen=maxlen, timeout=remains ) # None (timeout) / b'' (EOF) / b'...'
69+
#log.warning( "recv: {data!r}".format( data=data ))
70+
return data
6971

70-
length,c = b'',b'0'
71-
while not server.done and c in b'01234567889' or ( ignore and c in ignore ):
72+
length,c = b'',b'0' # remember: b'' is trivially considered as "in" b'...'
73+
while not server.done and c and c in b'01234567889' or ( ignore and c in ignore ):
7274
if not ignore or c not in ignore:
7375
assert c in b'0123456789', "Expected TNET size symbol, not {c!r}".format( c=c ) # EOF/timeout
7476
length += c
@@ -79,7 +81,7 @@ def recv( maxlen ):
7981
# No data w/in given timeout expiry! Inform the consumer, and then try again w/ fresh timeout.
8082
yield None
8183
started = cpppo.timer()
82-
if server.done or c == b'': return # done/EOF
84+
if server.done or not c: return # None/b'' ==> done/EOF
8385
assert c == b':', "Expected TNET <size> separator ':', not {c!r}".format( c=c )
8486
length = int( length )
8587

version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version_info__ = ( 4, 2, 3 )
1+
__version_info__ = ( 4, 2, 4 )
22
__version__ = '.'.join( map( str, __version_info__ ))

0 commit comments

Comments
 (0)