Mercurial > hg > nginx
annotate src/event/modules/ngx_rtsig_module.c @ 1925:6fd26b0e1009
non cacheable $proxy_host and $proxy_port
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 11 Mar 2008 14:10:11 +0000 |
parents | a62fb6c156c5 |
children | 6e7daf852eec |
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 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
4 */ |
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 #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
|
8 #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
|
9 #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
|
10 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
11 |
469 | 12 #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
|
13 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
14 #define F_SETSIG 10 |
1870
a62fb6c156c5
fix building --test-build-rtsig and --test-build-eventport on FreeBSD 7
Igor Sysoev <igor@sysoev.ru>
parents:
1354
diff
changeset
|
15 #define si_fd _reason.__spare__.__spare2__[0] |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
16 #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
|
17 #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
|
18 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
19 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
|
20 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
|
21 { |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
22 return -1; |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
23 } |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
24 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
25 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
|
26 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
27 #endif |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
28 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
29 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
30 typedef struct { |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
31 ngx_uint_t signo; |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
32 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
|
33 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
|
34 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
|
35 } 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
|
36 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
37 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
38 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
|
39 |
563 | 40 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
|
41 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
|
42 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
|
43 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
|
44 ngx_uint_t flags); |
563 | 45 static ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle, |
46 ngx_msec_t timer, ngx_uint_t flags); | |
47 static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle, | |
48 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
|
49 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
50 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
|
51 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
|
52 static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, |
499 | 53 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
|
54 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
55 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
56 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
|
57 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
|
58 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
|
59 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
60 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
61 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
|
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 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
|
64 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
|
65 }; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
66 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
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_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
|
69 |
499 | 70 { ngx_string("rtsig_signo"), |
71 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
72 ngx_conf_set_num_slot, | |
73 0, | |
74 offsetof(ngx_rtsig_conf_t, signo), | |
75 NULL }, | |
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_overflow_events"), |
78 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
79 ngx_conf_set_num_slot, | |
80 0, | |
81 offsetof(ngx_rtsig_conf_t, overflow_events), | |
82 NULL }, | |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
83 |
499 | 84 { ngx_string("rtsig_overflow_test"), |
85 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
86 ngx_conf_set_num_slot, | |
87 0, | |
88 offsetof(ngx_rtsig_conf_t, overflow_test), | |
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_threshold"), |
92 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
93 ngx_conf_set_num_slot, | |
94 0, | |
95 offsetof(ngx_rtsig_conf_t, overflow_threshold), | |
96 &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
|
97 |
499 | 98 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
|
99 }; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
100 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
101 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
102 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
|
103 &rtsig_name, |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
104 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
|
105 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
|
106 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
107 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
119 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
120 }; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
121 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
122 ngx_module_t ngx_rtsig_module = { |
509 | 123 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
|
124 &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
|
125 ngx_rtsig_commands, /* module directives */ |
499 | 126 NGX_EVENT_MODULE, /* module type */ |
541 | 127 NULL, /* init master */ |
499 | 128 NULL, /* init module */ |
541 | 129 NULL, /* init process */ |
130 NULL, /* init thread */ | |
131 NULL, /* exit thread */ | |
132 NULL, /* exit process */ | |
133 NULL, /* exit master */ | |
134 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
|
135 }; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
136 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
137 |
499 | 138 static ngx_int_t |
563 | 139 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
|
140 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
141 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
|
142 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
143 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
|
144 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
145 sigemptyset(&set); |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
146 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
|
147 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
|
148 sigaddset(&set, SIGIO); |
563 | 149 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
|
150 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
151 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
|
152 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
|
153 "sigprocmask() failed"); |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
154 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
155 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
156 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
157 if (overflow_list) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
158 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
|
159 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
160 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
161 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
|
162 cycle->log); |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
163 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
|
164 return NGX_ERROR; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
165 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
166 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
167 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
|
168 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
169 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
|
170 |
543 | 171 ngx_event_flags = NGX_USE_RTSIG_EVENT |
172 |NGX_USE_GREEDY_EVENT | |
173 |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
|
174 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
175 return NGX_OK; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
176 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
177 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
178 |
499 | 179 static void |
180 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
|
181 { |
452 | 182 ngx_free(overflow_list); |
183 | |
184 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
|
185 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
186 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 |
499 | 188 static ngx_int_t |
189 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
|
190 { |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
191 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
|
192 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
|
193 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
194 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
|
195 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
196 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
|
197 "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
|
198 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
199 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
|
200 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
|
201 "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
|
202 return NGX_ERROR; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
203 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
204 |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
205 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
|
206 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
|
207 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
208 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
209 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
|
210 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
211 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
|
212 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
213 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
|
214 "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
|
215 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 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
|
217 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
|
218 "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
|
219 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
220 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
222 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
|
223 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
|
224 "fcntl(F_SETSIG) failed"); |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
225 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
226 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
228 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
|
229 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
|
230 "fcntl(F_SETOWN) failed"); |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
232 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
233 |
469 | 234 #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
|
235 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
|
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_SETAUXFL) 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 #endif |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
241 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
242 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
|
243 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
|
244 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
245 return NGX_OK; |
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 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
248 |
499 | 249 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
|
250 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
|
251 { |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
252 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
|
253 "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
|
254 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
255 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
|
256 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
257 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
|
258 "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
|
259 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
260 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
|
261 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
|
262 return NGX_OK; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
263 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
264 |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
265 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
|
266 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
|
267 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
|
268 return NGX_OK; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
269 } |
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 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
|
272 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
|
273 "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
|
274 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
|
275 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
276 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
277 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
|
278 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
|
279 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
280 return NGX_OK; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
281 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
282 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
283 |
499 | 284 static ngx_int_t |
563 | 285 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
|
286 { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
287 int signo; |
501 | 288 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
|
289 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
|
290 siginfo_t si; |
573 | 291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
297 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
|
298 tp = NULL; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
299 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
300 } else { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
301 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
|
302 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
|
303 tp = &ts; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
304 } |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
305 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
306 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
557 | 307 "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
|
308 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
309 /* 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
|
310 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
311 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
|
312 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
313 if (signo == -1) { |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
314 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
|
315 |
382
449c4885dcd1
nginx-0.0.7-2004-07-07-23:48:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
316 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
|
317 "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
|
318 |
567 | 319 if (flags & NGX_UPDATE_TIME) { |
320 ngx_time_update(0, 0); | |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
321 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
322 |
567 | 323 if (err == NGX_EAGAIN) { |
324 | |
325 /* timeout */ | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
326 |
567 | 327 if (timer != NGX_TIMER_INFINITE) { |
328 return NGX_AGAIN; | |
329 } | |
577 | 330 |
567 | 331 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, |
332 "sigtimedwait() returned EAGAIN without timeout"); | |
333 return NGX_ERROR; | |
334 } | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
335 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
336 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
|
337 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
|
338 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
339 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
340 |
567 | 341 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
342 "rtsig signo:%d fd:%d band:%04Xd", | |
343 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
|
344 |
567 | 345 if (flags & NGX_UPDATE_TIME) { |
346 ngx_time_update(0, 0); | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
347 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
348 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
349 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
|
350 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
351 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
|
352 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
353 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
|
354 return NGX_OK; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
355 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
356 |
551 | 357 c = ngx_cycle->files[si.si_fd]; |
358 | |
359 if (c == NULL) { | |
563 | 360 |
551 | 361 /* 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
|
362 |
551 | 363 return NGX_OK; |
364 } | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
365 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
366 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
|
367 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
368 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
|
369 |
563 | 370 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
|
371 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
372 /* |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
373 * 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
|
374 * 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
|
375 */ |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
376 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
377 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
461 | 378 "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
|
379 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
380 return NGX_OK; |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
381 } |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
382 |
563 | 383 if ((si.si_band & (POLLIN|POLLHUP|POLLERR)) && rev->active) { |
573 | 384 |
563 | 385 rev->ready = 1; |
573 | 386 |
387 if (flags & NGX_POST_EVENTS) { | |
388 queue = (ngx_event_t **) (rev->accept ? | |
389 &ngx_posted_accept_events : &ngx_posted_events); | |
390 | |
391 ngx_locked_post_event(rev, queue); | |
392 | |
577 | 393 } else { |
573 | 394 rev->handler(rev); |
395 } | |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
396 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
397 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
398 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
|
399 |
563 | 400 if ((si.si_band & (POLLOUT|POLLHUP|POLLERR)) && wev->active) { |
573 | 401 |
563 | 402 wev->ready = 1; |
573 | 403 |
404 if (flags & NGX_POST_EVENTS) { | |
405 ngx_locked_post_event(wev, &ngx_posted_events); | |
406 | |
407 } else { | |
408 wev->handler(wev); | |
409 } | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
410 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
411 |
567 | 412 return NGX_OK; |
413 | |
563 | 414 } else if (signo == SIGALRM) { |
415 | |
567 | 416 ngx_time_update(0, 0); |
417 | |
563 | 418 return NGX_OK; |
419 | |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
420 } 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
|
421 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
422 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
|
423 "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
|
424 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
425 /* 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
|
426 |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
427 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
|
428 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
|
429 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
|
430 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
431 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
|
432 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
|
433 "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
|
434 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
435 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
436 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
|
437 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
|
438 "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
|
439 } |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
440 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
441 overflow = 1; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
442 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
|
443 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
|
444 |
352
694d7ddc3599
nginx-0.0.4-2004-06-11-10:15:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
351
diff
changeset
|
445 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
|
446 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
447 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
448 |
567 | 449 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
450 "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
|
451 |
567 | 452 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
|
453 } |
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 |
499 | 456 static ngx_int_t |
563 | 457 ngx_rtsig_process_overflow(ngx_cycle_t *cycle, ngx_msec_t timer, |
458 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
|
459 { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
460 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
|
461 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
|
462 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
|
463 ngx_uint_t tested, n, i; |
563 | 464 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
|
465 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
|
466 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
|
467 |
563 | 468 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
469 "rtsig process overflow"); | |
470 | |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
471 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
|
472 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
473 tested = 0; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
474 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
475 for ( ;; ) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
476 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
477 n = 0; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
478 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
|
479 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
480 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
|
481 break; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
482 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
483 |
543 | 484 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
|
485 |
559 | 486 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
|
487 continue; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
488 } |
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 events = 0; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
491 |
509 | 492 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
|
493 events |= POLLIN; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
494 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
495 |
509 | 496 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
|
497 events |= POLLOUT; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
498 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
499 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
500 if (events == 0) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
501 continue; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
502 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
503 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
504 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
|
505 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
|
506 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
|
507 n++; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
508 } |
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 if (n == 0) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
511 break; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
512 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
513 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
514 for ( ;; ) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
515 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
|
516 |
563 | 517 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
518 "rtsig overflow poll:%d", ready); | |
519 | |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
520 if (ready == -1) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
521 err = ngx_errno; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
522 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
|
523 cycle->log, 0, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
524 "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
|
525 |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
526 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
|
527 continue; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
528 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
529 } |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
530 |
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
531 break; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
532 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
533 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
534 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
|
535 continue; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
536 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
537 |
563 | 538 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
|
539 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
540 for (i = 0; i < n; i++) { |
543 | 541 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
|
542 |
559 | 543 if (c == NULL) { |
544 continue; | |
545 } | |
546 | |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
547 rev = c->read; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
548 |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
549 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
|
550 && !rev->closed |
509 | 551 && rev->handler |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
552 && (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
|
553 & (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
|
554 { |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
555 tested++; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
556 |
563 | 557 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
|
558 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
|
559 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
560 } else { |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
561 rev->ready = 1; |
563 | 562 } |
563 | |
564 if (flags & NGX_POST_EVENTS) { | |
565 queue = (ngx_event_t **) (rev->accept ? | |
566 &ngx_posted_accept_events : &ngx_posted_events); | |
567 | |
568 ngx_locked_post_event(rev, queue); | |
569 | |
570 } else { | |
571 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
|
572 } |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
573 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
574 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
575 wev = c->write; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
576 |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
577 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
|
578 && !wev->closed |
509 | 579 && wev->handler |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
580 && (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
|
581 & (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
|
582 { |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
583 tested++; |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
584 |
563 | 585 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
|
586 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
|
587 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
588 } else { |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
589 wev->ready = 1; |
563 | 590 } |
591 | |
592 if (flags & NGX_POST_EVENTS) { | |
593 ngx_locked_post_event(wev, &ngx_posted_events); | |
594 | |
595 } else { | |
596 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
|
597 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
598 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
599 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
600 |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
601 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
|
602 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
603 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
|
604 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
605 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
|
606 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
607 /* |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
608 * 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
|
609 * the new overflow. |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
610 * |
563 | 611 * learn the "/proc/sys/kernel/rtsig-max" value because |
612 * 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
|
613 */ |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
614 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
615 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
|
616 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
|
617 len = sizeof(rtsig_max); |
493 | 618 |
619 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
|
620 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
|
621 "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
|
622 return NGX_ERROR; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
623 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
624 |
493 | 625 /* 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
|
626 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
|
627 len = sizeof(rtsig_nr); |
493 | 628 |
629 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
|
630 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
|
631 "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
|
632 return NGX_ERROR; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
633 } |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
634 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
635 /* |
563 | 636 * 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
|
637 * is bigger than |
563 | 638 * "/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
|
639 */ |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
640 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
641 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
|
642 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
|
643 "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
|
644 rtsig_nr, rtsig_max); |
563 | 645 while (ngx_rtsig_process_events(cycle, 0, flags) == NGX_OK) |
646 { | |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
647 /* void */ |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
648 } |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
649 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
650 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
651 } else { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
652 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
653 /* |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
654 * 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
|
655 * 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
|
656 */ |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
657 |
563 | 658 while (ngx_rtsig_process_events(cycle, 0, flags) == NGX_OK) { |
659 /* void */ | |
660 } | |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
661 } |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
662 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
663 tested = 0; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
664 } |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
665 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
666 |
563 | 667 if (flags & NGX_UPDATE_TIME) { |
668 ngx_time_update(0, 0); | |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
669 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
670 |
527 | 671 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
|
672 "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
|
673 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
674 overflow = 0; |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
675 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
|
676 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
677 return NGX_OK; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
678 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
679 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
680 |
499 | 681 static void * |
682 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
|
683 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
684 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
|
685 |
501 | 686 rtscf = ngx_palloc(cycle->pool, sizeof(ngx_rtsig_conf_t)); |
687 if (rtscf == NULL) { | |
688 return NGX_CONF_ERROR; | |
689 } | |
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 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
|
692 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
|
693 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
|
694 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
|
695 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
696 return rtscf; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
697 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
698 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
699 |
499 | 700 static char * |
701 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
|
702 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
703 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
|
704 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
705 /* 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
|
706 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
|
707 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
708 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
|
709 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
|
710 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
|
711 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
712 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
|
713 } |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
714 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
715 |
499 | 716 static char * |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
577
diff
changeset
|
717 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
|
718 { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
719 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
|
720 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
|
721 } |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
722 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
723 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
|
724 "\"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
|
725 "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
|
726 |
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_OK; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
728 } |