Skip to content

Commit

Permalink
verification of pending data after run starter
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Sep 3, 2018
1 parent 8cf256f commit cbeab1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/netius/base/conn.py
Expand Up @@ -693,6 +693,9 @@ def is_exhausted(self):
def is_restored(self):
return self.pending_s <= self.min_pending

def is_pending_data(self):
return self.restored_s > 0

def _send(self):
# sets the write ready flag so that any further request to
# write operation will be immediately performed
Expand Down
5 changes: 5 additions & 0 deletions src/netius/base/server.py
Expand Up @@ -920,6 +920,11 @@ def on_socket_c(self, socket_c, address):
try: connection.run_starter()
except: connection.close(); raise

# in case there's extraneous data pending to be read from the
# current connection's internal receive buffer it must be properly
# handled on the risk of blocking the newly created connection
if connection.is_pending_data(): self.on_read(connection.socket)

def on_socket_d(self, socket_c):
connection = self.connections_m.get(socket_c, None)
if not connection: return
Expand Down

0 comments on commit cbeab1e

Please sign in to comment.