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

Comparing libev/ev_kqueue.c (file contents):
Revision 1.28 by root, Wed Dec 5 13:54:37 2007 UTC vs.
Revision 1.32 by ayin, Mon Dec 17 11:54:29 2007 UTC

37#include <errno.h> 37#include <errno.h>
38 38
39void inline_speed 39void inline_speed
40kqueue_change (EV_P_ int fd, int filter, int flags, int fflags) 40kqueue_change (EV_P_ int fd, int filter, int flags, int fflags)
41{ 41{
42 struct kevent *ke;
43
44 ++kqueue_changecnt; 42 ++kqueue_changecnt;
45 array_needsize (struct kevent, kqueue_changes, kqueue_changemax, kqueue_changecnt, EMPTY2); 43 array_needsize (struct kevent, kqueue_changes, kqueue_changemax, kqueue_changecnt, EMPTY2);
46 44
47 EV_SET (&kqueue_changes [kqueue_changecnt - 1], fd, filter, flags, fflags, 0, 0); 45 EV_SET (&kqueue_changes [kqueue_changecnt - 1], fd, filter, flags, fflags, 0, 0);
48} 46}
90 ts.tv_sec = (time_t)timeout; 88 ts.tv_sec = (time_t)timeout;
91 ts.tv_nsec = (long)((timeout - (ev_tstamp)ts.tv_sec) * 1e9); 89 ts.tv_nsec = (long)((timeout - (ev_tstamp)ts.tv_sec) * 1e9);
92 res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts); 90 res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts);
93 kqueue_changecnt = 0; 91 kqueue_changecnt = 0;
94 92
95 if (res < 0) 93 if (expect_false (res < 0))
96 { 94 {
97 if (errno != EINTR) 95 if (errno != EINTR)
98 syserr ("(libev) kevent"); 96 syserr ("(libev) kevent");
99 97
100 return; 98 return;
143} 141}
144 142
145int inline_size 143int inline_size
146kqueue_init (EV_P_ int flags) 144kqueue_init (EV_P_ int flags)
147{ 145{
148 struct kevent ch, ev;
149
150 /* Initalize the kernel queue */ 146 /* Initalize the kernel queue */
151 if ((backend_fd = kqueue ()) < 0) 147 if ((backend_fd = kqueue ()) < 0)
152 return 0; 148 return 0;
153 149
154 fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ 150 fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
155 151
156 /* fudge *might* be zero from the documentation, but bsd docs are notoriously wrong */ 152 backend_fudge = 0.;
157 backend_fudge = 1e-3; /* needed to compensate for kevent returning early */
158 backend_modify = kqueue_modify; 153 backend_modify = kqueue_modify;
159 backend_poll = kqueue_poll; 154 backend_poll = kqueue_poll;
160 155
161 kqueue_eventmax = 64; /* initial number of events receivable per poll */ 156 kqueue_eventmax = 64; /* initial number of events receivable per poll */
162 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); 157 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines