aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-11-21 22:09:55 -0800
committerBen Pfaff <blp@nicira.com>2012-11-21 22:12:36 -0800
commitaa8d2ee8ae0d47f1683cf51e83f104022102ed73 (patch)
treed8d2225463f06ee53b16ba154431790b14cfdb83
parent5d98c83b9dec5f86af52df52695c7f43d2a63602 (diff)
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>
-rw-r--r--python/ovs/stream.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/python/ovs/stream.py b/python/ovs/stream.py
index 5c065e43..66757661 100644
--- a/python/ovs/stream.py
+++ b/python/ovs/stream.py
@@ -135,15 +135,17 @@ class Stream(object):
is complete, returns 0 if the connection was successful or a positive
errno value if it failed. If the connection is still in progress,
returns errno.EAGAIN."""
- last_state = -1 # Always differs from initial self.state
- while self.state != last_state:
- last_state = self.state
- if self.state == Stream.__S_CONNECTING:
- self.__scs_connecting()
- elif self.state == Stream.__S_CONNECTED:
- return 0
- elif self.state == Stream.__S_DISCONNECTED:
- return self.error
+
+ if self.state == Stream.__S_CONNECTING:
+ self.__scs_connecting()
+
+ if self.state == Stream.__S_CONNECTING:
+ return errno.EAGAIN
+ elif self.state == Stream.__S_CONNECTED:
+ return 0
+ else:
+ assert self.state == Stream.__S_DISCONNECTED
+ return self.error
def recv(self, n):
"""Tries to receive up to 'n' bytes from this stream. Returns a