[ovs-dev] [PATCH] poll-loop: fix assertion in poll_create_node

Ben Pfaff blp at nicira.com
Wed Sep 30 03:49:15 UTC 2015


On Wed, Sep 30, 2015 at 02:44:15AM +0000, Alin Serdean wrote:
> The ides is the following:
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms740094%28v=vs.85%29.aspx
> and SOCKET is defined as:
> typedef UINT_PTR        SOCKET;
> 
> When we do the following:
> node->pollfd.fd = fd;
> and fd = -1, node->pollfd.fd will rollover.

That pages talks, twice, about negative values of fd.  That's
*intentionally* goddamn deceptive for talking about an unsigned type.
Microsoft should fix their documentation.  Maybe someone with an account
should add a comment on the page.

But: maybe we're doing totally the wrong thing if a SOCKET is really a
UINT_PTR, because that means we need a 64-bit (unsigned) type and we're
using an int in the function prototypes.  Maybe we need to change all
the function prototypes to use `int' on Unix and `SOCKET' on Windows
(presumably via typedef).

On the other hand, I guess socket() can't just be returning random
64-bit numbers as SOCKET values, since that would totally break the
select() function that Winsock appears to support at least somewhat.
Maybe it always returns a small integer.  (However, if it ever returns
zero...).



More information about the dev mailing list