mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-18 16:06:30 +08:00
coredevice: Handle prematurely closed sockets in comm_kernel receive loop
recv() returns 0 instead of data if the socket has already been closed. This is translated into a zero-length list on the Python layer. Previously, the code would enter an infinite loop if the socket was closed while attempting to receive data.
This commit is contained in:
parent
f1fd42ea98
commit
f9872bb7b8
@ -223,7 +223,10 @@ class CommKernel:
|
||||
flag = 0
|
||||
if diff > 8192:
|
||||
flag |= socket.MSG_WAITALL
|
||||
self.read_buffer += self.socket.recv(8192, flag)
|
||||
new_buffer = self.socket.recv(8192, flag)
|
||||
if not new_buffer:
|
||||
raise ConnectionResetError("Core device connection closed unexpectedly")
|
||||
self.read_buffer += new_buffer
|
||||
result = self.read_buffer[:length]
|
||||
self.read_buffer = self.read_buffer[length:]
|
||||
return result
|
||||
|
Loading…
Reference in New Issue
Block a user