[ovs-dev] [PATCH] poll-loop: Fix a bug while finding a poll node.

Ben Pfaff blp at nicira.com
Mon Oct 5 22:18:30 UTC 2015


On Mon, Oct 05, 2015 at 02:01:26PM -0700, Gurucharan Shetty wrote:
> >
> > I think that when the assertion is true (presumably always), the new and
> > the old 'if' conditions are equivalent.  Is that right?
> 
> They are not equivalent. In poll_create_node, we have the following
> piece of code.
> 
>     /* Check for duplicate.  If found, "or" the events. */
>     node = find_poll_node(loop, fd, wevent);
>     if (node) {
>         node->pollfd.events |= events;
>     } else {
>         node = xzalloc(sizeof *node);
>         hmap_insert(&loop->poll_nodes, &node->hmap_node,
>                     hash_2words(fd, (uint32_t)wevent));
>         node->pollfd.fd = fd;
>         node->pollfd.events = events;
> #ifdef _WIN32
>         if (!wevent) {
>             wevent = CreateEvent(NULL, FALSE, FALSE, NULL);
>         }
> #endif
>         node->wevent = wevent;
>         node->where = where;
>     }
> 
> For Windows, when 'fd' is set, when find_poll_node() returns false, we
> create a new poll_node whose key is 'fd' (wevent is zero). We later
> set node->wevent to the return value of CreateEvent().
> 
> When find_poll_node() is called again with the same 'fd', the current
> if condition in poll_fd_node() is wrong, because it does:
> "node->pollfd.fd == fd && node->wevent == wevent". The condition will
> never be true because 'wevent' passed to find_poll_node is 0 whereas
> node->wevent has a value set.
> 
> Did my above explanation make sense?

Yes.

Acked-by: Ben Pfaff <blp at nicira.com>



More information about the dev mailing list