2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-19 14:37:21 +00:00

python/ovs/stream: Fix Stream.connect() retval for incomplete connection.

If the loop condition in Stream.connect() was false, which is especially
likely for TCP connections, then Stream.connect() would return None,
which violates its documented behavior.  This commit fixes the problem.

Reported-by: Isaku Yamahata <yamahata@valinux.co.jp>
Tested-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Ben Pfaff
2012-11-21 22:09:55 -08:00
parent 4fe3445afb
commit dcb66daea4

View File

@@ -161,15 +161,17 @@ class Stream(object):
is complete, returns 0 if the connection was successful or a positive is complete, returns 0 if the connection was successful or a positive
errno value if it failed. If the connection is still in progress, errno value if it failed. If the connection is still in progress,
returns errno.EAGAIN.""" returns errno.EAGAIN."""
last_state = -1 # Always differs from initial self.state
while self.state != last_state: if self.state == Stream.__S_CONNECTING:
last_state = self.state self.__scs_connecting()
if self.state == Stream.__S_CONNECTING:
self.__scs_connecting() if self.state == Stream.__S_CONNECTING:
elif self.state == Stream.__S_CONNECTED: return errno.EAGAIN
return 0 elif self.state == Stream.__S_CONNECTED:
elif self.state == Stream.__S_DISCONNECTED: return 0
return self.error else:
assert self.state == Stream.__S_DISCONNECTED
return self.error
def recv(self, n): def recv(self, n):
"""Tries to receive up to 'n' bytes from this stream. Returns a """Tries to receive up to 'n' bytes from this stream. Returns a