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.27 by root, Wed Nov 28 11:15:55 2007 UTC vs.
Revision 1.31 by root, Sun Dec 9 15:06:21 2007 UTC

81 81
82 /* need to resize so there is enough space for errors */ 82 /* need to resize so there is enough space for errors */
83 if (kqueue_changecnt > kqueue_eventmax) 83 if (kqueue_changecnt > kqueue_eventmax)
84 { 84 {
85 ev_free (kqueue_events); 85 ev_free (kqueue_events);
86 kqueue_eventmax = array_roundsize (struct kevent, kqueue_changecnt); 86 kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt);
87 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); 87 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
88 } 88 }
89 89
90 ts.tv_sec = (time_t)timeout; 90 ts.tv_sec = (time_t)timeout;
91 ts.tv_nsec = (long)((timeout - (ev_tstamp)ts.tv_sec) * 1e9); 91 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); 92 res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts);
93 kqueue_changecnt = 0; 93 kqueue_changecnt = 0;
94 94
95 if (res < 0) 95 if (expect_false (res < 0))
96 { 96 {
97 if (errno != EINTR) 97 if (errno != EINTR)
98 syserr ("(libev) kevent"); 98 syserr ("(libev) kevent");
99 99
100 return; 100 return;
135 } 135 }
136 136
137 if (expect_false (res == kqueue_eventmax)) 137 if (expect_false (res == kqueue_eventmax))
138 { 138 {
139 ev_free (kqueue_events); 139 ev_free (kqueue_events);
140 kqueue_eventmax = array_roundsize (struct kevent, kqueue_eventmax << 1); 140 kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_eventmax + 1);
141 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); 141 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
142 } 142 }
143} 143}
144 144
145int inline_size 145int inline_size
151 if ((backend_fd = kqueue ()) < 0) 151 if ((backend_fd = kqueue ()) < 0)
152 return 0; 152 return 0;
153 153
154 fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ 154 fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
155 155
156 /* fudge *might* be zero from the documentation, but bsd docs are notoriously wrong */ 156 backend_fudge = 0.;
157 backend_fudge = 1e-3; /* needed to compensate for kevent returning early */
158 backend_modify = kqueue_modify; 157 backend_modify = kqueue_modify;
159 backend_poll = kqueue_poll; 158 backend_poll = kqueue_poll;
160 159
161 kqueue_eventmax = 64; /* initial number of events receivable per poll */ 160 kqueue_eventmax = 64; /* initial number of events receivable per poll */
162 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); 161 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines