@@ -364,19 +364,30 @@ def SpinOnce(self, timeout=0):
364
364
continue
365
365
366
366
serverClient , connection = socketConnections [rsocket ]
367
- try :
368
- received = rsocket .recv_into (connection .receiveBuffer .writeView )
369
- except Exception as e :
370
- connection .closeType = 'Immediate'
371
- log .exception ('error while trying to receive from connection %s: %s' , connection , e )
367
+ totalReceived = 0
368
+ while True :
369
+ try :
370
+ received = rsocket .recv_into (connection .receiveBuffer .writeView )
371
+ if received == 0 :
372
+ break
373
+ connection .receiveBuffer .size += received
374
+ totalReceived += received
375
+ if connection .receiveBuffer .capacity - connection .receiveBuffer .size < connection .receiveBuffer .capacity :
376
+ connection .receiveBuffer .capacity *= 2
377
+ except socket .error as e :
378
+ if e .errno not in (errno .EAGAIN , errno .EWOULDBLOCK ):
379
+ connection .closeType = 'Immediate'
380
+ log .exception ('error while trying to receive from connection %s: %s' , connection , e )
381
+ break
382
+
383
+ if connection .closeType == 'Immediate' :
372
384
continue
373
385
374
- if received == 0 :
386
+ if totalReceived == 0 :
375
387
connection .closeType = 'AfterSend'
376
388
log .debug ('received nothing from connection, maybe closed: %s' , connection )
377
389
continue
378
390
379
- connection .receiveBuffer .size += received
380
391
receivedConnections .append ((serverClient , connection ))
381
392
382
393
# handle sockets that can write
0 commit comments