2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

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>
This commit is contained in:
Alin Balutoiu
2017-08-25 15:02:57 +00:00
committed by Alin Gabriel Serdean
parent fef22d6871
commit 0024e9e96f

View File

@@ -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)