summaryrefslogtreecommitdiff
path: root/ev_select.c
diff options
context:
space:
mode:
Diffstat (limited to 'ev_select.c')
-rw-r--r--ev_select.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/ev_select.c b/ev_select.c
index 1303a56..93d84cf 100644
--- a/ev_select.c
+++ b/ev_select.c
@@ -79,15 +79,24 @@ select_modify (EV_P_ int fd, int oev, int nev)
int handle = fd;
#endif
- if (nev & EV_READ)
- FD_SET (handle, (fd_set *)vec_ri);
- else
- FD_CLR (handle, (fd_set *)vec_ri);
-
- if (nev & EV_WRITE)
- FD_SET (handle, (fd_set *)vec_wi);
- else
- FD_CLR (handle, (fd_set *)vec_wi);
+ /* FD_SET is broken on windows (it adds the fd to a set twice or more,
+ * which eventually leads to overflows). Need to call it only on changes.
+ */
+ #if EV_SELECT_IS_WINSOCKET
+ if ((oev ^ nev) & EV_READ)
+ #endif
+ if (nev & EV_READ)
+ FD_SET (handle, (fd_set *)vec_ri);
+ else
+ FD_CLR (handle, (fd_set *)vec_ri);
+
+ #if EV_SELECT_IS_WINSOCKET
+ if ((oev ^ nev) & EV_WRITE)
+ #endif
+ if (nev & EV_WRITE)
+ FD_SET (handle, (fd_set *)vec_wi);
+ else
+ FD_CLR (handle, (fd_set *)vec_wi);
#else