Merge branch 'master' of git.dolda2000.com:/srv/git/r/ashd
authorFredrik Tolf <fredrik@dolda2000.com>
Sat, 1 Oct 2011 03:07:44 +0000 (05:07 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Sat, 1 Oct 2011 03:07:44 +0000 (05:07 +0200)
lib/mtio-epoll.c
lib/mtio-select.c

index 511af81..85ee4a1 100644 (file)
@@ -188,7 +188,7 @@ void ioloop(void)
        nev = epoll_wait(epfd, evr, sizeof(evr) / sizeof(*evr), toval);
        if(nev < 0) {
            if(errno != EINTR) {
-               flog(LOG_CRIT, "ioloop: select errored out: %s", strerror(errno));
+               flog(LOG_CRIT, "ioloop: epoll_wait errored out: %s", strerror(errno));
                /* To avoid CPU hogging in case it's bad, which it
                 * probably is. */
                sleep(1);
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;