Mercurial > hg > nginx-quic
annotate src/event/modules/ngx_rtsig_module.c @ 4785:f8767b8032ba stable-1.2
Merge of r4713: map hostnames fix (ticket #182).
The final dot wasn't stripped before looking up in a map of hostnames.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 06 Aug 2012 14:04:06 +0000 |
parents | d620f497c50f |
children | 4c36e15651f7 |
rev | line source |
---|---|
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
1 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
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 |
4412 | 4 * Copyright (C) Nginx, Inc. |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
5 */ |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
6 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
7 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
8 #include <ngx_config.h> |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
9 #include <ngx_core.h> |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
10 #include <ngx_event.h> |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
11 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
12 |
469 | 13 #if (NGX_TEST_BUILD_RTSIG) |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
14 |
1939
6e7daf852eec
restore building --test-build-rtsig and --test-build-eventport on FreeBSD 6
Igor Sysoev <igor@sysoev.ru>
parents:
1870
diff
changeset
|
15 #ifdef SIGRTMIN |
6e7daf852eec
restore building --test-build-rtsig and --test-build-eventport on FreeBSD 6
Igor Sysoev <igor@sysoev.ru>
parents:
1870
diff
changeset
|
16 #define si_fd _reason.__spare__.__spare2__[0] |
6e7daf852eec
restore building --test-build-rtsig and --test-build-eventport on FreeBSD 6
Igor Sysoev <igor@sysoev.ru>
parents:
1870
diff
changeset
|
17 #else |
6e7daf852eec
restore building --test-build-rtsig and --test-build-eventport on FreeBSD 6
Igor Sysoev <igor@sysoev.ru>
parents:
1870
diff
changeset
|
18 #define SIGRTMIN 33 |
6e7daf852eec
restore building --test-build-rtsig and --test-build-eventport on FreeBSD 6
Igor Sysoev <igor@sysoev.ru>
parents:
1870
diff
changeset
|
19 #define si_fd __spare__[0] |
6e7daf852eec
restore building --test-build-rtsig and --test-build-eventport on FreeBSD 6
Igor Sysoev <igor@sysoev.ru>
parents:
1870
diff
changeset
|
20 #endif |
6e7daf852eec
restore building --test-build-rtsig and --test-build-eventport on FreeBSD 6
Igor Sysoev <igor@sysoev.ru>
parents:
1870
diff
changeset
|
21 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
22 #define F_SETSIG 10 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
23 #define KERN_RTSIGNR 30 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
24 #define KERN_RTSIGMAX 31 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
25 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
26 int sigtimedwait(const sigset_t *set, siginfo_t *info, |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
27 const struct timespec *timeout) |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
28 { |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
29 return -1; |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
30 } |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
31 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
32 int ngx_linux_rtsig_max; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
33 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
34 #endif |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
35 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
36 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
37 typedef struct { |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
38 ngx_uint_t signo; |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
39 ngx_uint_t overflow_events; |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
40 ngx_uint_t overflow_test; |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
41 ngx_uint_t overflow_threshold; |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
42 } ngx_rtsig_conf_t; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
43 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
44 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
45 extern ngx_event_module_t ngx_poll_module_ctx; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
46 |
563 | 47 static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle, ngx_msec_t timer); |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
48 static void ngx_rtsig_done(ngx_cycle_t *cycle); |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
49 static ngx_int_t ngx_rtsig_add_connection(ngx_connection_t *c); |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
50 static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c, |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
51 ngx_uint_t flags); |
563 | 52 static ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle, |
53 ngx_msec_t timer, ngx_uint_t flags); | |
54 static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle, | |
55 ngx_msec_t timer, ngx_uint_t flags); | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
56 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
57 static void *ngx_rtsig_create_conf(ngx_cycle_t *cycle); |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
58 static char *ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf); |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
59 static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, |
499 | 60 void *post, void *data); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
61 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
62 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
63 static sigset_t set; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
64 static ngx_uint_t overflow, overflow_current; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
65 static struct pollfd *overflow_list; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
66 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
67 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
68 static ngx_str_t rtsig_name = ngx_string("rtsig"); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
69 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
70 static ngx_conf_num_bounds_t ngx_overflow_threshold_bounds = { |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
71 ngx_check_ngx_overflow_threshold_bounds, 2, 10 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
72 }; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
73 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
74 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
75 static ngx_command_t ngx_rtsig_commands[] = { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
76 |
499 | 77 { ngx_string("rtsig_signo"), |
78 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
79 ngx_conf_set_num_slot, | |
80 0, | |
81 offsetof(ngx_rtsig_conf_t, signo), | |
82 NULL }, | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
83 |
499 | 84 { ngx_string("rtsig_overflow_events"), |
85 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
86 ngx_conf_set_num_slot, | |
87 0, | |
88 offsetof(ngx_rtsig_conf_t, overflow_events), | |
89 NULL }, | |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
90 |
499 | 91 { ngx_string("rtsig_overflow_test"), |
92 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
93 ngx_conf_set_num_slot, | |
94 0, | |
95 offsetof(ngx_rtsig_conf_t, overflow_test), | |
96 NULL }, | |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
97 |
499 | 98 { ngx_string("rtsig_overflow_threshold"), |
99 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
100 ngx_conf_set_num_slot, | |
101 0, | |
102 offsetof(ngx_rtsig_conf_t, overflow_threshold), | |
103 &ngx_overflow_threshold_bounds }, | |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
104 |
499 | 105 ngx_null_command |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
106 }; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
107 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
109 ngx_event_module_t ngx_rtsig_module_ctx = { |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
110 &rtsig_name, |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
111 ngx_rtsig_create_conf, /* create configuration */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
112 ngx_rtsig_init_conf, /* init configuration */ |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
113 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
114 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
115 NULL, /* add an event */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
116 NULL, /* delete an event */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
117 NULL, /* enable an event */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
118 NULL, /* disable an event */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
119 ngx_rtsig_add_connection, /* add an connection */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
120 ngx_rtsig_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
|
121 NULL, /* process the changes */ |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
122 ngx_rtsig_process_events, /* process the events */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
123 ngx_rtsig_init, /* init the events */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
124 ngx_rtsig_done, /* done the events */ |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
125 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
126 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
127 }; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
128 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
129 ngx_module_t ngx_rtsig_module = { |
509 | 130 NGX_MODULE_V1, |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
131 &ngx_rtsig_module_ctx, /* module context */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
132 ngx_rtsig_commands, /* module directives */ |
499 | 133 NGX_EVENT_MODULE, /* module type */ |
541 | 134 NULL, /* init master */ |
499 | 135 NULL, /* init module */ |
541 | 136 NULL, /* init process */ |
137 NULL, /* init thread */ | |
138 NULL, /* exit thread */ | |
139 NULL, /* exit process */ | |
140 NULL, /* exit master */ | |
141 NGX_MODULE_V1_PADDING | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
142 }; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
143 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
144 |
499 | 145 static ngx_int_t |
563 | 146 ngx_rtsig_init(ngx_cycle_t *cycle, ngx_msec_t timer) |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
147 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
148 ngx_rtsig_conf_t *rtscf; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
149 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
150 rtscf = ngx_event_get_conf(cycle->conf_ctx, ngx_rtsig_module); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
151 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
152 sigemptyset(&set); |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
153 sigaddset(&set, (int) rtscf->signo); |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
154 sigaddset(&set, (int) rtscf->signo + 1); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
155 sigaddset(&set, SIGIO); |
563 | 156 sigaddset(&set, SIGALRM); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
157 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
158 if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) { |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
159 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
160 "sigprocmask() failed"); |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
161 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
162 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
163 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
164 if (overflow_list) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
165 ngx_free(overflow_list); |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
166 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
167 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
168 overflow_list = ngx_alloc(sizeof(struct pollfd) * rtscf->overflow_events, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
169 cycle->log); |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
170 if (overflow_list == NULL) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
171 return NGX_ERROR; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
172 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
173 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
174 ngx_io = ngx_os_io; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
175 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
176 ngx_event_actions = ngx_rtsig_module_ctx.actions; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
177 |
543 | 178 ngx_event_flags = NGX_USE_RTSIG_EVENT |
179 |NGX_USE_GREEDY_EVENT | |
180 |NGX_USE_FD_EVENT; | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
181 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
182 return NGX_OK; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
183 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
184 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
185 |
499 | 186 static void |
187 ngx_rtsig_done(ngx_cycle_t *cycle) | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
188 { |
452 | 189 ngx_free(overflow_list); |
190 | |
191 overflow_list = NULL; | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
192 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
193 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 |
499 | 195 static ngx_int_t |
196 ngx_rtsig_add_connection(ngx_connection_t *c) | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
197 { |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
198 ngx_uint_t signo; |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
199 ngx_rtsig_conf_t *rtscf; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
200 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
201 if (c->read->accept && c->read->disabled) { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
202 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
203 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
204 "rtsig enable connection: fd:%d", c->fd); |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
205 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
206 if (fcntl(c->fd, F_SETOWN, ngx_pid) == -1) { |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
207 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
208 "fcntl(F_SETOWN) failed"); |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
209 return NGX_ERROR; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
210 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
211 |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
212 c->read->active = 1; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
213 c->read->disabled = 0; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
214 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
215 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
216 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
217 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
218 signo = rtscf->signo + c->read->instance; |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
219 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
220 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
221 "rtsig add connection: fd:%d signo:%ui", c->fd, signo); |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
222 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
223 if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC) == -1) { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
224 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
225 "fcntl(O_RDWR|O_NONBLOCK|O_ASYNC) failed"); |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
226 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
228 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
229 if (fcntl(c->fd, F_SETSIG, (int) signo) == -1) { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
230 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 "fcntl(F_SETSIG) failed"); |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
232 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
233 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
234 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
235 if (fcntl(c->fd, F_SETOWN, ngx_pid) == -1) { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
236 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
237 "fcntl(F_SETOWN) failed"); |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
238 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
239 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
240 |
469 | 241 #if (NGX_HAVE_ONESIGFD) |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
242 if (fcntl(c->fd, F_SETAUXFL, O_ONESIGFD) == -1) { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
243 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
244 "fcntl(F_SETAUXFL) failed"); |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
245 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
246 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
247 #endif |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
248 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
249 c->read->active = 1; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
250 c->write->active = 1; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
251 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
252 return NGX_OK; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
253 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
254 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
255 |
499 | 256 static ngx_int_t |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
257 ngx_rtsig_del_connection(ngx_connection_t *c, ngx_uint_t flags) |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
258 { |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
259 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
260 "rtsig del connection: fd:%d", c->fd); |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
261 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
262 if ((flags & NGX_DISABLE_EVENT) && c->read->accept) { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
263 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
264 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
265 "rtsig disable connection: fd:%d", c->fd); |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
266 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
267 c->read->active = 0; |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
268 c->read->disabled = 1; |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
269 return NGX_OK; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
270 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
271 |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
272 if (flags & NGX_CLOSE_EVENT) { |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
273 c->read->active = 0; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
274 c->write->active = 0; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
275 return NGX_OK; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
276 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
277 |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
278 if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK) == -1) { |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
279 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
280 "fcntl(O_RDWR|O_NONBLOCK) failed"); |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
281 return NGX_ERROR; |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
282 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
283 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
284 c->read->active = 0; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
285 c->write->active = 0; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
286 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
287 return NGX_OK; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
288 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
289 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
290 |
499 | 291 static ngx_int_t |
563 | 292 ngx_rtsig_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags) |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
293 { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
294 int signo; |
501 | 295 ngx_int_t instance; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
296 ngx_err_t err; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
297 siginfo_t si; |
573 | 298 ngx_event_t *rev, *wev, **queue; |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
299 struct timespec ts, *tp; |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
300 struct sigaction sa; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
301 ngx_connection_t *c; |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
302 ngx_rtsig_conf_t *rtscf; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
303 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
304 if (timer == NGX_TIMER_INFINITE) { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
305 tp = NULL; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
306 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
307 } else { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
308 ts.tv_sec = timer / 1000; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
309 ts.tv_nsec = (timer % 1000) * 1000000; |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
310 tp = &ts; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
311 } |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
312 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
313 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
557 | 314 "rtsig timer: %M", timer); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
315 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
316 /* Linux's sigwaitinfo() is sigtimedwait() with the NULL timeout pointer */ |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
317 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
318 signo = sigtimedwait(&set, &si, tp); |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
319 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
320 if (signo == -1) { |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
321 err = ngx_errno; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
322 |
382
449c4885dcd1
nginx-0.0.7-2004-07-07-23:48:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
323 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, err, |
449c4885dcd1
nginx-0.0.7-2004-07-07-23:48:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
324 "rtsig signo:%d", signo); |
449c4885dcd1
nginx-0.0.7-2004-07-07-23:48:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
325 |
567 | 326 if (flags & NGX_UPDATE_TIME) { |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
327 ngx_time_update(); |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
328 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
329 |
567 | 330 if (err == NGX_EAGAIN) { |
331 | |
332 /* timeout */ | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
333 |
567 | 334 if (timer != NGX_TIMER_INFINITE) { |
335 return NGX_AGAIN; | |
336 } | |
577 | 337 |
567 | 338 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, |
339 "sigtimedwait() returned EAGAIN without timeout"); | |
340 return NGX_ERROR; | |
341 } | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
342 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
343 ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT, |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
344 cycle->log, err, "sigtimedwait() failed"); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
345 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
346 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
347 |
567 | 348 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
349 "rtsig signo:%d fd:%d band:%04Xd", | |
350 signo, si.si_fd, si.si_band); | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
351 |
567 | 352 if (flags & NGX_UPDATE_TIME) { |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
353 ngx_time_update(); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
354 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
355 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
356 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
357 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
358 if (signo == (int) rtscf->signo || signo == (int) rtscf->signo + 1) { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
359 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
360 if (overflow && (ngx_uint_t) si.si_fd > overflow_current) { |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
361 return NGX_OK; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
362 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
363 |
551 | 364 c = ngx_cycle->files[si.si_fd]; |
365 | |
366 if (c == NULL) { | |
563 | 367 |
551 | 368 /* the stale event */ |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
369 |
551 | 370 return NGX_OK; |
371 } | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
372 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
373 instance = signo - (int) rtscf->signo; |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
374 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
375 rev = c->read; |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
376 |
563 | 377 if (rev->instance != instance) { |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
378 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
379 /* |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
380 * the stale event from a file descriptor |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
381 * that was just closed in this iteration |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
382 */ |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
383 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
384 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
461 | 385 "rtsig: stale event %p", c); |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
386 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
387 return NGX_OK; |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
388 } |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
389 |
563 | 390 if ((si.si_band & (POLLIN|POLLHUP|POLLERR)) && rev->active) { |
573 | 391 |
563 | 392 rev->ready = 1; |
573 | 393 |
394 if (flags & NGX_POST_EVENTS) { | |
395 queue = (ngx_event_t **) (rev->accept ? | |
396 &ngx_posted_accept_events : &ngx_posted_events); | |
397 | |
398 ngx_locked_post_event(rev, queue); | |
399 | |
577 | 400 } else { |
573 | 401 rev->handler(rev); |
402 } | |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
403 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
404 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
405 wev = c->write; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
406 |
563 | 407 if ((si.si_band & (POLLOUT|POLLHUP|POLLERR)) && wev->active) { |
573 | 408 |
563 | 409 wev->ready = 1; |
573 | 410 |
411 if (flags & NGX_POST_EVENTS) { | |
412 ngx_locked_post_event(wev, &ngx_posted_events); | |
413 | |
414 } else { | |
415 wev->handler(wev); | |
416 } | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
417 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
418 |
567 | 419 return NGX_OK; |
420 | |
563 | 421 } else if (signo == SIGALRM) { |
422 | |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
423 ngx_time_update(); |
567 | 424 |
563 | 425 return NGX_OK; |
426 | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
427 } else if (signo == SIGIO) { |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
428 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
429 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
430 "rt signal queue overflowed"); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
431 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
432 /* flush the RT signal queue */ |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
433 |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
434 ngx_memzero(&sa, sizeof(struct sigaction)); |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
435 sa.sa_handler = SIG_DFL; |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
436 sigemptyset(&sa.sa_mask); |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
437 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
438 if (sigaction(rtscf->signo, &sa, NULL) == -1) { |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
439 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
440 "sigaction(%d, SIG_DFL) failed", rtscf->signo); |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
441 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
442 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
443 if (sigaction(rtscf->signo + 1, &sa, NULL) == -1) { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
444 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
445 "sigaction(%d, SIG_DFL) failed", rtscf->signo + 1); |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
446 } |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
447 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
448 overflow = 1; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
449 overflow_current = 0; |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
450 ngx_event_actions.process_events = ngx_rtsig_process_overflow; |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
451 |
352
694d7ddc3599
nginx-0.0.4-2004-06-11-10:15:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
351
diff
changeset
|
452 return NGX_ERROR; |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
453 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
454 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
455 |
567 | 456 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
457 "sigtimedwait() returned unexpected signal: %d", signo); | |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
458 |
567 | 459 return NGX_ERROR; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
460 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
461 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
462 |
499 | 463 static ngx_int_t |
563 | 464 ngx_rtsig_process_overflow(ngx_cycle_t *cycle, ngx_msec_t timer, |
465 ngx_uint_t flags) | |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
466 { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
467 int name[2], rtsig_max, rtsig_nr, events, ready; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
468 size_t len; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
469 ngx_err_t err; |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
470 ngx_uint_t tested, n, i; |
563 | 471 ngx_event_t *rev, *wev, **queue; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
472 ngx_connection_t *c; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
473 ngx_rtsig_conf_t *rtscf; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
474 |
563 | 475 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
476 "rtsig process overflow"); | |
477 | |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
478 rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module); |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
479 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
480 tested = 0; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
481 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
482 for ( ;; ) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
483 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
484 n = 0; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
485 while (n < rtscf->overflow_events) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
486 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
487 if (overflow_current == cycle->connection_n) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
488 break; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
489 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
490 |
543 | 491 c = cycle->files[overflow_current++]; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
492 |
559 | 493 if (c == NULL || c->fd == -1) { |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
494 continue; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
495 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
496 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
497 events = 0; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
498 |
509 | 499 if (c->read->active && c->read->handler) { |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
500 events |= POLLIN; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
501 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
502 |
509 | 503 if (c->write->active && c->write->handler) { |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
504 events |= POLLOUT; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
505 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
506 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
507 if (events == 0) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
508 continue; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
509 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
510 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
511 overflow_list[n].fd = c->fd; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
512 overflow_list[n].events = events; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
513 overflow_list[n].revents = 0; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
514 n++; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
515 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
516 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
517 if (n == 0) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
518 break; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
519 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
520 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
521 for ( ;; ) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
522 ready = poll(overflow_list, n, 0); |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
523 |
563 | 524 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
525 "rtsig overflow poll:%d", ready); | |
526 | |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
527 if (ready == -1) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
528 err = ngx_errno; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
529 ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
530 cycle->log, 0, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
531 "poll() failed while the overflow recover"); |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
532 |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
533 if (err == NGX_EINTR) { |
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
534 continue; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
535 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
536 } |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
537 |
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
538 break; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
539 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
540 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
541 if (ready <= 0) { |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
542 continue; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
543 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
544 |
563 | 545 ngx_mutex_lock(ngx_posted_events_mutex); |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
546 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
547 for (i = 0; i < n; i++) { |
543 | 548 c = cycle->files[overflow_list[i].fd]; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
549 |
559 | 550 if (c == NULL) { |
551 continue; | |
552 } | |
553 | |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
554 rev = c->read; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
555 |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
556 if (rev->active |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
557 && !rev->closed |
509 | 558 && rev->handler |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
559 && (overflow_list[i].revents |
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
560 & (POLLIN|POLLERR|POLLHUP|POLLNVAL))) |
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
561 { |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
562 tested++; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
563 |
563 | 564 if ((flags & NGX_POST_THREAD_EVENTS) && !rev->accept) { |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
565 rev->posted_ready = 1; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
566 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
567 } else { |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
568 rev->ready = 1; |
563 | 569 } |
570 | |
571 if (flags & NGX_POST_EVENTS) { | |
572 queue = (ngx_event_t **) (rev->accept ? | |
573 &ngx_posted_accept_events : &ngx_posted_events); | |
574 | |
575 ngx_locked_post_event(rev, queue); | |
576 | |
577 } else { | |
578 rev->handler(rev); | |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
579 } |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
580 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
581 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
582 wev = c->write; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
583 |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
584 if (wev->active |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
585 && !wev->closed |
509 | 586 && wev->handler |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
587 && (overflow_list[i].revents |
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
588 & (POLLOUT|POLLERR|POLLHUP|POLLNVAL))) |
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
589 { |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
590 tested++; |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
591 |
563 | 592 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
|
593 wev->posted_ready = 1; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
594 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
595 } else { |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
596 wev->ready = 1; |
563 | 597 } |
598 | |
599 if (flags & NGX_POST_EVENTS) { | |
600 ngx_locked_post_event(wev, &ngx_posted_events); | |
601 | |
602 } else { | |
603 wev->handler(wev); | |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
604 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
605 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
606 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
607 |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
608 ngx_mutex_unlock(ngx_posted_events_mutex); |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
609 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
610 if (tested >= rtscf->overflow_test) { |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
611 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
612 if (ngx_linux_rtsig_max) { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
613 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
614 /* |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
615 * Check the current rt queue length to prevent |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
616 * the new overflow. |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
617 * |
563 | 618 * learn the "/proc/sys/kernel/rtsig-max" value because |
619 * it can be changed since the last checking | |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
620 */ |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
621 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
622 name[0] = CTL_KERN; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
623 name[1] = KERN_RTSIGMAX; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
624 len = sizeof(rtsig_max); |
493 | 625 |
626 if (sysctl(name, 2, &rtsig_max, &len, NULL, 0) == -1) { | |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
627 ngx_log_error(NGX_LOG_ALERT, cycle->log, errno, |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
628 "sysctl(KERN_RTSIGMAX) failed"); |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
629 return NGX_ERROR; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
630 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
631 |
493 | 632 /* name[0] = CTL_KERN; */ |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
633 name[1] = KERN_RTSIGNR; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
634 len = sizeof(rtsig_nr); |
493 | 635 |
636 if (sysctl(name, 2, &rtsig_nr, &len, NULL, 0) == -1) { | |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
637 ngx_log_error(NGX_LOG_ALERT, cycle->log, errno, |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
638 "sysctl(KERN_RTSIGNR) failed"); |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
639 return NGX_ERROR; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
640 } |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
641 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
642 /* |
563 | 643 * drain the rt signal queue if the /"proc/sys/kernel/rtsig-nr" |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
644 * is bigger than |
563 | 645 * "/proc/sys/kernel/rtsig-max" / "rtsig_overflow_threshold" |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
646 */ |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
647 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
648 if (rtsig_max / (int) rtscf->overflow_threshold < rtsig_nr) { |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
649 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
650 "rtsig queue state: %d/%d", |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
651 rtsig_nr, rtsig_max); |
563 | 652 while (ngx_rtsig_process_events(cycle, 0, flags) == NGX_OK) |
653 { | |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
654 /* void */ |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
655 } |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
656 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
657 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
658 } else { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
659 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
660 /* |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
661 * Linux has not KERN_RTSIGMAX since 2.6.6-mm2 |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
662 * so drain the rt signal queue unconditionally |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
663 */ |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
664 |
563 | 665 while (ngx_rtsig_process_events(cycle, 0, flags) == NGX_OK) { |
666 /* void */ | |
667 } | |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
668 } |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
669 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
670 tested = 0; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
671 } |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
672 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
673 |
563 | 674 if (flags & NGX_UPDATE_TIME) { |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
675 ngx_time_update(); |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
676 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
677 |
527 | 678 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
679 "rt signal queue overflow recovered"); |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
680 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
681 overflow = 0; |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
682 ngx_event_actions.process_events = ngx_rtsig_process_events; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
683 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
684 return NGX_OK; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
685 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
686 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
687 |
499 | 688 static void * |
689 ngx_rtsig_create_conf(ngx_cycle_t *cycle) | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
690 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
691 ngx_rtsig_conf_t *rtscf; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
692 |
501 | 693 rtscf = ngx_palloc(cycle->pool, sizeof(ngx_rtsig_conf_t)); |
694 if (rtscf == NULL) { | |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
1939
diff
changeset
|
695 return NULL; |
501 | 696 } |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
697 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
698 rtscf->signo = NGX_CONF_UNSET; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
699 rtscf->overflow_events = NGX_CONF_UNSET; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
700 rtscf->overflow_test = NGX_CONF_UNSET; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
701 rtscf->overflow_threshold = NGX_CONF_UNSET; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
702 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
703 return rtscf; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
704 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
705 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
706 |
499 | 707 static char * |
708 ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf) | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
709 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
710 ngx_rtsig_conf_t *rtscf = conf; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
711 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
712 /* LinuxThreads use the first 3 RT signals */ |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
713 ngx_conf_init_uint_value(rtscf->signo, SIGRTMIN + 10); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
714 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
715 ngx_conf_init_uint_value(rtscf->overflow_events, 16); |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
716 ngx_conf_init_uint_value(rtscf->overflow_test, 32); |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
717 ngx_conf_init_uint_value(rtscf->overflow_threshold, 10); |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
718 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
719 return NGX_CONF_OK; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
720 } |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
721 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
722 |
499 | 723 static char * |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
724 ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, void *post, void *data) |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
725 { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
726 if (ngx_linux_rtsig_max) { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
727 return ngx_conf_check_num_bounds(cf, post, data); |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
728 } |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
729 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
730 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
731 "\"rtsig_overflow_threshold\" is not supported " |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
732 "since Linux 2.6.6-mm2, ignored"); |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
733 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
734 return NGX_CONF_OK; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
735 } |