Mercurial > hg > nginx
annotate src/event/modules/ngx_devpoll_module.c @ 4282:71cdac0b9ea6
Fix of "Content-Length" header of MP4 response if start argument was used.
Patch by Piotr Sikora.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 14 Nov 2011 14:42:48 +0000 |
parents | ab353d7dc182 |
children | d620f497c50f |
rev | line source |
---|---|
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
1 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 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 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
4 */ |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
5 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
10 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
11 |
469 | 12 #if (NGX_TEST_BUILD_DEVPOLL) |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
13 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
14 /* Solaris declarations */ |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 |
1433 | 16 #define POLLREMOVE 0x0800 |
17 #define DP_POLL 0xD001 | |
18 #define DP_ISPOLLED 0xD002 | |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
19 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
20 struct dvpoll { |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
21 struct pollfd *dp_fds; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
22 int dp_nfds; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
23 int dp_timeout; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
24 }; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
25 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
26 #endif |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
28 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
29 typedef struct { |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
30 ngx_uint_t changes; |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
31 ngx_uint_t events; |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
32 } ngx_devpoll_conf_t; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
33 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
34 |
563 | 35 static ngx_int_t ngx_devpoll_init(ngx_cycle_t *cycle, ngx_msec_t timer); |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
36 static void ngx_devpoll_done(ngx_cycle_t *cycle); |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
37 static ngx_int_t ngx_devpoll_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:
1141
diff
changeset
|
38 ngx_uint_t flags); |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
39 static ngx_int_t ngx_devpoll_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:
1141
diff
changeset
|
40 ngx_uint_t flags); |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
41 static ngx_int_t ngx_devpoll_set_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:
1141
diff
changeset
|
42 ngx_uint_t flags); |
563 | 43 static ngx_int_t ngx_devpoll_process_events(ngx_cycle_t *cycle, |
44 ngx_msec_t timer, ngx_uint_t flags); | |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
45 |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
46 static void *ngx_devpoll_create_conf(ngx_cycle_t *cycle); |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
47 static char *ngx_devpoll_init_conf(ngx_cycle_t *cycle, void *conf); |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
48 |
167
8aef3c72e5da
nginx-0.0.1-2003-10-30-19:51:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
49 static int dp = -1; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
50 static struct pollfd *change_list, *event_list; |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
51 static ngx_uint_t nchanges, max_changes, nevents; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
52 |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
53 static ngx_event_t **change_index; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
55 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
56 static ngx_str_t devpoll_name = ngx_string("/dev/poll"); |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
57 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
58 static ngx_command_t ngx_devpoll_commands[] = { |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
59 |
499 | 60 { ngx_string("devpoll_changes"), |
61 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
62 ngx_conf_set_num_slot, | |
63 0, | |
64 offsetof(ngx_devpoll_conf_t, changes), | |
65 NULL }, | |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
66 |
499 | 67 { ngx_string("devpoll_events"), |
68 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
69 ngx_conf_set_num_slot, | |
70 0, | |
71 offsetof(ngx_devpoll_conf_t, events), | |
72 NULL }, | |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
73 |
499 | 74 ngx_null_command |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
75 }; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
76 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
77 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
78 ngx_event_module_t ngx_devpoll_module_ctx = { |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
79 &devpoll_name, |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
80 ngx_devpoll_create_conf, /* create configuration */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
81 ngx_devpoll_init_conf, /* init configuration */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
82 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
83 { |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
84 ngx_devpoll_add_event, /* add an event */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
85 ngx_devpoll_del_event, /* delete an event */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
86 ngx_devpoll_add_event, /* enable an event */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
87 ngx_devpoll_del_event, /* disable an event */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
88 NULL, /* add an connection */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
89 NULL, /* 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
|
90 NULL, /* process the changes */ |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
91 ngx_devpoll_process_events, /* process the events */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
92 ngx_devpoll_init, /* init the events */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
93 ngx_devpoll_done, /* done the events */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
94 } |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
95 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
96 }; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
98 ngx_module_t ngx_devpoll_module = { |
509 | 99 NGX_MODULE_V1, |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
100 &ngx_devpoll_module_ctx, /* module context */ |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
101 ngx_devpoll_commands, /* module directives */ |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
102 NGX_EVENT_MODULE, /* module type */ |
541 | 103 NULL, /* init master */ |
116
571bcbff82c5
nginx-0.0.1-2003-07-11-08:50:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
104 NULL, /* init module */ |
541 | 105 NULL, /* init process */ |
106 NULL, /* init thread */ | |
107 NULL, /* exit thread */ | |
108 NULL, /* exit process */ | |
109 NULL, /* exit master */ | |
110 NGX_MODULE_V1_PADDING | |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
111 }; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
112 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
113 |
499 | 114 static ngx_int_t |
563 | 115 ngx_devpoll_init(ngx_cycle_t *cycle, ngx_msec_t timer) |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
116 { |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
179
diff
changeset
|
117 size_t n; |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
118 ngx_devpoll_conf_t *dpcf; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
119 |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
120 dpcf = ngx_event_get_conf(cycle->conf_ctx, ngx_devpoll_module); |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
121 |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
122 if (dp == -1) { |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
123 dp = open("/dev/poll", O_RDWR); |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
124 |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
125 if (dp == -1) { |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
126 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
127 "open(/dev/poll) failed"); |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
128 return NGX_ERROR; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
129 } |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
130 } |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
131 |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
132 if (max_changes < dpcf->changes) { |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
133 if (nchanges) { |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
134 n = nchanges * sizeof(struct pollfd); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
135 if (write(dp, change_list, n) != (ssize_t) n) { |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
136 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
137 "write(/dev/poll) failed"); |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
138 return NGX_ERROR; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
139 } |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
140 |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
141 nchanges = 0; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
142 } |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
143 |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
144 if (change_list) { |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
145 ngx_free(change_list); |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
146 } |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
147 |
501 | 148 change_list = ngx_alloc(sizeof(struct pollfd) * dpcf->changes, |
149 cycle->log); | |
150 if (change_list == NULL) { | |
151 return NGX_ERROR; | |
152 } | |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
153 |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
154 if (change_index) { |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
155 ngx_free(change_index); |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
156 } |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
157 |
501 | 158 change_index = ngx_alloc(sizeof(ngx_event_t *) * dpcf->changes, |
159 cycle->log); | |
160 if (change_index == NULL) { | |
161 return NGX_ERROR; | |
162 } | |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
163 } |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
164 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
165 max_changes = dpcf->changes; |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
166 |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
167 if (nevents < dpcf->events) { |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
168 if (event_list) { |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
169 ngx_free(event_list); |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
170 } |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 |
501 | 172 event_list = ngx_alloc(sizeof(struct pollfd) * dpcf->events, |
173 cycle->log); | |
174 if (event_list == NULL) { | |
175 return NGX_ERROR; | |
176 } | |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
177 } |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
179 nevents = dpcf->events; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
180 |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
181 ngx_io = ngx_os_io; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
182 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
183 ngx_event_actions = ngx_devpoll_module_ctx.actions; |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
184 |
543 | 185 ngx_event_flags = NGX_USE_LEVEL_EVENT|NGX_USE_FD_EVENT; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
186 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 return NGX_OK; |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
188 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
189 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
190 |
499 | 191 static void |
192 ngx_devpoll_done(ngx_cycle_t *cycle) | |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
193 { |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
194 if (close(dp) == -1) { |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
195 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
196 "close(/dev/poll) failed"); |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
197 } |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
198 |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
199 dp = -1; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
200 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
201 ngx_free(change_list); |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
202 ngx_free(event_list); |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
203 ngx_free(change_index); |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
204 |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
205 change_list = NULL; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
206 event_list = NULL; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
207 change_index = NULL; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
208 max_changes = 0; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
209 nchanges = 0; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
210 nevents = 0; |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
211 } |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
212 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
213 |
499 | 214 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
215 ngx_devpoll_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags) |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 { |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
217 #if (NGX_DEBUG) |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
218 ngx_connection_t *c; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
219 #endif |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
220 |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
221 #if (NGX_READ_EVENT != POLLIN) |
452 | 222 event = (event == NGX_READ_EVENT) ? POLLIN : POLLOUT; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
223 #endif |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
224 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
225 #if (NGX_DEBUG) |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
226 c = ev->data; |
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
227 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
228 "devpoll add event: fd:%d ev:%04Xi", c->fd, event); |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
229 #endif |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
230 |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
231 ev->active = 1; |
452 | 232 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
233 return ngx_devpoll_set_event(ev, event, 0); |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
234 } |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
235 |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
236 |
499 | 237 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
238 ngx_devpoll_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags) |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
239 { |
109
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
240 ngx_event_t *e; |
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
241 ngx_connection_t *c; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
242 |
110
152567c11325
nginx-0.0.1-2003-07-02-22:51:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
109
diff
changeset
|
243 c = ev->data; |
152567c11325
nginx-0.0.1-2003-07-02-22:51:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
109
diff
changeset
|
244 |
452 | 245 #if (NGX_READ_EVENT != POLLIN) |
246 event = (event == NGX_READ_EVENT) ? POLLIN : POLLOUT; | |
247 #endif | |
248 | |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
249 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
250 "devpoll del event: fd:%d ev:%04Xi", c->fd, event); |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
251 |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
252 if (ngx_devpoll_set_event(ev, POLLREMOVE, flags) == NGX_ERROR) { |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
253 return NGX_ERROR; |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
254 } |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
255 |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
256 ev->active = 0; |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
257 |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
258 if (flags & NGX_CLOSE_EVENT) { |
1431
ec3833f74cc2
disable pair event on POLLREMOVE
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
259 e = (event == POLLIN) ? c->write : c->read; |
ec3833f74cc2
disable pair event on POLLREMOVE
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
260 |
ec3833f74cc2
disable pair event on POLLREMOVE
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
261 if (e) { |
ec3833f74cc2
disable pair event on POLLREMOVE
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
262 e->active = 0; |
ec3833f74cc2
disable pair event on POLLREMOVE
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
263 } |
ec3833f74cc2
disable pair event on POLLREMOVE
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
264 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
265 return NGX_OK; |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
266 } |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
267 |
1432 | 268 /* restore the pair event if it exists */ |
109
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
269 |
452 | 270 if (event == POLLIN) { |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
271 e = c->write; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
272 event = POLLOUT; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
273 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
274 } else { |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
275 e = c->read; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
276 event = POLLIN; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
277 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
278 |
452 | 279 if (e && e->active) { |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
280 return ngx_devpoll_set_event(e, event, 0); |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
281 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
282 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
283 return NGX_OK; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
284 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
285 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
286 |
499 | 287 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
288 ngx_devpoll_set_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags) |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
289 { |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
179
diff
changeset
|
290 size_t n; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
291 ngx_connection_t *c; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
292 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
293 c = ev->data; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
294 |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
295 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0, |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
296 "devpoll fd:%d ev:%04Xi fl:%04Xi", c->fd, event, flags); |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
297 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
298 if (nchanges >= max_changes) { |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
299 ngx_log_error(NGX_LOG_WARN, ev->log, 0, |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
300 "/dev/pool change list is filled up"); |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
301 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
302 n = nchanges * sizeof(struct pollfd); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
303 if (write(dp, change_list, n) != (ssize_t) n) { |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
304 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
305 "write(/dev/poll) failed"); |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
306 return NGX_ERROR; |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
307 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
308 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
309 nchanges = 0; |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
310 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
311 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
312 change_list[nchanges].fd = c->fd; |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
313 change_list[nchanges].events = (short) event; |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
314 change_list[nchanges].revents = 0; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
315 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
316 change_index[nchanges] = ev; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
317 ev->index = nchanges; |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
318 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
319 nchanges++; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
320 |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
321 if (flags & NGX_CLOSE_EVENT) { |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
322 n = nchanges * sizeof(struct pollfd); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
323 if (write(dp, change_list, n) != (ssize_t) n) { |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
324 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
325 "write(/dev/poll) failed"); |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
326 return NGX_ERROR; |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
327 } |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
328 |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
329 nchanges = 0; |
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
330 } |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
331 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
332 return NGX_OK; |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
333 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
334 |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
335 |
499 | 336 ngx_int_t |
563 | 337 ngx_devpoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, |
338 ngx_uint_t flags) | |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
339 { |
1433 | 340 int events, revents, rc; |
557 | 341 size_t n; |
1433 | 342 ngx_fd_t fd; |
557 | 343 ngx_err_t err; |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
344 ngx_int_t i; |
563 | 345 ngx_uint_t level; |
346 ngx_event_t *rev, *wev, **queue; | |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
347 ngx_connection_t *c; |
1433 | 348 struct pollfd pfd; |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
349 struct dvpoll dvp; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
350 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
351 /* NGX_TIMER_INFINITE == INFTIM */ |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
352 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
353 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
557 | 354 "devpoll timer: %M", timer); |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
355 |
47
d81326c3b21b
nginx-0.0.1-2003-01-15-10:02:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
40
diff
changeset
|
356 if (nchanges) { |
d81326c3b21b
nginx-0.0.1-2003-01-15-10:02:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
40
diff
changeset
|
357 n = nchanges * sizeof(struct pollfd); |
245
e6c005b66b3a
nginx-0.0.1-2004-01-30-00:45:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
358 if (write(dp, change_list, n) != (ssize_t) n) { |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
359 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
47
d81326c3b21b
nginx-0.0.1-2003-01-15-10:02:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
40
diff
changeset
|
360 "write(/dev/poll) failed"); |
d81326c3b21b
nginx-0.0.1-2003-01-15-10:02:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
40
diff
changeset
|
361 return NGX_ERROR; |
d81326c3b21b
nginx-0.0.1-2003-01-15-10:02:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
40
diff
changeset
|
362 } |
567 | 363 |
364 nchanges = 0; | |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
365 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
366 |
40
d5d4f3bba6f0
nginx-0.0.1-2002-12-26-10:24:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
39
diff
changeset
|
367 dvp.dp_fds = event_list; |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1141
diff
changeset
|
368 dvp.dp_nfds = (int) nevents; |
40
d5d4f3bba6f0
nginx-0.0.1-2002-12-26-10:24:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
39
diff
changeset
|
369 dvp.dp_timeout = timer; |
d5d4f3bba6f0
nginx-0.0.1-2002-12-26-10:24:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
39
diff
changeset
|
370 events = ioctl(dp, DP_POLL, &dvp); |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
371 |
3043 | 372 err = (events == -1) ? ngx_errno : 0; |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
373 |
3473
0299cf5856fc
do not update time in the timer signal handler,
Igor Sysoev <igor@sysoev.ru>
parents:
3043
diff
changeset
|
374 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
|
375 ngx_time_update(); |
563 | 376 } |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
167
diff
changeset
|
377 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
378 if (err) { |
563 | 379 if (err == NGX_EINTR) { |
380 | |
381 if (ngx_event_timer_alarm) { | |
382 ngx_event_timer_alarm = 0; | |
383 return NGX_OK; | |
384 } | |
577 | 385 |
563 | 386 level = NGX_LOG_INFO; |
577 | 387 |
388 } else { | |
563 | 389 level = NGX_LOG_ALERT; |
390 } | |
391 | |
392 ngx_log_error(level, cycle->log, err, "ioctl(DP_POLL) failed"); | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
393 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
394 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
395 |
567 | 396 if (events == 0) { |
397 if (timer != NGX_TIMER_INFINITE) { | |
398 return NGX_OK; | |
399 } | |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
110
diff
changeset
|
400 |
567 | 401 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
402 "ioctl(DP_POLL) returned no events without timeout"); | |
403 return NGX_ERROR; | |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
404 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
405 |
563 | 406 ngx_mutex_lock(ngx_posted_events_mutex); |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
407 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
408 for (i = 0; i < events; i++) { |
1433 | 409 |
410 fd = event_list[i].fd; | |
411 revents = event_list[i].revents; | |
412 | |
413 c = ngx_cycle->files[fd]; | |
414 | |
415 if (c == NULL || c->fd == -1) { | |
416 | |
417 pfd.fd = fd; | |
418 pfd.events = 0; | |
419 pfd.revents = 0; | |
420 | |
421 rc = ioctl(dp, DP_ISPOLLED, &pfd); | |
422 | |
423 switch (rc) { | |
424 | |
425 case -1: | |
426 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
427 "ioctl(DP_ISPOLLED) failed for socket %d, event", | |
428 fd, revents); | |
429 break; | |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
430 |
1433 | 431 case 0: |
432 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, | |
433 "phantom event %04Xd for closed and removed socket %d", | |
434 revents, fd); | |
435 break; | |
436 | |
437 default: | |
438 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, | |
439 "unexpected event %04Xd for closed and removed socket %d, ", | |
440 "ioctl(DP_ISPOLLED) returned rc:%d, fd:%d, event %04Xd", | |
441 revents, fd, rc, pfd.fd, pfd.revents); | |
442 | |
443 pfd.fd = fd; | |
444 pfd.events = POLLREMOVE; | |
445 pfd.revents = 0; | |
446 | |
447 if (write(dp, &pfd, sizeof(struct pollfd)) | |
448 != (ssize_t) sizeof(struct pollfd)) | |
449 { | |
450 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
451 "write(/dev/poll) for %d failed, fd"); | |
452 } | |
453 | |
454 if (close(fd) == -1) { | |
455 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
456 "close(%d) failed", fd); | |
457 } | |
458 | |
459 break; | |
473 | 460 } |
461 | |
462 continue; | |
463 } | |
464 | |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
465 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
461 | 466 "devpoll: fd:%d, ev:%04Xd, rev:%04Xd", |
1433 | 467 fd, event_list[i].events, revents); |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
468 |
483 | 469 if (revents & (POLLERR|POLLHUP|POLLNVAL)) { |
1141
2b16d3959c2b
fix building without --with-debug on Solaris
Igor Sysoev <igor@sysoev.ru>
parents:
1128
diff
changeset
|
470 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
461 | 471 "ioctl(DP_POLL) error fd:%d ev:%04Xd rev:%04Xd", |
1433 | 472 fd, event_list[i].events, revents); |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
473 } |
39
83fa61cd3d2f
nginx-0.0.1-2002-12-24-20:30:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
36
diff
changeset
|
474 |
483 | 475 if (revents & ~(POLLIN|POLLOUT|POLLERR|POLLHUP|POLLNVAL)) { |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
476 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
477 "strange ioctl(DP_POLL) events " |
461 | 478 "fd:%d ev:%04Xd rev:%04Xd", |
1433 | 479 fd, event_list[i].events, revents); |
483 | 480 } |
481 | |
482 if ((revents & (POLLERR|POLLHUP|POLLNVAL)) | |
483 && (revents & (POLLIN|POLLOUT)) == 0) | |
484 { | |
485 /* | |
486 * if the error events were returned without POLLIN or POLLOUT, | |
487 * then add these flags to handle the events at least in one | |
577 | 488 * active handler |
483 | 489 */ |
490 | |
491 revents |= POLLIN|POLLOUT; | |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
492 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
493 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
494 rev = c->read; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
495 |
483 | 496 if ((revents & POLLIN) && rev->active) { |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
497 |
563 | 498 if ((flags & NGX_POST_THREAD_EVENTS) && !rev->accept) { |
499 rev->posted_ready = 1; | |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
500 |
563 | 501 } else { |
502 rev->ready = 1; | |
503 } | |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
504 |
563 | 505 if (flags & NGX_POST_EVENTS) { |
506 queue = (ngx_event_t **) (rev->accept ? | |
507 &ngx_posted_accept_events : &ngx_posted_events); | |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
508 |
563 | 509 ngx_locked_post_event(rev, queue); |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
510 |
563 | 511 } else { |
512 rev->handler(rev); | |
513 } | |
514 } | |
515 | |
516 wev = c->write; | |
517 | |
518 if ((revents & POLLOUT) && wev->active) { | |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
519 |
563 | 520 if (flags & NGX_POST_THREAD_EVENTS) { |
521 wev->posted_ready = 1; | |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
522 |
563 | 523 } else { |
524 wev->ready = 1; | |
525 } | |
526 | |
527 if (flags & NGX_POST_EVENTS) { | |
528 ngx_locked_post_event(wev, &ngx_posted_events); | |
529 | |
530 } else { | |
531 wev->handler(wev); | |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
532 } |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
533 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
534 } |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
535 |
563 | 536 ngx_mutex_unlock(ngx_posted_events_mutex); |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
537 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
538 return NGX_OK; |
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
539 } |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
540 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
541 |
499 | 542 static void * |
543 ngx_devpoll_create_conf(ngx_cycle_t *cycle) | |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
544 { |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
545 ngx_devpoll_conf_t *dpcf; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
546 |
501 | 547 dpcf = ngx_palloc(cycle->pool, sizeof(ngx_devpoll_conf_t)); |
548 if (dpcf == NULL) { | |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
1433
diff
changeset
|
549 return NULL; |
501 | 550 } |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
551 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
552 dpcf->changes = NGX_CONF_UNSET; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
553 dpcf->events = NGX_CONF_UNSET; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
554 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
555 return dpcf; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
556 } |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
557 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
558 |
499 | 559 static char * |
560 ngx_devpoll_init_conf(ngx_cycle_t *cycle, void *conf) | |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
561 { |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
562 ngx_devpoll_conf_t *dpcf = conf; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
563 |
663 | 564 ngx_conf_init_uint_value(dpcf->changes, 32); |
565 ngx_conf_init_uint_value(dpcf->events, 32); | |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
566 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
567 return NGX_CONF_OK; |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
568 } |