--- libev/ev_epoll.c 2008/10/27 13:39:18 1.37 +++ libev/ev_epoll.c 2008/11/07 15:07:50 1.43 @@ -70,7 +70,7 @@ * on the assumption that the fd is gone anyways * if that is wrong, we have to handle the spurious * event in epoll_poll. - * the fd is later added, we try to ADD it, and, if that + * if the fd is added again, we try to ADD it, and, if that * fails, we assume it still has the same eventmask. */ if (!nev) @@ -79,8 +79,9 @@ oldmask = anfds [fd].emask; anfds [fd].emask = nev; - /* store the generation counter in the upper 32 bits */ - ev.data.u64 = fd | ((uint64_t)++anfds [fd].egen << 32); + /* store the generation counter in the upper 32 bits, the fd in the lower 32 bits */ + ev.data.u64 = (uint64_t)(uint32_t)fd + | ((uint64_t)(uint32_t)++anfds [fd].egen << 32); ev.events = (nev & EV_READ ? EPOLLIN : 0) | (nev & EV_WRITE ? EPOLLOUT : 0); @@ -123,7 +124,7 @@ if (expect_false (eventcnt < 0)) { if (errno != EINTR) - syserr ("(libev) epoll_wait"); + ev_syserr ("(libev) epoll_wait"); return; } @@ -138,7 +139,7 @@ | (ev->events & (EPOLLIN | EPOLLERR | EPOLLHUP) ? EV_READ : 0); /* check for spurious notification */ - if (expect_false (anfds [fd].egen != (unsigned char)(ev->data.u64 >> 32))) + if (expect_false ((uint32_t)anfds [fd].egen != (uint32_t)(ev->data.u64 >> 32))) { /* recreate kernel state */ postfork = 1; @@ -205,7 +206,7 @@ close (backend_fd); while ((backend_fd = epoll_create (256)) < 0) - syserr ("(libev) epoll_create"); + ev_syserr ("(libev) epoll_create"); fcntl (backend_fd, F_SETFD, FD_CLOEXEC);