From patchwork Fri Aug 25 15:02:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alin Balutoiu X-Patchwork-Id: 805945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xf4Fv155tz9sPs for ; Sat, 26 Aug 2017 01:04:51 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 77B3DB2A; Fri, 25 Aug 2017 15:03:37 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 735DCB08 for ; Fri, 25 Aug 2017 15:03:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.cloudbasesolutions.com (mail.cloudbasesolutions.com [91.232.152.5]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 9C1ED135 for ; Fri, 25 Aug 2017 15:02:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.cloudbasesolutions.com (Postfix) with ESMTP id D59B041C63 for ; Fri, 25 Aug 2017 18:02:58 +0300 (EEST) X-Virus-Scanned: amavisd-new at cloudbasesolutions.com Received: from mail.cloudbasesolutions.com ([127.0.0.1]) by localhost (mail.cloudbasesolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5RGaYtpZou_E for ; Fri, 25 Aug 2017 18:02:58 +0300 (EEST) Received: from mail.cloudbasesolutions.com (unknown [10.77.78.3]) by mail.cloudbasesolutions.com (Postfix) with ESMTP id 8F55D4164E for ; Fri, 25 Aug 2017 18:02:58 +0300 (EEST) Received: from CBSEX1.cloudbase.local ([10.77.78.3]) by CBSEX1.cloudbase.local ([10.77.78.3]) with mapi id 14.03.0361.001; Fri, 25 Aug 2017 17:02:58 +0200 From: Alin Balutoiu To: "dev@openvswitch.org" Thread-Topic: [PATCH 2/2] windows,python: remove unnecessary code Thread-Index: AQHTHbM87x7hz+L9Lky/Ye13nHt+cQ== Date: Fri, 25 Aug 2017 15:02:57 +0000 Message-ID: <1503673364-3166-3-git-send-email-abalutoiu@cloudbasesolutions.com> References: <1503673364-3166-1-git-send-email-abalutoiu@cloudbasesolutions.com> In-Reply-To: <1503673364-3166-1-git-send-email-abalutoiu@cloudbasesolutions.com> Accept-Language: en-US, it-IT Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.77.78.1] MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/2] windows,python: remove unnecessary code X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 Acked-by: Alin Gabriel Serdean --- python/ovs/stream.py | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/python/ovs/stream.py b/python/ovs/stream.py index 9d0536d..cb1cdbe 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)