From patchwork Wed Sep 30 21:18:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurucharan Shetty X-Patchwork-Id: 524598 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id A32AC1402B6 for ; Thu, 1 Oct 2015 07:21:52 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id BE00D10B18; Wed, 30 Sep 2015 14:21:51 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id BDDE010B0C for ; Wed, 30 Sep 2015 14:21:50 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 3E8921E02DE for ; Wed, 30 Sep 2015 15:21:50 -0600 (MDT) X-ASG-Debug-ID: 1443648108-09eadd141810f50001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id i61HrsxjFs6F2SWi (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 30 Sep 2015 15:21:48 -0600 (MDT) X-Barracuda-Envelope-From: shettyg@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mail-pa0-f42.google.com) (209.85.220.42) by mx1-pf2.cudamail.com with ESMTPS (RC4-SHA encrypted); 30 Sep 2015 21:21:48 -0000 Received-SPF: unknown (mx1-pf2.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.42 Received: by pacfv12 with SMTP id fv12so52542313pac.2 for ; Wed, 30 Sep 2015 14:21:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=vqzwaSJdXuDm1S7psEVAVgckAFvMz2iazzCxS/CzUgo=; b=gINKGPvUqVW+EVrj6GDlHDCImfpaYxxDRBout5bzoLIH08MllbGP6uJSf9fj1kqHZI vQqxPRJMXGbIR/Ytif6VmW46oXLXtNCHRkTf2QONZav8zX76SD9Ya38BsefgGz+7wkH0 YtWTBAgmSiyOl6DE60Z6D6RwPjRRJVhI5tJs5u/19RtDwRyRRpR8cv6A0c5CfTGQAxNe R7JQJEy1sSLsOWN5L184bdF6AHboa1TZVlH9Va3tjuWw0L3A3G769jhshAqqtosbye37 dam1x8tZLjBpxSltqp8FNPwai/yIADMnckwtlfH6DhoEwL823kWPYu11GkIP597z4TqV nA4w== X-Gm-Message-State: ALoCoQkHN/P0RPfLDyOM5jK4HRAWMJ5J7wJkEeEeLb7ukZXcThlSnZqBDR+tGiY51n2IUtNmfYCF X-Received: by 10.66.242.138 with SMTP id wq10mr7469285pac.2.1443648107665; Wed, 30 Sep 2015 14:21:47 -0700 (PDT) Received: from ubuntu-test.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id fu4sm2433599pbb.59.2015.09.30.14.21.46 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Sep 2015 14:21:47 -0700 (PDT) X-CudaMail-Envelope-Sender: shettyg@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.1.34 From: Gurucharan Shetty X-Google-Original-From: Gurucharan Shetty To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E2-929099390 X-CudaMail-DTE: 093015 X-CudaMail-Originating-IP: 209.85.220.42 Date: Wed, 30 Sep 2015 14:18:47 -0700 X-ASG-Orig-Subj: [##CM-E2-929099390##][PATCH] poll-loop: Fix a bug while finding a poll node. Message-Id: <1443647927-29701-1-git-send-email-gshetty@nicira.com> X-Mailer: git-send-email 1.7.9.5 X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1443648108 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Gurucharan Shetty Subject: [ovs-dev] [PATCH] poll-loop: Fix a bug while finding a poll node. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" When a poll_node is created, it gets either a 'fd' or a 'wevent' (can't get both). When the poll_node is searched for previous creations on that 'fd' or 'wevent', the search criteria was wrong for Windows. In Windows, when a 'fd' is received in poll_create_node, we create a corresponding 'wevent'. So while searching for that 'fd', we should not look for 'wevent' in the hmap_node. Reported-by: Alin Gabriel Serdean Signed-off-by: Gurucharan Shetty Acked-by: Alin Gabriel Serdean Acked-by: Ben Pfaff --- lib/poll-loop.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/poll-loop.c b/lib/poll-loop.c index 3c4b55c..60e1f6e 100644 --- a/lib/poll-loop.c +++ b/lib/poll-loop.c @@ -57,16 +57,20 @@ struct poll_loop { static struct poll_loop *poll_loop(void); -/* Look up the node with same fd and wevent. */ +/* Look up the node with same fd or wevent. */ static struct poll_node * find_poll_node(struct poll_loop *loop, int fd, HANDLE wevent) { struct poll_node *node; + /* Both 'fd' and 'wevent' cannot be set. */ + ovs_assert(!fd != !wevent); + HMAP_FOR_EACH_WITH_HASH (node, hmap_node, hash_2words(fd, (uint32_t)wevent), &loop->poll_nodes) { - if (node->pollfd.fd == fd && node->wevent == wevent) { + if ((fd && node->pollfd.fd == fd) + || (wevent && node->wevent == wevent)) { return node; } }