summaryrefslogtreecommitdiff
path: root/ev_select.c
diff options
context:
space:
mode:
Diffstat (limited to 'ev_select.c')
-rw-r--r--ev_select.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ev_select.c b/ev_select.c
index 1835444..5a5a61d 100644
--- a/ev_select.c
+++ b/ev_select.c
@@ -1,7 +1,7 @@
/*
* libev select fd activity backend
*
- * Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de>
+ * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
@@ -72,6 +72,7 @@ select_modify (EV_P_ int fd, int oev, int nev)
{
#if EV_SELECT_USE_FD_SET
+ assert (("libev: fd >= FD_SETSIZE passed to fd_set-based select backend", fd < FD_SETSIZE));
#if EV_SELECT_IS_WINSOCKET
SOCKET handle = anfds [fd].handle;
@@ -158,6 +159,9 @@ select_poll (EV_P_ ev_tstamp timeout)
*/
memcpy (vec_eo, vec_wi, fd_setsize);
res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, (fd_set *)vec_eo, &tv);
+#elif EV_SELECT_USE_FD_SET
+ fd_setsize = anfdmax < FD_SETSIZE ? anfdmax : FD_SETSIZE;
+ res = select (fd_setsize, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv);
#else
res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv);
#endif
@@ -265,7 +269,6 @@ select_init (EV_P_ int flags)
backend_poll = select_poll;
#if EV_SELECT_USE_FD_SET
- vec_max = FD_SETSIZE / 32;
vec_ri = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_ri);
vec_ro = ev_malloc (sizeof (fd_set));
vec_wi = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_wi);