ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev_epoll.c
(Generate patch)

Comparing libev/ev_epoll.c (file contents):
Revision 1.41 by root, Wed Oct 29 07:10:16 2008 UTC vs.
Revision 1.44 by root, Thu Jul 9 09:11:20 2009 UTC

68 /* 68 /*
69 * we handle EPOLL_CTL_DEL by ignoring it here 69 * we handle EPOLL_CTL_DEL by ignoring it here
70 * on the assumption that the fd is gone anyways 70 * on the assumption that the fd is gone anyways
71 * if that is wrong, we have to handle the spurious 71 * if that is wrong, we have to handle the spurious
72 * event in epoll_poll. 72 * event in epoll_poll.
73 * the fd is later added, we try to ADD it, and, if that 73 * if the fd is added again, we try to ADD it, and, if that
74 * fails, we assume it still has the same eventmask. 74 * fails, we assume it still has the same eventmask.
75 */ 75 */
76 if (!nev) 76 if (!nev)
77 return; 77 return;
78 78
79 oldmask = anfds [fd].emask; 79 oldmask = anfds [fd].emask;
80 anfds [fd].emask = nev; 80 anfds [fd].emask = nev;
81 81
82 /* store the generation counter in the upper 32 bits */ 82 /* store the generation counter in the upper 32 bits, the fd in the lower 32 bits */
83 ev.data.u64 = (uint64_t)(uint32_t)fd | ((uint64_t)(uint32_t)++anfds [fd].egen << 32); 83 ev.data.u64 = (uint64_t)(uint32_t)fd
84 | ((uint64_t)(uint32_t)++anfds [fd].egen << 32);
84 ev.events = (nev & EV_READ ? EPOLLIN : 0) 85 ev.events = (nev & EV_READ ? EPOLLIN : 0)
85 | (nev & EV_WRITE ? EPOLLOUT : 0); 86 | (nev & EV_WRITE ? EPOLLOUT : 0);
86 87
87 if (expect_true (!epoll_ctl (backend_fd, oev ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, fd, &ev))) 88 if (expect_true (!epoll_ctl (backend_fd, oev ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, fd, &ev)))
88 return; 89 return;
116 117
117static void 118static void
118epoll_poll (EV_P_ ev_tstamp timeout) 119epoll_poll (EV_P_ ev_tstamp timeout)
119{ 120{
120 int i; 121 int i;
122 int eventcnt;
123
124 if (expect_false (suspend_cb)) suspend_cb (EV_A);
121 int eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, (int)ceil (timeout * 1000.)); 125 eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, (int)ceil (timeout * 1000.));
126 if (expect_false (resume_cb)) resume_cb (EV_A);
122 127
123 if (expect_false (eventcnt < 0)) 128 if (expect_false (eventcnt < 0))
124 { 129 {
125 if (errno != EINTR) 130 if (errno != EINTR)
126 ev_syserr ("(libev) epoll_wait"); 131 ev_syserr ("(libev) epoll_wait");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines