Mercurial > hg > nginx
annotate src/event/modules/ngx_epoll_module.c @ 3760:38f74d11e5bd
discard "secure_link_expires on|off"
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 06 Sep 2010 14:19:18 +0000 |
parents | ab353d7dc182 |
children | 159b58f9c0bd |
rev | line source |
---|---|
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
4 */ |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
5 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
469 | 12 #if (NGX_TEST_BUILD_EPOLL) |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 /* epoll declarations */ |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
16 #define EPOLLIN 0x001 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
17 #define EPOLLPRI 0x002 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
18 #define EPOLLOUT 0x004 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
19 #define EPOLLRDNORM 0x040 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
20 #define EPOLLRDBAND 0x080 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
21 #define EPOLLWRNORM 0x100 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
22 #define EPOLLWRBAND 0x200 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
23 #define EPOLLMSG 0x400 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
24 #define EPOLLERR 0x008 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
25 #define EPOLLHUP 0x010 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
26 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
27 #define EPOLLET 0x80000000 |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
28 #define EPOLLONESHOT 0x40000000 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 #define EPOLL_CTL_ADD 1 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 #define EPOLL_CTL_DEL 2 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 #define EPOLL_CTL_MOD 3 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 typedef union epoll_data { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 void *ptr; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 int fd; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 uint32_t u32; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 uint64_t u64; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
39 } epoll_data_t; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
40 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 struct epoll_event { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 uint32_t events; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 epoll_data_t data; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 }; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
45 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 int epoll_create(int size) |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
48 return -1; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
50 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
51 int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
52 { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
53 return -1; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
55 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 int epoll_wait(int epfd, struct epoll_event *events, int nevents, int timeout) |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
57 { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 return -1; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
59 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
61 #if (NGX_HAVE_FILE_AIO) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
62 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
63 #define SYS_io_setup 245 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
64 #define SYS_io_destroy 246 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
65 #define SYS_io_getevents 247 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
66 #define SYS_eventfd 323 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
67 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
68 typedef u_int aio_context_t; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
69 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
70 struct io_event { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
71 uint64_t data; /* the data field from the iocb */ |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
72 uint64_t obj; /* what iocb this event came from */ |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
73 int64_t res; /* result code for this event */ |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
74 int64_t res2; /* secondary result */ |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
75 }; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
76 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
77 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
78 int eventfd(u_int initval) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
79 { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
80 return -1; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
81 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
82 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
83 #endif |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
84 #endif |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
85 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
87 typedef struct { |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
88 ngx_uint_t events; |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
89 } ngx_epoll_conf_t; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
90 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
91 |
563 | 92 static ngx_int_t ngx_epoll_init(ngx_cycle_t *cycle, ngx_msec_t timer); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
93 static void ngx_epoll_done(ngx_cycle_t *cycle); |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
94 static ngx_int_t ngx_epoll_add_event(ngx_event_t *ev, ngx_int_t event, |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
95 ngx_uint_t flags); |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
96 static ngx_int_t ngx_epoll_del_event(ngx_event_t *ev, ngx_int_t event, |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
97 ngx_uint_t flags); |
499 | 98 static ngx_int_t ngx_epoll_add_connection(ngx_connection_t *c); |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
99 static ngx_int_t ngx_epoll_del_connection(ngx_connection_t *c, |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
100 ngx_uint_t flags); |
563 | 101 static ngx_int_t ngx_epoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, |
102 ngx_uint_t flags); | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
104 #if (NGX_HAVE_FILE_AIO) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
105 static void ngx_epoll_eventfd_handler(ngx_event_t *ev); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
106 #endif |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
107 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 static void *ngx_epoll_create_conf(ngx_cycle_t *cycle); |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
109 static char *ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf); |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
110 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
111 static int ep = -1; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
112 static struct epoll_event *event_list; |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
113 static ngx_uint_t nevents; |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
114 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
115 #if (NGX_HAVE_FILE_AIO) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
116 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
117 int ngx_eventfd = -1; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
118 aio_context_t ngx_aio_ctx = 0; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
119 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
120 static ngx_event_t ngx_eventfd_event; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
121 static ngx_connection_t ngx_eventfd_conn; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
122 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
123 #endif |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
124 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 static ngx_str_t epoll_name = ngx_string("epoll"); |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 static ngx_command_t ngx_epoll_commands[] = { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
128 |
499 | 129 { ngx_string("epoll_events"), |
130 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
131 ngx_conf_set_num_slot, | |
132 0, | |
133 offsetof(ngx_epoll_conf_t, events), | |
134 NULL }, | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
135 |
499 | 136 ngx_null_command |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
137 }; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
138 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
139 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
140 ngx_event_module_t ngx_epoll_module_ctx = { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
141 &epoll_name, |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 ngx_epoll_create_conf, /* create configuration */ |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 ngx_epoll_init_conf, /* init configuration */ |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
144 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
145 { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
146 ngx_epoll_add_event, /* add an event */ |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
147 ngx_epoll_del_event, /* delete an event */ |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
148 ngx_epoll_add_event, /* enable an event */ |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
149 ngx_epoll_del_event, /* disable an event */ |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
150 ngx_epoll_add_connection, /* add an connection */ |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
151 ngx_epoll_del_connection, /* delete an connection */ |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
152 NULL, /* process the changes */ |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
153 ngx_epoll_process_events, /* process the events */ |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 ngx_epoll_init, /* init the events */ |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
155 ngx_epoll_done, /* done the events */ |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 }; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
159 ngx_module_t ngx_epoll_module = { |
509 | 160 NGX_MODULE_V1, |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
161 &ngx_epoll_module_ctx, /* module context */ |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 ngx_epoll_commands, /* module directives */ |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
163 NGX_EVENT_MODULE, /* module type */ |
541 | 164 NULL, /* init master */ |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
165 NULL, /* init module */ |
541 | 166 NULL, /* init process */ |
167 NULL, /* init thread */ | |
168 NULL, /* exit thread */ | |
169 NULL, /* exit process */ | |
170 NULL, /* exit master */ | |
171 NGX_MODULE_V1_PADDING | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 }; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
173 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
174 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
175 #if (NGX_HAVE_FILE_AIO) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
176 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
177 /* |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
178 * We call io_setup(), io_destroy() io_submit(), and io_getevents() directly |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
179 * as syscalls instead of libaio usage, because the library header file |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
180 * supports eventfd() since 0.3.107 version only. |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
181 * |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
182 * Also we do not use eventfd() in glibc, because glibc supports it |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
183 * since 2.8 version and glibc maps two syscalls eventfd() and eventfd2() |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
184 * into single eventfd() function with different number of parameters. |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
185 */ |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
186 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
187 static long |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
188 io_setup(u_int nr_reqs, aio_context_t *ctx) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
189 { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
190 return syscall(SYS_io_setup, nr_reqs, ctx); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
191 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
192 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
193 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
194 static int |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
195 io_destroy(aio_context_t ctx) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
196 { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
197 return syscall(SYS_io_destroy, ctx); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
198 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
199 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
200 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
201 static long |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
202 io_getevents(aio_context_t ctx, long min_nr, long nr, struct io_event *events, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
203 struct timespec *tmo) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
204 { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
205 return syscall(SYS_io_getevents, ctx, min_nr, nr, events, tmo); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
206 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
207 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
208 #endif |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
209 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
210 |
499 | 211 static ngx_int_t |
563 | 212 ngx_epoll_init(ngx_cycle_t *cycle, ngx_msec_t timer) |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
213 { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
214 ngx_epoll_conf_t *epcf; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
215 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 epcf = ngx_event_get_conf(cycle->conf_ctx, ngx_epoll_module); |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
218 if (ep == -1) { |
2062
90312b616162
prepare to allow various number of connections in child processes
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
219 ep = epoll_create(cycle->connection_n / 2); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
220 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 if (ep == -1) { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
222 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
223 "epoll_create() failed"); |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
224 return NGX_ERROR; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
225 } |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
226 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
227 #if (NGX_HAVE_FILE_AIO) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
228 { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
229 int n; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
230 struct epoll_event ee; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
231 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
232 ngx_eventfd = syscall(SYS_eventfd, 0); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
233 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
234 if (ngx_eventfd == -1) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
235 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
236 "eventfd() failed"); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
237 return NGX_ERROR; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
238 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
239 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
240 n = 1; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
241 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
242 if (ioctl(ngx_eventfd, FIONBIO, &n) == -1) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
243 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
244 "ioctl(eventfd, FIONBIO) failed"); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
245 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
246 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
247 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
248 "eventfd: %d", ngx_eventfd); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
249 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
250 n = io_setup(1024, &ngx_aio_ctx); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
251 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
252 if (n != 0) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
253 ngx_log_error(NGX_LOG_EMERG, cycle->log, -n, "io_setup() failed"); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
254 return NGX_ERROR; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
255 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
256 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
257 ngx_eventfd_event.data = &ngx_eventfd_conn; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
258 ngx_eventfd_event.handler = ngx_epoll_eventfd_handler; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
259 ngx_eventfd_event.log = cycle->log; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
260 ngx_eventfd_event.active = 1; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
261 ngx_eventfd_conn.fd = ngx_eventfd; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
262 ngx_eventfd_conn.read = &ngx_eventfd_event; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
263 ngx_eventfd_conn.log = cycle->log; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
264 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
265 ee.events = EPOLLIN|EPOLLET; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
266 ee.data.ptr = &ngx_eventfd_conn; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
267 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
268 if (epoll_ctl(ep, EPOLL_CTL_ADD, ngx_eventfd, &ee) == -1) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
269 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
270 "epoll_ctl(EPOLL_CTL_ADD, eventfd) failed"); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
271 return NGX_ERROR; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
272 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
273 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
274 #endif |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
275 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
276 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
277 if (nevents < epcf->events) { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
278 if (event_list) { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
279 ngx_free(event_list); |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
280 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
281 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
282 event_list = ngx_alloc(sizeof(struct epoll_event) * epcf->events, |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
283 cycle->log); |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
284 if (event_list == NULL) { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
285 return NGX_ERROR; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
286 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
287 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
288 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
289 nevents = epcf->events; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
290 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
291 ngx_io = ngx_os_io; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
292 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
293 ngx_event_actions = ngx_epoll_module_ctx.actions; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
294 |
469 | 295 #if (NGX_HAVE_CLEAR_EVENT) |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
296 ngx_event_flags = NGX_USE_CLEAR_EVENT |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
297 #else |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
298 ngx_event_flags = NGX_USE_LEVEL_EVENT |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
299 #endif |
455 | 300 |NGX_USE_GREEDY_EVENT |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
301 |NGX_USE_EPOLL_EVENT; |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
302 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
303 return NGX_OK; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
304 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
305 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
306 |
499 | 307 static void |
308 ngx_epoll_done(ngx_cycle_t *cycle) | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
309 { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
310 if (close(ep) == -1) { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
311 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
312 "epoll close() failed"); |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
313 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
314 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
315 ep = -1; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
316 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
317 #if (NGX_HAVE_FILE_AIO) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
318 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
319 if (io_destroy(ngx_aio_ctx) != 0) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
320 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
321 "io_destroy() failed"); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
322 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
323 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
324 ngx_aio_ctx = 0; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
325 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
326 #endif |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
327 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
328 ngx_free(event_list); |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
329 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
330 event_list = NULL; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
331 nevents = 0; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
332 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
333 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
334 |
499 | 335 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
336 ngx_epoll_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags) |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
337 { |
483 | 338 int op; |
339 uint32_t events, prev; | |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
340 ngx_event_t *e; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
341 ngx_connection_t *c; |
258
733dffa1fe97
nginx-0.0.2-2004-02-11-10:19:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
342 struct epoll_event ee; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
343 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
344 c = ev->data; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
345 |
483 | 346 events = (uint32_t) event; |
347 | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
348 if (event == NGX_READ_EVENT) { |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
349 e = c->write; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
350 prev = EPOLLOUT; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
351 #if (NGX_READ_EVENT != EPOLLIN) |
483 | 352 events = EPOLLIN; |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
256
diff
changeset
|
353 #endif |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
256
diff
changeset
|
354 |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
355 } else { |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
356 e = c->read; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
357 prev = EPOLLIN; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
358 #if (NGX_WRITE_EVENT != EPOLLOUT) |
483 | 359 events = EPOLLOUT; |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
360 #endif |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
361 } |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
362 |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
363 if (e->active) { |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
364 op = EPOLL_CTL_MOD; |
483 | 365 events |= prev; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
366 |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
367 } else { |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
368 op = EPOLL_CTL_ADD; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
369 } |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
370 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
371 ee.events = events | (uint32_t) flags; |
581 | 372 ee.data.ptr = (void *) ((uintptr_t) c | ev->instance); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
373 |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
374 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
461 | 375 "epoll add event: fd:%d op:%d ev:%08XD", |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
376 c->fd, op, ee.events); |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
377 |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
378 if (epoll_ctl(ep, op, c->fd, &ee) == -1) { |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
379 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
380 "epoll_ctl(%d, %d) failed", op, c->fd); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
381 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
382 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
383 |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
384 ev->active = 1; |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
385 #if 0 |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
386 ev->oneshot = (flags & NGX_ONESHOT_EVENT) ? 1 : 0; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
387 #endif |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
388 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
389 return NGX_OK; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
390 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
391 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
392 |
499 | 393 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
394 ngx_epoll_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags) |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
395 { |
483 | 396 int op; |
397 uint32_t prev; | |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
398 ngx_event_t *e; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
399 ngx_connection_t *c; |
258
733dffa1fe97
nginx-0.0.2-2004-02-11-10:19:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
400 struct epoll_event ee; |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
401 |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
402 /* |
483 | 403 * when the file descriptor is closed, the epoll automatically deletes |
404 * it from its queue, so we do not need to delete explicity the event | |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
405 * before the closing the file descriptor |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
406 */ |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
407 |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
408 if (flags & NGX_CLOSE_EVENT) { |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
409 ev->active = 0; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
410 return NGX_OK; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
411 } |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
412 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
413 c = ev->data; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
414 |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
415 if (event == NGX_READ_EVENT) { |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
416 e = c->write; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
417 prev = EPOLLOUT; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
418 |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
419 } else { |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
420 e = c->read; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
421 prev = EPOLLIN; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
422 } |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
423 |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
424 if (e->active) { |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
425 op = EPOLL_CTL_MOD; |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
426 ee.events = prev | (uint32_t) flags; |
581 | 427 ee.data.ptr = (void *) ((uintptr_t) c | ev->instance); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
428 |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
429 } else { |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
430 op = EPOLL_CTL_DEL; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
431 ee.events = 0; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
432 ee.data.ptr = NULL; |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
433 } |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
434 |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
435 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
461 | 436 "epoll del event: fd:%d op:%d ev:%08XD", |
259
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
437 c->fd, op, ee.events); |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
438 |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
439 if (epoll_ctl(ep, op, c->fd, &ee) == -1) { |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
440 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, |
d30f2c39caae
nginx-0.0.2-2004-02-12-23:57:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
258
diff
changeset
|
441 "epoll_ctl(%d, %d) failed", op, c->fd); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
442 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
443 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
444 |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
445 ev->active = 0; |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
446 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
447 return NGX_OK; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
448 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
449 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
450 |
499 | 451 static ngx_int_t |
452 ngx_epoll_add_connection(ngx_connection_t *c) | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
453 { |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
454 struct epoll_event ee; |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
455 |
253
b6793bc5034b
nginx-0.0.2-2004-02-09-10:46:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
456 ee.events = EPOLLIN|EPOLLOUT|EPOLLET; |
581 | 457 ee.data.ptr = (void *) ((uintptr_t) c | c->read->instance); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
458 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
459 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
461 | 460 "epoll add connection: fd:%d ev:%08XD", c->fd, ee.events); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
461 |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
462 if (epoll_ctl(ep, EPOLL_CTL_ADD, c->fd, &ee) == -1) { |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
463 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
464 "epoll_ctl(EPOLL_CTL_ADD, %d) failed", c->fd); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
465 return NGX_ERROR; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
466 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
467 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
468 c->read->active = 1; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
469 c->write->active = 1; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
470 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
471 return NGX_OK; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
472 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
473 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
474 |
499 | 475 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
476 ngx_epoll_del_connection(ngx_connection_t *c, ngx_uint_t flags) |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
477 { |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
478 int op; |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
479 struct epoll_event ee; |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
480 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
481 /* |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
482 * when the file descriptor is closed the epoll automatically deletes |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
483 * it from its queue so we do not need to delete explicity the event |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
484 * before the closing the file descriptor |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
485 */ |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
486 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
487 if (flags & NGX_CLOSE_EVENT) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
488 c->read->active = 0; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
489 c->write->active = 0; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
490 return NGX_OK; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
491 } |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
492 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
493 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
494 "epoll del connection: fd:%d", c->fd); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
495 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
496 op = EPOLL_CTL_DEL; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
497 ee.events = 0; |
581 | 498 ee.data.ptr = NULL; |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
499 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
500 if (epoll_ctl(ep, op, c->fd, &ee) == -1) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
501 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
502 "epoll_ctl(%d, %d) failed", op, c->fd); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
503 return NGX_ERROR; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
504 } |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
505 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
506 c->read->active = 0; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
507 c->write->active = 0; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
508 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
509 return NGX_OK; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
510 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
511 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
512 |
499 | 513 static ngx_int_t |
563 | 514 ngx_epoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags) |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
515 { |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
516 int events; |
483 | 517 uint32_t revents; |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
518 ngx_int_t instance, i; |
563 | 519 ngx_uint_t level; |
309
2e899477243a
nginx-0.0.3-2004-04-09-20:03:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
520 ngx_err_t err; |
2e899477243a
nginx-0.0.3-2004-04-09-20:03:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
521 ngx_log_t *log; |
563 | 522 ngx_event_t *rev, *wev, **queue; |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
523 ngx_connection_t *c; |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
524 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
525 /* NGX_TIMER_INFINITE == INFTIM */ |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
526 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
259
diff
changeset
|
527 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
557 | 528 "epoll timer: %M", timer); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
529 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
663
diff
changeset
|
530 events = epoll_wait(ep, event_list, (int) nevents, timer); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
531 |
3043 | 532 err = (events == -1) ? ngx_errno : 0; |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
533 |
3473
0299cf5856fc
do not update time in the timer signal handler,
Igor Sysoev <igor@sysoev.ru>
parents:
3052
diff
changeset
|
534 if (flags & NGX_UPDATE_TIME || ngx_event_timer_alarm) { |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
535 ngx_time_update(); |
563 | 536 } |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
537 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
538 if (err) { |
563 | 539 if (err == NGX_EINTR) { |
540 | |
541 if (ngx_event_timer_alarm) { | |
542 ngx_event_timer_alarm = 0; | |
543 return NGX_OK; | |
544 } | |
577 | 545 |
563 | 546 level = NGX_LOG_INFO; |
577 | 547 |
548 } else { | |
563 | 549 level = NGX_LOG_ALERT; |
550 } | |
551 | |
552 ngx_log_error(level, cycle->log, err, "epoll_wait() failed"); | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
553 return NGX_ERROR; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
554 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
555 |
563 | 556 if (events == 0) { |
567 | 557 if (timer != NGX_TIMER_INFINITE) { |
558 return NGX_OK; | |
559 } | |
560 | |
561 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, | |
562 "epoll_wait() returned no events without timeout"); | |
563 return NGX_ERROR; | |
563 | 564 } |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
565 |
563 | 566 ngx_mutex_lock(ngx_posted_events_mutex); |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
567 |
309
2e899477243a
nginx-0.0.3-2004-04-09-20:03:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
568 log = cycle->log; |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
569 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
570 for (i = 0; i < events; i++) { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
571 c = event_list[i].data.ptr; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
572 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
573 instance = (uintptr_t) c & 1; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
574 c = (ngx_connection_t *) ((uintptr_t) c & (uintptr_t) ~1); |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
575 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
576 rev = c->read; |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
259
diff
changeset
|
577 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
578 if (c->fd == -1 || rev->instance != instance) { |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
579 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
580 /* |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
581 * the stale event from a file descriptor |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
582 * that was just closed in this iteration |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
583 */ |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
584 |
312
f5431a4bbc7d
nginx-0.0.3-2004-04-13-09:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
585 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
461 | 586 "epoll: stale event %p", c); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
587 continue; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
588 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
589 |
328
fb4dfb2ac0fc
nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
590 #if (NGX_DEBUG0) |
312
f5431a4bbc7d
nginx-0.0.3-2004-04-13-09:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
591 log = c->log ? c->log : cycle->log; |
f5431a4bbc7d
nginx-0.0.3-2004-04-13-09:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
592 #endif |
f5431a4bbc7d
nginx-0.0.3-2004-04-13-09:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
593 |
483 | 594 revents = event_list[i].events; |
595 | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
596 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0, |
461 | 597 "epoll: fd:%d ev:%04XD d:%p", |
577 | 598 c->fd, revents, event_list[i].data.ptr); |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
599 |
483 | 600 if (revents & (EPOLLERR|EPOLLHUP)) { |
309
2e899477243a
nginx-0.0.3-2004-04-09-20:03:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
601 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0, |
461 | 602 "epoll_wait() error on fd:%d ev:%04XD", |
483 | 603 c->fd, revents); |
604 } | |
605 | |
663 | 606 #if 0 |
483 | 607 if (revents & ~(EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP)) { |
608 ngx_log_error(NGX_LOG_ALERT, log, 0, | |
609 "strange epoll_wait() events fd:%d ev:%04XD", | |
610 c->fd, revents); | |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
611 } |
663 | 612 #endif |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
613 |
483 | 614 if ((revents & (EPOLLERR|EPOLLHUP)) |
615 && (revents & (EPOLLIN|EPOLLOUT)) == 0) | |
616 { | |
617 /* | |
618 * if the error events were returned without EPOLLIN or EPOLLOUT, | |
619 * then add these flags to handle the events at least in one | |
620 * active handler | |
621 */ | |
622 | |
623 revents |= EPOLLIN|EPOLLOUT; | |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
624 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
625 |
563 | 626 if ((revents & EPOLLIN) && rev->active) { |
627 | |
628 if ((flags & NGX_POST_THREAD_EVENTS) && !rev->accept) { | |
629 rev->posted_ready = 1; | |
630 | |
631 } else { | |
632 rev->ready = 1; | |
633 } | |
634 | |
635 if (flags & NGX_POST_EVENTS) { | |
636 queue = (ngx_event_t **) (rev->accept ? | |
637 &ngx_posted_accept_events : &ngx_posted_events); | |
638 | |
639 ngx_locked_post_event(rev, queue); | |
640 | |
641 } else { | |
642 rev->handler(rev); | |
643 } | |
644 } | |
645 | |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
646 wev = c->write; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
647 |
483 | 648 if ((revents & EPOLLOUT) && wev->active) { |
649 | |
563 | 650 if (flags & NGX_POST_THREAD_EVENTS) { |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
651 wev->posted_ready = 1; |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
652 |
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
653 } else { |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
654 wev->ready = 1; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
655 } |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
656 |
563 | 657 if (flags & NGX_POST_EVENTS) { |
658 ngx_locked_post_event(wev, &ngx_posted_events); | |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
659 |
563 | 660 } else { |
661 wev->handler(wev); | |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
662 } |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
663 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
664 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
665 |
563 | 666 ngx_mutex_unlock(ngx_posted_events_mutex); |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
667 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
668 return NGX_OK; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
669 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
670 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
671 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
672 #if (NGX_HAVE_FILE_AIO) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
673 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
674 static void |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
675 ngx_epoll_eventfd_handler(ngx_event_t *ev) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
676 { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
677 int n; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
678 long i, events; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
679 uint64_t ready; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
680 ngx_err_t err; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
681 ngx_event_t *e; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
682 ngx_event_aio_t *aio; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
683 struct io_event event[64]; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
684 struct timespec ts; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
685 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
686 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "eventfd handler"); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
687 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
688 n = read(ngx_eventfd, &ready, 8); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
689 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
690 err = ngx_errno; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
691 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
692 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0, "eventfd: %d", n); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
693 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
694 if (n != 8) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
695 if (n == -1) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
696 if (err == NGX_EAGAIN) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
697 return; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
698 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
699 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
700 ngx_log_error(NGX_LOG_ALERT, ev->log, err, "read(eventfd) failed"); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
701 return; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
702 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
703 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
704 ngx_log_error(NGX_LOG_ALERT, ev->log, 0, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
705 "read(eventfd) returned only %d bytes", n); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
706 return; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
707 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
708 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
709 ts.tv_sec = 0; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
710 ts.tv_nsec = 0; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
711 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
712 while (ready) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
713 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
714 events = io_getevents(ngx_aio_ctx, 1, 64, event, &ts); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
715 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
716 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
717 "io_getevents: %l", events); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
718 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
719 if (events > 0) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
720 ready -= events; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
721 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
722 for (i = 0; i < events; i++) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
723 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
724 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
725 "io_event: %uXL %uXL %L %L", |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
726 event[i].data, event[i].obj, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
727 event[i].res, event[i].res2); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
728 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
729 e = (ngx_event_t *) (uintptr_t) event[i].data; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
730 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
731 e->complete = 1; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
732 e->active = 0; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
733 e->ready = 1; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
734 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
735 aio = e->data; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
736 aio->res = event[i].res; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
737 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
738 ngx_post_event(e, &ngx_posted_events); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
739 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
740 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
741 continue; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
742 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
743 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
744 if (events == 0) { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
745 return; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
746 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
747 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
748 /* events < 0 */ |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
749 ngx_log_error(NGX_LOG_ALERT, ev->log, -events, "io_getevents() failed"); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
750 return; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
751 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
752 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
753 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
754 #endif |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
755 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3044
diff
changeset
|
756 |
499 | 757 static void * |
758 ngx_epoll_create_conf(ngx_cycle_t *cycle) | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
759 { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
760 ngx_epoll_conf_t *epcf; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
761 |
501 | 762 epcf = ngx_palloc(cycle->pool, sizeof(ngx_epoll_conf_t)); |
763 if (epcf == NULL) { | |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2062
diff
changeset
|
764 return NULL; |
501 | 765 } |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
766 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
767 epcf->events = NGX_CONF_UNSET; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
768 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
769 return epcf; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
770 } |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
771 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
772 |
499 | 773 static char * |
774 ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf) | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
775 { |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
776 ngx_epoll_conf_t *epcf = conf; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
777 |
663 | 778 ngx_conf_init_uint_value(epcf->events, 512); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
779 |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
780 return NGX_CONF_OK; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
781 } |