Mercurial > hg > nginx
comparison src/event/modules/ngx_kqueue_module.c @ 59:e8cdc2989cee
nginx-0.0.1-2003-02-06-20:21:13 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 06 Feb 2003 17:21:13 +0000 |
parents | d1e42f1b8fd4 |
children | 50186b49f2ad |
comparison
equal
deleted
inserted
replaced
58:6b13b1cadabe | 59:e8cdc2989cee |
---|---|
21 #define KQUEUE_NCHANGES 512 | 21 #define KQUEUE_NCHANGES 512 |
22 #define KQUEUE_NEVENTS 512 | 22 #define KQUEUE_NEVENTS 512 |
23 | 23 |
24 | 24 |
25 /* should be per-thread */ | 25 /* should be per-thread */ |
26 #if 1 | |
27 int kq; | |
28 #else | |
26 static int kq; | 29 static int kq; |
30 #endif | |
27 static struct kevent *change_list, *event_list; | 31 static struct kevent *change_list, *event_list; |
28 static unsigned int nchanges; | 32 static unsigned int nchanges; |
29 static int nevents; | 33 static int nevents; |
30 | 34 |
31 static ngx_event_t *timer_queue; | 35 static ngx_event_t *timer_queue; |
61 ngx_event_actions.del = ngx_kqueue_del_event; | 65 ngx_event_actions.del = ngx_kqueue_del_event; |
62 ngx_event_actions.timer = ngx_event_add_timer; | 66 ngx_event_actions.timer = ngx_event_add_timer; |
63 ngx_event_actions.process = ngx_kqueue_process_events; | 67 ngx_event_actions.process = ngx_kqueue_process_events; |
64 | 68 |
65 ngx_event_flags = NGX_HAVE_LEVEL_EVENT | 69 ngx_event_flags = NGX_HAVE_LEVEL_EVENT |
66 |NGX_HAVE_ONESHOT_EVENT|NGX_HAVE_CLEAR_EVENT; | 70 |NGX_HAVE_ONESHOT_EVENT |
71 #if (HAVE_AIO_EVENT) | |
72 |NGX_HAVE_AIO_EVENT; | |
73 #else | |
74 |NGX_HAVE_CLEAR_EVENT; | |
75 #endif | |
67 #endif | 76 #endif |
68 | 77 |
69 return NGX_OK; | 78 return NGX_OK; |
70 } | 79 } |
71 | 80 |
219 #endif | 228 #endif |
220 | 229 |
221 for (i = 0; i < events; i++) { | 230 for (i = 0; i < events; i++) { |
222 | 231 |
223 #if (NGX_DEBUG_EVENT) | 232 #if (NGX_DEBUG_EVENT) |
224 ngx_log_debug(log, "kevent: %d: ft:%d f:%08x ff:%08x d:%d ud:%08x" _ | 233 if (event_list[i].ident > 0x8000000) { |
225 event_list[i].ident _ event_list[i].filter _ | 234 ngx_log_debug(log, |
226 event_list[i].flags _ event_list[i].fflags _ | 235 "kevent: %08x: ft:%d f:%08x ff:%08x d:%d ud:%08x" _ |
227 event_list[i].data _ event_list[i].udata); | 236 event_list[i].ident _ event_list[i].filter _ |
237 event_list[i].flags _ event_list[i].fflags _ | |
238 event_list[i].data _ event_list[i].udata); | |
239 } else { | |
240 ngx_log_debug(log, | |
241 "kevent: %d: ft:%d f:%08x ff:%08x d:%d ud:%08x" _ | |
242 event_list[i].ident _ event_list[i].filter _ | |
243 event_list[i].flags _ event_list[i].fflags _ | |
244 event_list[i].data _ event_list[i].udata); | |
245 } | |
228 #endif | 246 #endif |
229 | 247 |
230 if (event_list[i].flags & EV_ERROR) { | 248 if (event_list[i].flags & EV_ERROR) { |
231 ngx_log_error(NGX_LOG_ALERT, log, event_list[i].data, | 249 ngx_log_error(NGX_LOG_ALERT, log, event_list[i].data, |
232 "kevent error on %d", event_list[i].ident); | 250 "kevent error on %d", event_list[i].ident); |
241 | 259 |
242 switch (event_list[i].filter) { | 260 switch (event_list[i].filter) { |
243 | 261 |
244 case EVFILT_READ: | 262 case EVFILT_READ: |
245 case EVFILT_WRITE: | 263 case EVFILT_WRITE: |
246 ev->ready = 1; | |
247 ev->available = event_list[i].data; | 264 ev->available = event_list[i].data; |
248 | 265 |
249 if (event_list[i].flags & EV_EOF) { | 266 if (event_list[i].flags & EV_EOF) { |
250 ev->eof = 1; | 267 ev->eof = 1; |
251 ev->error = event_list[i].fflags; | 268 ev->error = event_list[i].fflags; |
253 | 270 |
254 if (ev->oneshot) { | 271 if (ev->oneshot) { |
255 ngx_del_timer(ev); | 272 ngx_del_timer(ev); |
256 } | 273 } |
257 | 274 |
275 /* fall through */ | |
276 | |
277 case EVFILT_AIO: | |
278 ev->ready = 1; | |
279 | |
258 if (ev->event_handler(ev) == NGX_ERROR) { | 280 if (ev->event_handler(ev) == NGX_ERROR) { |
259 ev->close_handler(ev); | 281 ev->close_handler(ev); |
260 } | 282 } |
261 | 283 |
262 break; | 284 break; |
263 | 285 |
286 | |
264 default: | 287 default: |
265 ngx_log_error(NGX_LOG_ALERT, log, 0, | 288 ngx_log_error(NGX_LOG_ALERT, log, 0, |
266 "unknown kevent filter %d" _ event_list[i].filter); | 289 "unknown kevent filter %d" _ event_list[i].filter); |
267 } | 290 } |
268 } | 291 } |