Skip to content

Commit

Permalink
Merge pull request #3 from mujin/zozo_FixLargeRequests
Browse files Browse the repository at this point in the history
Allow server to receive files more than initial receive buffer size
  • Loading branch information
ziyan authored Jun 18, 2024
2 parents f1fafb8 + d20405b commit e73979b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/mujinasync/asynctcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,9 @@ def SpinOnce(self, timeout=0):
socketConnections = {}
for serverClient in self._servers + self._clients:
for connection in serverClient._connections:
if connection.receiveBuffer.size < connection.receiveBuffer.capacity:
rsockets.append(connection.connectionSocket)
if connection.receiveBuffer.size >= connection.receiveBuffer.capacity:
connection.receiveBuffer.capacity *= 2
rsockets.append(connection.connectionSocket)
if connection.sendBuffer.size > 0:
wsockets.append(connection.connectionSocket)
xsockets.append(connection.connectionSocket)
Expand Down Expand Up @@ -366,6 +367,11 @@ def SpinOnce(self, timeout=0):
serverClient, connection = socketConnections[rsocket]
try:
received = rsocket.recv_into(connection.receiveBuffer.writeView)
except socket.error as e:
if e.errno not in (errno.EAGAIN, errno.EWOULDBLOCK):
connection.closeType = 'Immediate'
log.exception('error while trying to receive from connection %s: %s', connection, e)
continue
except Exception as e:
connection.closeType = 'Immediate'
log.exception('error while trying to receive from connection %s: %s', connection, e)
Expand Down

0 comments on commit e73979b

Please sign in to comment.