… | |
… | |
95 | kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt); |
95 | kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt); |
96 | kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); |
96 | kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); |
97 | } |
97 | } |
98 | |
98 | |
99 | EV_RELEASE_CB; |
99 | EV_RELEASE_CB; |
100 | ts.tv_sec = (time_t)timeout; |
100 | EV_SET_TV (tv, timeout); |
101 | ts.tv_nsec = (long)((timeout - (ev_tstamp)ts.tv_sec) * 1e9); |
|
|
102 | res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts); |
101 | res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts); |
103 | EV_ACQUIRE_CB; |
102 | EV_ACQUIRE_CB; |
104 | kqueue_changecnt = 0; |
103 | kqueue_changecnt = 0; |
105 | |
104 | |
106 | if (expect_false (res < 0)) |
105 | if (expect_false (res < 0)) |
… | |
… | |
154 | } |
153 | } |
155 | |
154 | |
156 | int inline_size |
155 | int inline_size |
157 | kqueue_init (EV_P_ int flags) |
156 | kqueue_init (EV_P_ int flags) |
158 | { |
157 | { |
159 | /* Initalize the kernel queue */ |
158 | /* Initialize the kernel queue */ |
160 | if ((backend_fd = kqueue ()) < 0) |
159 | if ((backend_fd = kqueue ()) < 0) |
161 | return 0; |
160 | return 0; |
162 | |
161 | |
163 | fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ |
162 | fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ |
164 | |
163 | |