summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlin Balutoiu <abalutoiu@cloudbasesolutions.com>2017-08-25 15:02:57 +0000
committerAlin Gabriel Serdean <aserdean@ovn.org>2017-09-13 00:54:45 +0300
commit7645006d478409049b1e3a16b003b7920325539b (patch)
tree73a64734ca2c02bed4e693ec751c7fc07eb4f8cd
parent2a62d1e7abb8f61f8354017ae17787389764afb8 (diff)
downloadopenvswitch-7645006d478409049b1e3a16b003b7920325539b.tar.gz
windows,python: remove unnecessary code
At the moment we have WSAEventSelect in each if branch. Since the call to the function is similar, we can move it outside the if branch and create some local variables which will be passed to WSAEventSelect. This patch also remove the keyword argument passed when the event for the connection overlapped structure is created. The argument is not needed since it does not change the value from the default one. Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org> Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
-rw-r--r--python/ovs/stream.py41
1 files changed, 18 insertions, 23 deletions
diff --git a/python/ovs/stream.py b/python/ovs/stream.py
index 9d0536d12..cb1cdbe8d 100644
--- a/python/ovs/stream.py
+++ b/python/ovs/stream.py
@@ -457,29 +457,24 @@ class Stream(object):
def __wait_windows(self, poller, wait):
if self.socket is not None:
if wait == Stream.W_RECV:
- read_flags = (win32file.FD_READ |
- win32file.FD_ACCEPT |
- win32file.FD_CLOSE)
- try:
- win32file.WSAEventSelect(self.socket,
- self._wevent,
- read_flags)
- except pywintypes.error as e:
- vlog.err("failed to associate events with socket: %s"
- % e.strerror)
- poller.fd_wait(self._wevent, ovs.poller.POLLIN)
+ mask = (win32file.FD_READ |
+ win32file.FD_ACCEPT |
+ win32file.FD_CLOSE)
+ event = ovs.poller.POLLIN
else:
- write_flags = (win32file.FD_WRITE |
- win32file.FD_CONNECT |
- win32file.FD_CLOSE)
- try:
- win32file.WSAEventSelect(self.socket,
- self._wevent,
- write_flags)
- except pywintypes.error as e:
- vlog.err("failed to associate events with socket: %s"
- % e.strerror)
- poller.fd_wait(self._wevent, ovs.poller.POLLOUT)
+ mask = (win32file.FD_WRITE |
+ win32file.FD_CONNECT |
+ win32file.FD_CLOSE)
+ event = ovs.poller.POLLOUT
+
+ try:
+ win32file.WSAEventSelect(self.socket,
+ self._wevent,
+ mask)
+ except pywintypes.error as e:
+ vlog.err("failed to associate events with socket: %s"
+ % e.strerror)
+ poller.fd_wait(self._wevent, event)
else:
if wait == Stream.W_RECV:
if self._read:
@@ -549,7 +544,7 @@ class PassiveStream(object):
self.socket = sock
if pipe is not None:
self.connect = pywintypes.OVERLAPPED()
- self.connect.hEvent = winutils.get_new_event(bManualReset=True)
+ self.connect.hEvent = winutils.get_new_event()
self.connect_pending = False
suffix = name.split(":", 1)[1]
suffix = ovs.util.abs_file_name(ovs.dirs.RUNDIR, suffix)