blob: 1d387799ab0047da7c28e75b54183e559c38e402 [file] [log] [blame]
Igor Sysoev10318a22004-01-29 21:45:01 +00001
2/*
3 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/
4 */
5
6
7#include <ngx_config.h>
8#include <ngx_core.h>
9#include <ngx_event.h>
10
11
12#if (TEST_BUILD_EPOLL)
13
14/* epoll declarations */
15
Igor Sysoev328af6e2004-02-01 08:10:52 +000016#define EPOLLIN 0x001
17#define EPOLLPRI 0x002
18#define EPOLLOUT 0x004
19#define EPOLLRDNORM 0x040
20#define EPOLLRDBAND 0x080
21#define EPOLLWRNORM 0x100
22#define EPOLLWRBAND 0x200
23#define EPOLLMSG 0x400
24#define EPOLLERR 0x008
25#define EPOLLHUP 0x010
26
27#define EPOLLET 0x80000000
28#define EPOLLONESHOT 0x40000000
Igor Sysoev10318a22004-01-29 21:45:01 +000029
30#define EPOLL_CTL_ADD 1
31#define EPOLL_CTL_DEL 2
32#define EPOLL_CTL_MOD 3
33
34typedef union epoll_data {
35 void *ptr;
36 int fd;
37 uint32_t u32;
38 uint64_t u64;
39} epoll_data_t;
40
41struct epoll_event {
42 uint32_t events;
43 epoll_data_t data;
44};
45
46int epoll_create(int size);
47int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
48int epoll_wait(int epfd, struct epoll_event *events, int nevents, int timeout);
49
50int epoll_create(int size)
51{
52 return -1;
53}
54
55int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
56{
57 return -1;
58}
59
60int epoll_wait(int epfd, struct epoll_event *events, int nevents, int timeout)
61{
62 return -1;
63}
64
65#endif
66
67
68typedef struct {
69 u_int events;
70} ngx_epoll_conf_t;
71
72
73static int ngx_epoll_init(ngx_cycle_t *cycle);
74static void ngx_epoll_done(ngx_cycle_t *cycle);
Igor Sysoevbbcea6c2004-01-30 17:39:00 +000075static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags);
76static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags);
Igor Sysoev10318a22004-01-29 21:45:01 +000077static int ngx_epoll_add_connection(ngx_connection_t *c);
78static int ngx_epoll_del_connection(ngx_connection_t *c);
Igor Sysoevc972a3f2004-04-02 15:13:20 +000079static int ngx_epoll_process_events(ngx_cycle_t *cycle);
Igor Sysoev10318a22004-01-29 21:45:01 +000080
81static void *ngx_epoll_create_conf(ngx_cycle_t *cycle);
82static char *ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf);
83
84static int ep = -1;
85static struct epoll_event *event_list;
86static u_int nevents;
87
88
89static ngx_str_t epoll_name = ngx_string("epoll");
90
91static ngx_command_t ngx_epoll_commands[] = {
92
93 {ngx_string("epoll_events"),
94 NGX_EVENT_CONF|NGX_CONF_TAKE1,
95 ngx_conf_set_num_slot,
96 0,
97 offsetof(ngx_epoll_conf_t, events),
98 NULL},
99
100 ngx_null_command
101};
102
103
104ngx_event_module_t ngx_epoll_module_ctx = {
105 &epoll_name,
106 ngx_epoll_create_conf, /* create configuration */
107 ngx_epoll_init_conf, /* init configuration */
108
109 {
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000110 ngx_epoll_add_event, /* add an event */
111 ngx_epoll_del_event, /* delete an event */
112 ngx_epoll_add_event, /* enable an event */
113 ngx_epoll_del_event, /* disable an event */
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000114 NULL, /* add an connection */
115 NULL, /* delete an connection */
Igor Sysoev10318a22004-01-29 21:45:01 +0000116 ngx_epoll_process_events, /* process the events */
117 ngx_epoll_init, /* init the events */
118 ngx_epoll_done, /* done the events */
119 }
Igor Sysoev10318a22004-01-29 21:45:01 +0000120};
121
122ngx_module_t ngx_epoll_module = {
123 NGX_MODULE,
124 &ngx_epoll_module_ctx, /* module context */
125 ngx_epoll_commands, /* module directives */
126 NGX_EVENT_MODULE, /* module type */
127 NULL, /* init module */
128 NULL /* init child */
129};
130
131
132static int ngx_epoll_init(ngx_cycle_t *cycle)
133{
134 size_t n;
Igor Sysoevc7a2f682004-02-10 16:23:38 +0000135 ngx_event_conf_t *ecf;
Igor Sysoev10318a22004-01-29 21:45:01 +0000136 ngx_epoll_conf_t *epcf;
137
Igor Sysoevc7a2f682004-02-10 16:23:38 +0000138 ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module);
139
Igor Sysoev10318a22004-01-29 21:45:01 +0000140 epcf = ngx_event_get_conf(cycle->conf_ctx, ngx_epoll_module);
141
142 if (ep == -1) {
Igor Sysoevc7a2f682004-02-10 16:23:38 +0000143 ep = epoll_create(ecf->connections / 2);
Igor Sysoev10318a22004-01-29 21:45:01 +0000144
145 if (ep == -1) {
146 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
147 "epoll_create() failed");
148 return NGX_ERROR;
149 }
150 }
151
152 if (nevents < epcf->events) {
153 if (event_list) {
154 ngx_free(event_list);
155 }
156
157 event_list = ngx_alloc(sizeof(struct epoll_event) * epcf->events,
158 cycle->log);
159 if (event_list == NULL) {
160 return NGX_ERROR;
161 }
162 }
163
164 nevents = epcf->events;
165
166 ngx_io = ngx_os_io;
167
168 ngx_event_actions = ngx_epoll_module_ctx.actions;
169
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000170#if (HAVE_CLEAR_EVENT)
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000171 ngx_event_flags = NGX_USE_CLEAR_EVENT
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000172#else
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000173 ngx_event_flags = NGX_USE_LEVEL_EVENT
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000174#endif
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000175 |NGX_HAVE_INSTANCE_EVENT;
Igor Sysoev10318a22004-01-29 21:45:01 +0000176
177 return NGX_OK;
178}
179
180
181static void ngx_epoll_done(ngx_cycle_t *cycle)
182{
183 if (close(ep) == -1) {
184 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
185 "epoll close() failed");
186 }
187
188 ep = -1;
189
190 ngx_free(event_list);
191
192 event_list = NULL;
193 nevents = 0;
194}
195
196
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000197static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
198{
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000199 int op, prev;
200 ngx_event_t *e;
Igor Sysoevdfe63ad2004-02-11 07:19:26 +0000201 ngx_connection_t *c;
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000202 struct epoll_event ee;
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000203
204 c = ev->data;
205
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000206 if (event == NGX_READ_EVENT) {
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000207 e = c->write;
208 prev = EPOLLOUT;
209#if (NGX_READ_EVENT != EPOLLIN)
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000210 event = EPOLLIN;
Igor Sysoev54498db2004-02-11 17:08:49 +0000211#endif
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000212
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000213 } else {
214 e = c->read;
215 prev = EPOLLIN;
216#if (NGX_WRITE_EVENT != EPOLLOUT)
217 event = EPOLLOUT;
218#endif
219 }
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000220
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000221 if (e->active) {
222 op = EPOLL_CTL_MOD;
223 event |= prev;
Igor Sysoev54498db2004-02-11 17:08:49 +0000224
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000225 } else {
226 op = EPOLL_CTL_ADD;
227 }
228
229 ee.events = event | flags;
230 ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
231
232 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
233 "epoll add event: fd:%d op:%d ev:%08X",
234 c->fd, op, ee.events);
235
236 if (epoll_ctl(ep, op, c->fd, &ee) == -1) {
237 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
238 "epoll_ctl(%d, %d) failed", op, c->fd);
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000239 return NGX_ERROR;
240 }
241
Igor Sysoev328af6e2004-02-01 08:10:52 +0000242 ev->active = 1;
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000243#if 0
244 ev->oneshot = (flags & NGX_ONESHOT_EVENT) ? 1 : 0;
245#endif
Igor Sysoev328af6e2004-02-01 08:10:52 +0000246
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000247 return NGX_OK;
248}
249
250
251static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
252{
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000253 int op, prev;
254 ngx_event_t *e;
Igor Sysoevdfe63ad2004-02-11 07:19:26 +0000255 ngx_connection_t *c;
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000256 struct epoll_event ee;
257
258 /*
259 * when the file descriptor is closed the epoll automatically deletes
260 * it from its queue so we do not need to delete explicity the event
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000261 * before the closing the file descriptor
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000262 */
263
264 if (flags & NGX_CLOSE_EVENT) {
265 ev->active = 0;
266 return NGX_OK;
267 }
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000268
269 c = ev->data;
270
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000271 if (event == NGX_READ_EVENT) {
272 e = c->write;
273 prev = EPOLLOUT;
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000274
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000275 } else {
276 e = c->read;
277 prev = EPOLLIN;
278 }
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000279
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000280 if (e->active) {
281 op = EPOLL_CTL_MOD;
282 ee.events = prev | flags;
283 ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
284
285 } else {
286 op = EPOLL_CTL_DEL;
287 ee.events = 0;
288 ee.data.ptr = NULL;
289 }
290
291 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
292 "epoll del event: fd:%d op:%d ev:%08X",
293 c->fd, op, ee.events);
294
295 if (epoll_ctl(ep, op, c->fd, &ee) == -1) {
296 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
297 "epoll_ctl(%d, %d) failed", op, c->fd);
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000298 return NGX_ERROR;
299 }
300
Igor Sysoev328af6e2004-02-01 08:10:52 +0000301 ev->active = 0;
302
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000303 return NGX_OK;
304}
305
306
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000307#if 0
Igor Sysoev10318a22004-01-29 21:45:01 +0000308static int ngx_epoll_add_connection(ngx_connection_t *c)
309{
Igor Sysoev328af6e2004-02-01 08:10:52 +0000310 struct epoll_event ee;
Igor Sysoev10318a22004-01-29 21:45:01 +0000311
Igor Sysoev7af6b162004-02-09 07:46:43 +0000312 ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
Igor Sysoev328af6e2004-02-01 08:10:52 +0000313 ee.data.ptr = (void *) ((uintptr_t) c | c->read->instance);
Igor Sysoev10318a22004-01-29 21:45:01 +0000314
315 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
Igor Sysoev7af6b162004-02-09 07:46:43 +0000316 "epoll add connection: fd:%d ev:%08X", c->fd, ee.events);
Igor Sysoev10318a22004-01-29 21:45:01 +0000317
Igor Sysoev328af6e2004-02-01 08:10:52 +0000318 if (epoll_ctl(ep, EPOLL_CTL_ADD, c->fd, &ee) == -1) {
Igor Sysoev10318a22004-01-29 21:45:01 +0000319 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000320 "epoll_ctl(EPOLL_CTL_ADD, %d) failed", c->fd);
Igor Sysoev10318a22004-01-29 21:45:01 +0000321 return NGX_ERROR;
322 }
323
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000324 c->read->active = 1;
325 c->write->active = 1;
326
Igor Sysoev10318a22004-01-29 21:45:01 +0000327 return NGX_OK;
328}
329
330
331static int ngx_epoll_del_connection(ngx_connection_t *c)
332{
333 c->read->active = 0;
334 c->write->active = 0;
335
336 return NGX_OK;
337}
Igor Sysoev7b6062a2004-02-12 20:57:10 +0000338#endif
Igor Sysoev10318a22004-01-29 21:45:01 +0000339
340
Igor Sysoevc972a3f2004-04-02 15:13:20 +0000341int ngx_epoll_process_events(ngx_cycle_t *cycle)
Igor Sysoev10318a22004-01-29 21:45:01 +0000342{
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000343 int events;
Igor Sysoev407b0de2004-04-09 16:03:04 +0000344 size_t n;
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000345 ngx_int_t instance, i;
346 ngx_uint_t lock, expire;
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000347 ngx_err_t err;
Igor Sysoev407b0de2004-04-09 16:03:04 +0000348 ngx_log_t *log;
349 ngx_msec_t timer;
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000350 struct timeval tv;
351 ngx_connection_t *c;
352 ngx_epoch_msec_t delta;
Igor Sysoev10318a22004-01-29 21:45:01 +0000353
354 timer = ngx_event_find_timer();
355 ngx_old_elapsed_msec = ngx_elapsed_msec;
356
357 if (timer == 0) {
358 timer = (ngx_msec_t) -1;
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000359 expire = 0;
360
361 } else {
362 expire = 1;
363 }
364
365 if (ngx_accept_mutex) {
366 if (ngx_trylock_accept_mutex(cycle) == NGX_ERROR) {
367 return NGX_ERROR;
368 }
369
370 if (ngx_accept_mutex_held == 0 && timer > ngx_accept_mutex_delay) {
371 timer = ngx_accept_mutex_delay;
372 expire = 0;
373 }
Igor Sysoev10318a22004-01-29 21:45:01 +0000374 }
375
Igor Sysoevc972a3f2004-04-02 15:13:20 +0000376 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
377 "epoll timer: %d", timer);
Igor Sysoev10318a22004-01-29 21:45:01 +0000378
379 events = epoll_wait(ep, event_list, nevents, timer);
380
381 if (events == -1) {
382 err = ngx_errno;
383 } else {
384 err = 0;
385 }
386
387 ngx_gettimeofday(&tv);
388 ngx_time_update(tv.tv_sec);
389
390 delta = ngx_elapsed_msec;
391 ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
392
Igor Sysoev328af6e2004-02-01 08:10:52 +0000393 if (timer != (ngx_msec_t) -1) {
Igor Sysoev10318a22004-01-29 21:45:01 +0000394 delta = ngx_elapsed_msec - delta;
395
Igor Sysoevc972a3f2004-04-02 15:13:20 +0000396 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
Igor Sysoev10318a22004-01-29 21:45:01 +0000397 "epoll timer: %d, delta: %d", timer, (int) delta);
398 } else {
399 if (events == 0) {
Igor Sysoevc972a3f2004-04-02 15:13:20 +0000400 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
Igor Sysoev10318a22004-01-29 21:45:01 +0000401 "epoll_wait() returned no events without timeout");
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000402 ngx_accept_mutex_unlock();
Igor Sysoev10318a22004-01-29 21:45:01 +0000403 return NGX_ERROR;
404 }
405 }
406
407 if (err) {
408 ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
Igor Sysoevc972a3f2004-04-02 15:13:20 +0000409 cycle->log, err, "epoll_wait() failed");
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000410 ngx_accept_mutex_unlock();
Igor Sysoev10318a22004-01-29 21:45:01 +0000411 return NGX_ERROR;
412 }
413
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000414 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
415 ngx_accept_mutex_unlock();
416 return NGX_ERROR;
417 }
418
419 lock = 1;
Igor Sysoev407b0de2004-04-09 16:03:04 +0000420 log = cycle->log;
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000421
Igor Sysoev10318a22004-01-29 21:45:01 +0000422 for (i = 0; i < events; i++) {
423 c = event_list[i].data.ptr;
424
425 instance = (uintptr_t) c & 1;
426 c = (ngx_connection_t *) ((uintptr_t) c & (uintptr_t) ~1);
427
Igor Sysoevc972a3f2004-04-02 15:13:20 +0000428 if (event_list[i].events & EPOLLIN) {
429 c->read->returned_instance = instance;
430 }
431
432 if (event_list[i].events & EPOLLOUT) {
433 c->write->returned_instance = instance;
434 }
435
Igor Sysoev407b0de2004-04-09 16:03:04 +0000436#if (NGX_DEBUG)
437 log = c->log ? c->log : cycle->log;
438#endif
439
440 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
Igor Sysoev10318a22004-01-29 21:45:01 +0000441 "epoll: fd:%d ev:%04X d:" PTR_FMT,
442 c->fd, event_list[i].events, event_list[i].data);
443
444 if (c->read->instance != instance) {
445
446 /*
Igor Sysoev328af6e2004-02-01 08:10:52 +0000447 * the stale event from a file descriptor
Igor Sysoev10318a22004-01-29 21:45:01 +0000448 * that was just closed in this iteration
449 */
450
Igor Sysoev407b0de2004-04-09 16:03:04 +0000451 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0,
Igor Sysoev10318a22004-01-29 21:45:01 +0000452 "epoll: stale event " PTR_FMT, c);
453 continue;
454 }
455
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000456 if (event_list[i].events & (EPOLLERR|EPOLLHUP)) {
Igor Sysoev407b0de2004-04-09 16:03:04 +0000457 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
Igor Sysoev7af6b162004-02-09 07:46:43 +0000458 "epoll_wait() error on fd:%d ev:%04X",
459 c->fd, event_list[i].events);
Igor Sysoev10318a22004-01-29 21:45:01 +0000460 }
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000461
Igor Sysoev328af6e2004-02-01 08:10:52 +0000462 if (event_list[i].events & ~(EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP)) {
Igor Sysoev407b0de2004-04-09 16:03:04 +0000463 ngx_log_error(NGX_LOG_ALERT, log, 0,
Igor Sysoev328af6e2004-02-01 08:10:52 +0000464 "strange epoll_wait() events fd:%d ev:%04X",
Igor Sysoevbbcea6c2004-01-30 17:39:00 +0000465 c->fd, event_list[i].events);
466 }
467
Igor Sysoev328af6e2004-02-01 08:10:52 +0000468 if ((event_list[i].events & (EPOLLOUT|EPOLLERR|EPOLLHUP))
469 && c->write->active)
470 {
471 c->write->ready = 1;
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000472
473 if (!ngx_threaded && !ngx_accept_mutex_held) {
474 c->write->event_handler(c->write);
475
476 } else {
477 ngx_post_event(c->write);
478 }
479 }
480
481 /*
482 * EPOLLIN must be handled after EPOLLOUT because we use
483 * the optimization to avoid the unnecessary mutex locking/unlocking
484 * if the accept event is the last one.
485 */
486
487 if ((event_list[i].events & (EPOLLIN|EPOLLERR|EPOLLHUP))
488 && c->read->active)
489 {
490 c->read->ready = 1;
491
492 if (!ngx_threaded && !ngx_accept_mutex_held) {
493 c->read->event_handler(c->read);
494
495 } else if (!c->read->accept) {
496 ngx_post_event(c->read);
497
498 } else {
499 ngx_mutex_unlock(ngx_posted_events_mutex);
500
501 c->read->event_handler(c->read);
502
503 if (i + 1 == events) {
504 lock = 0;
505 break;
506 }
507
508 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
509 ngx_accept_mutex_unlock();
510 return NGX_ERROR;
511 }
512 }
Igor Sysoev328af6e2004-02-01 08:10:52 +0000513 }
Igor Sysoev10318a22004-01-29 21:45:01 +0000514 }
515
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000516 if (lock) {
517 ngx_mutex_unlock(ngx_posted_events_mutex);
518 }
519
520 ngx_accept_mutex_unlock();
521
522 if (expire && delta) {
Igor Sysoev10318a22004-01-29 21:45:01 +0000523 ngx_event_expire_timers((ngx_msec_t) delta);
524 }
525
Igor Sysoev9a864bd2004-04-04 20:32:09 +0000526 if (!ngx_threaded) {
527 ngx_event_process_posted(cycle);
528 }
529
Igor Sysoev10318a22004-01-29 21:45:01 +0000530 return NGX_OK;
531}
532
533
534static void *ngx_epoll_create_conf(ngx_cycle_t *cycle)
535{
536 ngx_epoll_conf_t *epcf;
537
538 ngx_test_null(epcf, ngx_palloc(cycle->pool, sizeof(ngx_epoll_conf_t)),
539 NGX_CONF_ERROR);
540
541 epcf->events = NGX_CONF_UNSET;
542
543 return epcf;
544}
545
546
547static char *ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf)
548{
549 ngx_epoll_conf_t *epcf = conf;
550
551 ngx_conf_init_unsigned_value(epcf->events, 512);
552
553 return NGX_CONF_OK;
554}