summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAlin Balutoiu <abalutoiu@cloudbasesolutions.com>2017-08-25 15:02:48 +0000
committerAlin Gabriel Serdean <aserdean@ovn.org>2017-09-13 00:38:26 +0300
commitfef22d68717ba23705d70dd9fb7d691dfc31f617 (patch)
treea1f6f2286ce19f30c7143224d81e6b3bcb026c8b /python
parent29e34ce1c516e20f336faa7422c00b419e356679 (diff)
downloadopenvswitch-fef22d68717ba23705d70dd9fb7d691dfc31f617.tar.gz
windows, python: create a different event for sockets
At the moment the sockets on Windows use the same events that are being created for the pipes. This is not correct because they should be different events. This patch introduces a new event which should be used for sockets. The new event needs to be set on automatic reset with its initial state not signaled. Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com> Co-authored-by: Alin Gabriel Serdean <aserdean@ovn.org> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org> Tested-by: Alin Gabriel Serdean <aserdean@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
Diffstat (limited to 'python')
-rw-r--r--python/ovs/stream.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/python/ovs/stream.py b/python/ovs/stream.py
index 717ea18ae..9d0536d12 100644
--- a/python/ovs/stream.py
+++ b/python/ovs/stream.py
@@ -102,10 +102,6 @@ class Stream(object):
self.socket = socket
self.pipe = pipe
if sys.platform == 'win32':
- self._read = pywintypes.OVERLAPPED()
- self._read.hEvent = winutils.get_new_event()
- self._write = pywintypes.OVERLAPPED()
- self._write.hEvent = winutils.get_new_event()
if pipe is not None:
# Flag to check if fd is a server HANDLE. In the case of a
# server handle we have to issue a disconnect before closing
@@ -114,6 +110,13 @@ class Stream(object):
suffix = name.split(":", 1)[1]
suffix = ovs.util.abs_file_name(ovs.dirs.RUNDIR, suffix)
self._pipename = winutils.get_pipe_name(suffix)
+ self._read = pywintypes.OVERLAPPED()
+ self._read.hEvent = winutils.get_new_event()
+ self._write = pywintypes.OVERLAPPED()
+ self._write.hEvent = winutils.get_new_event()
+ else:
+ self._wevent = winutils.get_new_event(bManualReset=False,
+ bInitialState=False)
self.name = name
if status == errno.EAGAIN:
@@ -459,24 +462,24 @@ class Stream(object):
win32file.FD_CLOSE)
try:
win32file.WSAEventSelect(self.socket,
- self._read.hEvent,
+ self._wevent,
read_flags)
except pywintypes.error as e:
vlog.err("failed to associate events with socket: %s"
% e.strerror)
- poller.fd_wait(self._read.hEvent, ovs.poller.POLLIN)
+ poller.fd_wait(self._wevent, ovs.poller.POLLIN)
else:
write_flags = (win32file.FD_WRITE |
win32file.FD_CONNECT |
win32file.FD_CLOSE)
try:
win32file.WSAEventSelect(self.socket,
- self._write.hEvent,
+ self._wevent,
write_flags)
except pywintypes.error as e:
vlog.err("failed to associate events with socket: %s"
% e.strerror)
- poller.fd_wait(self._write.hEvent, ovs.poller.POLLOUT)
+ poller.fd_wait(self._wevent, ovs.poller.POLLOUT)
else:
if wait == Stream.W_RECV:
if self._read: