Mercurial > hg > nginx
comparison src/event/modules/ngx_aio_module.c @ 93:738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 21 May 2003 13:28:21 +0000 |
parents | 637625a2acdb |
children | 8220378432a8 |
comparison
equal
deleted
inserted
replaced
92:19cc647ecd91 | 93:738fe44c70d5 |
---|---|
1 | 1 |
2 #include <ngx_config.h> | 2 #include <ngx_config.h> |
3 | |
4 #include <ngx_core.h> | 3 #include <ngx_core.h> |
5 #include <ngx_types.h> | |
6 #include <ngx_log.h> | |
7 #include <ngx_connection.h> | |
8 #include <ngx_event.h> | 4 #include <ngx_event.h> |
9 #include <ngx_event_timer.h> | 5 #include <ngx_aio.h> |
10 | 6 |
11 #if (HAVE_KQUEUE) | 7 #if (HAVE_KQUEUE) |
12 #include <ngx_kqueue_module.h> | 8 #include <ngx_kqueue_module.h> |
13 #endif | 9 #endif |
14 | 10 |
15 | 11 |
16 int ngx_aio_init(int max_connections, ngx_log_t *log) | 12 static int ngx_aio_init(ngx_log_t *log); |
17 { | 13 static void ngx_aio_done(ngx_log_t *log); |
14 static int ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags); | |
15 static int ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags); | |
16 static int ngx_aio_process_events(ngx_log_t *log); | |
17 | |
18 | |
19 ngx_os_io_t ngx_os_aio = { | |
20 ngx_aio_read, | |
21 NULL, | |
22 ngx_aio_write, | |
23 ngx_aio_write_chain, | |
24 NGX_HAVE_ZEROCOPY | |
25 }; | |
26 | |
27 | |
28 static ngx_str_t aio_name = ngx_string("aio"); | |
29 | |
30 ngx_event_module_t ngx_aio_module_ctx = { | |
31 NGX_EVENT_MODULE, | |
32 &aio_name, | |
33 NULL, /* create configuration */ | |
34 NULL, /* init configuration */ | |
35 | |
36 { | |
37 ngx_aio_add_event, /* add an event */ | |
38 ngx_aio_del_event, /* delete an event */ | |
39 NULL, /* enable an event */ | |
40 NULL, /* disable an event */ | |
41 NULL, /* add an connection */ | |
42 NULL, /* delete an connection */ | |
43 ngx_aio_process_events, /* process the events */ | |
44 ngx_aio_init, /* init the events */ | |
45 ngx_aio_done /* done the events */ | |
46 } | |
47 | |
48 }; | |
49 | |
50 ngx_module_t ngx_aio_module = { | |
51 &ngx_aio_module_ctx, /* module context */ | |
52 0, /* module index */ | |
53 NULL, /* module directives */ | |
54 NGX_EVENT_MODULE_TYPE, /* module type */ | |
55 NULL /* init module */ | |
56 }; | |
57 | |
58 | |
59 | |
18 #if (HAVE_KQUEUE) | 60 #if (HAVE_KQUEUE) |
19 | 61 |
20 int rc; | 62 static int ngx_aio_init(ngx_log_t *log) |
21 | 63 { |
22 rc = ngx_kqueue_init(max_connections, log); | 64 if (ngx_kqueue_module_ctx.actions.init(log) == NGX_ERROR) { |
65 return NGX_ERROR; | |
66 } | |
23 | 67 |
24 ngx_event_flags = NGX_HAVE_AIO_EVENT|NGX_USE_AIO_EVENT; | 68 ngx_event_flags = NGX_HAVE_AIO_EVENT|NGX_USE_AIO_EVENT; |
25 ngx_write_chain_proc = ngx_aio_write_chain; | 69 ngx_event_actions = ngx_aio_module_ctx.actions; |
70 ngx_io = ngx_os_aio; | |
26 | 71 |
27 return rc; | |
28 | 72 |
29 #endif | 73 return NGX_OK; |
30 } | 74 } |
31 | 75 |
32 | 76 |
77 static void ngx_aio_done(ngx_log_t *log) | |
78 { | |
79 ngx_kqueue_module_ctx.actions.done(log); | |
80 } | |
33 | 81 |
82 | |
83 /* The event adding and deleteing are needed for the listening sockets */ | |
84 | |
85 static int ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags) | |
86 { | |
87 return ngx_kqueue_module_ctx.actions.add(ev, event, flags); | |
88 } | |
89 | |
90 | |
91 static int ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags) | |
92 { | |
93 return ngx_kqueue_module_ctx.actions.del(ev, event, flags); | |
94 } | |
95 | |
96 | |
97 static int ngx_aio_process_events(ngx_log_t *log) | |
98 { | |
99 return ngx_kqueue_module_ctx.actions.process(log); | |
100 } | |
101 | |
102 #endif | |
34 | 103 |
35 | 104 |
36 #if 0 | 105 #if 0 |
106 | |
37 /* 1 */ | 107 /* 1 */ |
38 int ngx_posix_aio_process_events(ngx_log_t *log) | 108 int ngx_posix_aio_process_events(ngx_log_t *log) |
39 { | 109 { |
40 listen via SIGIO; | 110 listen via SIGIO; |
41 aio_* via SIGxxx; | 111 aio_* via SIGxxx; |
64 } | 134 } |
65 | 135 |
66 /* 3 */ | 136 /* 3 */ |
67 int ngx_posix_aio_process_events(ngx_log_t *log) | 137 int ngx_posix_aio_process_events(ngx_log_t *log) |
68 { | 138 { |
139 #if 0 | |
69 unmask signal | 140 unmask signal |
70 | 141 |
71 /* BUG: AIO signal can be delivered before select() */ | 142 /* BUG: AIO signal can be delivered before select() */ |
72 | 143 |
73 select(listen); | 144 select(listen); |
74 | 145 |
75 mask signal | 146 mask signal |
147 #endif | |
148 | |
149 pselect(listen, mask); | |
76 | 150 |
77 if (ngx_socket_errno == NGX_EINTR) | 151 if (ngx_socket_errno == NGX_EINTR) |
78 look ready array | 152 look ready array |
79 } | 153 } |
80 | 154 |
81 void aio_sig_handler(int signo, siginfo_t *siginfo, void *context) | 155 void aio_sig_handler(int signo, siginfo_t *siginfo, void *context) |
82 { | 156 { |
83 push siginfo->si_value.sival_ptr | 157 push siginfo->si_value.sival_ptr |
84 } | 158 } |
159 | |
85 #endif | 160 #endif |