Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions ext/libev/ev_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,35 +184,13 @@ select_modify (EV_P_ int fd, int oev, int nev)
}
}

#undef socket

static void
select_poll (EV_P_ ev_tstamp timeout)
{
struct timeval tv;
int res;
int fd_setsize;

#ifdef _WIN32
/* POSIX defines the case when the readfds, writefds, and errorfds arguments
* are all null pointers.
* http://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html
*
* But Windows doesn't define such case; simply say don't so that
* https://msdn.microsoft.com/en-us/library/windows/desktop/ms740141(v=vs.85).aspx
* "Any two of the parameters, readfds, writefds, or exceptfds, can be given
* as null. At least one must be non-null, and any non-null descriptor set
* must contain at least one handle to a socket."
* At least on Windows Server 2012 R2 Datacenter with Visual Studio 2013
* (Visual C++ 12), it cause WaitForMultipleObjects stuck.
*/
if (EV_WIN_FD_COUNT(vec_ri) == 0 && EV_WIN_FD_COUNT(vec_wi) == 0)
{
ev_sleep (timeout);
return;
}
#endif

EV_RELEASE_CB;
EV_TV_SET (tv, timeout);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does using SleepEx care this situation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once I thought NULL fds for select cause stuck, but https://github.com/tarcieri/cool.io/pull/47/files#diff-c9164d22260cba57b9d4a9beb08b42d0L258 says it will return EINVAL. I confirmed it with simple C program.
Now I think I misunderstood stuck on select() instead of stuck on Sleep().

Anyway this code still has a meaning as shortcut (skip select() and just sleep), but I choose code size.

Expand Down Expand Up @@ -268,7 +246,7 @@ select_poll (EV_P_ ev_tstamp timeout)
if (timeout)
{
unsigned long ms = (unsigned long)(timeout * 1e3);
Sleep (ms ? ms : 1);
SleepEx (ms ? ms : 1, TRUE);
}

return;
Expand Down