1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/win32port/win32helpers
Graham Newton 7ee4f890a3 windows workaround unsigned fd in emulated poll
A common practise to temporarily disable a socket in a poll call is to negate the socket fd.  poll should then ignore the socket.
emulated_poll does this with the following code:
        if (poll_fd->fd < 0 || !poll_fd->events)
            goto skip1;

However on Windows the fd field in WSAPOLLFD is unsigned int!!!  So the check for a negative fd value always fails.
This results in select returning an error with an error code of 10038 -- Socket operation on nonsocket.
The fix is to type cast fd like so:
        if ((int)poll_fd->fd < 0 || !poll_fd->events)

This may be the cause of some high CPU load reports.  I noticed the load being 50% with my application running on Windows XP.

Signed-off-by: Graham Newton <gnewton@peavey-eu.com>
2013-11-09 08:11:41 +08:00
..
sys introduce win32 build capability 2011-03-02 22:03:47 +00:00
getopt.c update win32 support for zlib 2011-03-10 18:19:10 +00:00
getopt.h update win32 support for zlib 2011-03-10 18:19:10 +00:00
getopt_long.c update win32 support for zlib 2011-03-10 18:19:10 +00:00
gettimeofday.c fix win32helpers gettimeofday epoch 2013-03-05 08:41:47 +08:00
gettimeofday.h mingw gettimeofday avoid missing include 2012-04-12 13:31:12 +08:00
netdb.h introduce win32 build capability 2011-03-02 22:03:47 +00:00
strings.h introduce win32 build capability 2011-03-02 22:03:47 +00:00
unistd.h introduce win32 build capability 2011-03-02 22:03:47 +00:00
websock-w32.c windows workaround unsigned fd in emulated poll 2013-11-09 08:11:41 +08:00
websock-w32.h Windows Fix usage in Windows XP targetting projects 2013-11-04 10:18:14 +08:00