vici: Check for closed connection in Python bindings
The Python VICI library does not check if the socket is closed. If the daemon closes the connection, _recvall() spins forever. Closes strongswan/strongswan#56.
This commit is contained in:
committed by
Tobias Brunner
parent
564a199674
commit
351179d4dc
@@ -33,7 +33,10 @@ class Transport(object):
|
|||||||
"""Ensure to read count bytes from the socket"""
|
"""Ensure to read count bytes from the socket"""
|
||||||
data = b""
|
data = b""
|
||||||
while len(data) < count:
|
while len(data) < count:
|
||||||
data += self.socket.recv(count - len(data))
|
buf = self.socket.recv(count - len(data))
|
||||||
|
if not buf:
|
||||||
|
raise socket.error('Connection closed')
|
||||||
|
data += buf
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user