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.8 by root, Sun Nov 4 18:29:44 2007 UTC vs.
Revision 1.9 by root, Tue Nov 6 00:10:04 2007 UTC

83 ts.tv_nsec = (long)(timeout - (ev_tstamp)ts.tv_sec) * 1e9; 83 ts.tv_nsec = (long)(timeout - (ev_tstamp)ts.tv_sec) * 1e9;
84 res = kevent (kqueue_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts); 84 res = kevent (kqueue_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts);
85 kqueue_changecnt = 0; 85 kqueue_changecnt = 0;
86 86
87 if (res < 0) 87 if (res < 0)
88 {
89 if (errno != EINTR)
90 syserr ();
91
88 return; 92 return;
93 }
89 94
90 for (i = 0; i < res; ++i) 95 for (i = 0; i < res; ++i)
91 { 96 {
92 if (kqueue_events [i].flags & EV_ERROR) 97 if (kqueue_events [i].flags & EV_ERROR)
93 { 98 {
116 ); 121 );
117 } 122 }
118 123
119 if (expect_false (res == kqueue_eventmax)) 124 if (expect_false (res == kqueue_eventmax))
120 { 125 {
121 free (kqueue_events); 126 ev_free (kqueue_events);
122 kqueue_eventmax = array_roundsize (kqueue_events, kqueue_eventmax << 1); 127 kqueue_eventmax = array_roundsize (kqueue_events, kqueue_eventmax << 1);
123 kqueue_events = malloc (sizeof (struct kevent) * kqueue_eventmax); 128 kqueue_events = ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
124 } 129 }
125} 130}
126 131
127static int 132static int
128kqueue_init (EV_P_ int flags) 133kqueue_init (EV_P_ int flags)
157 method_fudge = 1e-3; /* needed to compensate for kevent returning early */ 162 method_fudge = 1e-3; /* needed to compensate for kevent returning early */
158 method_modify = kqueue_modify; 163 method_modify = kqueue_modify;
159 method_poll = kqueue_poll; 164 method_poll = kqueue_poll;
160 165
161 kqueue_eventmax = 64; /* intiial number of events receivable per poll */ 166 kqueue_eventmax = 64; /* intiial number of events receivable per poll */
162 kqueue_events = malloc (sizeof (struct kevent) * kqueue_eventmax); 167 kqueue_events = ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
163 168
164 kqueue_changes = 0; 169 kqueue_changes = 0;
165 kqueue_changemax = 0; 170 kqueue_changemax = 0;
166 kqueue_changecnt = 0; 171 kqueue_changecnt = 0;
167 172
171static void 176static void
172kqueue_destroy (EV_P) 177kqueue_destroy (EV_P)
173{ 178{
174 close (kqueue_fd); 179 close (kqueue_fd);
175 180
176 free (kqueue_events); 181 ev_free (kqueue_events);
177 free (kqueue_changes); 182 ev_free (kqueue_changes);
178} 183}
179 184
180static void 185static void
181kqueue_fork (EV_P) 186kqueue_fork (EV_P)
182{ 187{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines