Updated ChangeLog.
[ashd.git] / lib / mtio-select.c
index eb84a45..6536c95 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
+#include <unistd.h>
 #include <errno.h>
 #include <sys/select.h>
 
@@ -44,6 +46,11 @@ int block(int fd, int ev, time_t to)
     struct blocker *bl;
     int rv;
     
+    if(fd >= FD_SETSIZE) {
+       flog(LOG_ERR, "tried to use more file descriptors than select() can handle: fd %i", fd);
+       errno = EMFILE;
+       return(-1);
+    }
     omalloc(bl);
     bl->fd = fd;
     bl->ev = ev;