Mercurial > hg > nginx-quic
annotate src/event/modules/ngx_rtsig_module.c @ 404:37b5381fb6d8
nginx-0.0.9-2004-07-30-21:05:14 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 30 Jul 2004 17:05:14 +0000 |
parents | f209f3391020 |
children | da8c5707af39 |
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 /* |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
3 * Copyright (C) 2002-2004 Igor Sysoev, http://sysoev.ru/en/ |
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 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
12 #if (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 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
15 #define SIGRTMIN 33 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
16 #define si_fd __spare__[0] |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
17 #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
|
18 #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
|
19 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
20 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
|
21 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
|
22 { |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
23 return -1; |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
24 } |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
25 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
26 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
|
27 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
28 #endif |
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 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
31 typedef struct { |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
32 int signo; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
33 ngx_int_t overflow_events; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
34 ngx_int_t overflow_test; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
35 ngx_int_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
|
36 } 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
|
37 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
38 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
39 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
|
40 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
41 static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle); |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
42 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
|
43 static ngx_int_t ngx_rtsig_add_connection(ngx_connection_t *c); |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
44 static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags); |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
45 static ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle); |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
46 static ngx_int_t ngx_rtsig_process_overflow(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
|
47 |
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_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
|
49 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
|
50 static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
51 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
|
52 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
53 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
54 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
|
55 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
|
56 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
|
57 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
58 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
59 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
|
60 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
61 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
|
62 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
|
63 }; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
64 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
65 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
66 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
|
67 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
68 {ngx_string("rtsig_signo"), |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
69 NGX_EVENT_CONF|NGX_CONF_TAKE1, |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
70 ngx_conf_set_num_slot, |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
71 0, |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
72 offsetof(ngx_rtsig_conf_t, signo), |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
73 NULL}, |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
74 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
75 {ngx_string("rtsig_overflow_events"), |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
76 NGX_EVENT_CONF|NGX_CONF_TAKE1, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
77 ngx_conf_set_num_slot, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
78 0, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
79 offsetof(ngx_rtsig_conf_t, overflow_events), |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
80 NULL}, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
81 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
82 {ngx_string("rtsig_overflow_test"), |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
83 NGX_EVENT_CONF|NGX_CONF_TAKE1, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
84 ngx_conf_set_num_slot, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
85 0, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
86 offsetof(ngx_rtsig_conf_t, overflow_test), |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
87 NULL}, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
88 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
89 {ngx_string("rtsig_overflow_threshold"), |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
90 NGX_EVENT_CONF|NGX_CONF_TAKE1, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
91 ngx_conf_set_num_slot, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
92 0, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
93 offsetof(ngx_rtsig_conf_t, overflow_threshold), |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
94 &ngx_overflow_threshold_bounds}, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
95 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
96 ngx_null_command |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
97 }; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
98 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
99 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
100 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
|
101 &rtsig_name, |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
102 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
|
103 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
|
104 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
105 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
117 |
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 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
120 ngx_module_t 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
|
121 NGX_MODULE, |
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_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
|
123 ngx_rtsig_commands, /* module directives */ |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
124 NGX_EVENT_MODULE, /* module type */ |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
125 NULL, /* init module */ |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
126 NULL /* init process */ |
246
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 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
129 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
130 static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle) |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
131 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
132 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
|
133 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
134 if (ngx_poll_module_ctx.actions.init(cycle) == NGX_ERROR) { |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
135 return NGX_ERROR; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
136 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
137 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
138 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
|
139 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
140 sigemptyset(&set); |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
141 sigaddset(&set, rtscf->signo); |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
142 sigaddset(&set, 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
|
143 sigaddset(&set, SIGIO); |
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 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
|
146 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
|
147 "sigprocmask() failed"); |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
148 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
149 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
150 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
151 if (overflow_list) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
152 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
|
153 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
154 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
155 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
|
156 cycle->log); |
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 == NULL) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
158 return NGX_ERROR; |
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 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
161 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
|
162 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
163 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
|
164 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
165 ngx_event_flags = NGX_USE_RTSIG_EVENT|NGX_HAVE_GREEDY_EVENT; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
166 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
167 return NGX_OK; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
168 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
169 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
170 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
171 static void 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
|
172 { |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
173 ngx_poll_module_ctx.actions.done(cycle); |
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 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
176 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
177 static ngx_int_t 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
|
178 { |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
179 int signo; |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
180 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
|
181 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
182 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
|
183 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
184 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
|
185 "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
|
186 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
187 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
|
188 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
|
189 "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
|
190 return NGX_ERROR; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
191 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
192 |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
193 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
|
194 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
|
195 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
196 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
197 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
|
198 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
199 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
|
200 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
201 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
202 "rtsig add connection: fd:%d signo:%d", c->fd, signo); |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
203 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
204 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
|
205 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
|
206 "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
|
207 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
208 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
210 if (fcntl(c->fd, F_SETSIG, signo) == -1) { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
211 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
|
212 "fcntl(F_SETSIG) failed"); |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
213 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
214 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
215 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
216 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
|
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(F_SETOWN) 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 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
222 #if (HAVE_ONESIGFD) |
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_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
|
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(F_SETAUXFL) 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 #endif |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
229 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
230 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
|
231 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
|
232 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
233 return NGX_OK; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
234 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
235 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
236 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
237 static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags) |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
238 { |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
239 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
|
240 "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
|
241 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
242 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
|
243 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
244 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
|
245 "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
|
246 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
247 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
|
248 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
|
249 return NGX_OK; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
250 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
251 |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
252 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
|
253 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
|
254 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
|
255 return NGX_OK; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
256 } |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
257 |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
258 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
|
259 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
|
260 "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
|
261 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
|
262 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
263 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
264 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
|
265 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
|
266 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
267 return NGX_OK; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
268 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
269 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
270 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
271 ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle) |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
272 { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
273 int signo; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
274 ngx_int_t instance, i; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
275 ngx_uint_t expire; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
276 size_t n; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
277 ngx_msec_t timer; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
278 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
|
279 siginfo_t si; |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
280 ngx_event_t *rev, *wev; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
281 struct timeval tv; |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
282 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
|
283 struct sigaction sa; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
284 ngx_epoch_msec_t delta; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
285 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
|
286 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
|
287 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
288 if (overflow) { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
289 timer = 0; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
290 expire = 0; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
291 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
292 } else { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
293 for ( ;; ) { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
294 timer = ngx_event_find_timer(); |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
295 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
296 #if (NGX_THREADS) |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
297 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
298 if (timer == NGX_TIMER_ERROR) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
299 return NGX_ERROR; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
300 } |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
301 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
302 if (timer == NGX_TIMER_INFINITE || timer > 500) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
303 timer = 500; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
304 break; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
305 } |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
306 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
307 #endif |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
308 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
309 if (timer != 0) { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
310 break; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
311 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
312 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
313 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
314 "rtsig expired timer"); |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
315 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
316 ngx_event_expire_timers((ngx_msec_t) |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
317 (ngx_elapsed_msec - ngx_old_elapsed_msec)); |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
318 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
319 if (ngx_posted_events && ngx_threaded) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
320 ngx_wakeup_worker_thread(cycle); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
321 } |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
322 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
323 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
324 expire = 1; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
325 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
326 if (ngx_accept_mutex) { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
327 if (ngx_accept_disabled > 0) { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
328 ngx_accept_disabled--; |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
329 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
330 } else { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
331 ngx_accept_mutex_held = 0; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
332 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
333 if (ngx_trylock_accept_mutex(cycle) == NGX_ERROR) { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
334 return NGX_ERROR; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
335 } |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
336 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
337 if (ngx_accept_mutex_held == 0 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
338 && (timer == NGX_TIMER_INFINITE |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
339 || timer > ngx_accept_mutex_delay)) |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
340 { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
341 timer = ngx_accept_mutex_delay; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
342 expire = 0; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
343 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
344 } |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
345 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
346 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
347 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
348 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
|
349 tp = NULL; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
350 expire = 0; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
351 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
352 } else { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
353 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
|
354 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
|
355 tp = &ts; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
356 } |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
357 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
358 ngx_old_elapsed_msec = ngx_elapsed_msec; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
359 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
360 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
361 "rtsig timer: %d", timer); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
362 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
363 /* 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
|
364 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
365 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
|
366 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
367 if (signo == -1) { |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
368 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
|
369 |
382
449c4885dcd1
nginx-0.0.7-2004-07-07-23:48:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
370 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
|
371 "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
|
372 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
373 if (err == NGX_EAGAIN) { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
374 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
375 if (timer == NGX_TIMER_INFINITE) { |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
376 ngx_accept_mutex_unlock(); |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
377 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
378 "sigtimedwait() returned EAGAIN without timeout"); |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
379 return NGX_ERROR; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
380 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
381 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
382 err = 0; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
383 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
384 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
385 } else { |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
386 err = 0; |
382
449c4885dcd1
nginx-0.0.7-2004-07-07-23:48:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
387 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
449c4885dcd1
nginx-0.0.7-2004-07-07-23:48:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
388 "rtsig signo:%d fd:%d band:%X", |
449c4885dcd1
nginx-0.0.7-2004-07-07-23:48:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
389 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
|
390 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
391 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
392 ngx_gettimeofday(&tv); |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
393 ngx_time_update(tv.tv_sec); |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
394 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
395 delta = ngx_elapsed_msec; |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
396 ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000 |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
397 + tv.tv_usec / 1000 - ngx_start_msec; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
398 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
399 if (err) { |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
400 ngx_accept_mutex_unlock(); |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
401 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
|
402 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
|
403 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
404 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
405 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
406 if (timer != NGX_TIMER_INFINITE) { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
407 delta = ngx_elapsed_msec - delta; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
408 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
409 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
410 "rtsig timer: %d, delta: %d", timer, (int) delta); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
411 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
412 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
413 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
|
414 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
415 if (signo == rtscf->signo || signo == 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
|
416 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
417 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
|
418 return NGX_OK; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
419 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
420 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
421 /* TODO: old_cycles */ |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
422 |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
423 c = &ngx_cycle->connections[si.si_fd]; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
424 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
425 instance = signo - rtscf->signo; |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
426 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
427 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
|
428 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
429 if (c->read->instance != instance) { |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
430 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
431 /* |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
432 * 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
|
433 * 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
|
434 */ |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
435 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
436 ngx_accept_mutex_unlock(); |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
437 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
438 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
439 "rtsig: stale event " PTR_FMT, c); |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
440 |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
441 return NGX_OK; |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
442 } |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
443 |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
444 if (si.si_band & (POLLIN|POLLHUP|POLLERR)) { |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
445 if (rev->active) { |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
446 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
447 if (ngx_threaded && !rev->accept) { |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
448 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
449 ngx_accept_mutex_unlock(); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
450 return NGX_ERROR; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
451 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
452 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
453 rev->posted_ready = 1; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
454 ngx_post_event(rev); |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
455 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
456 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
|
457 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
458 } else { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
459 rev->ready = 1; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
460 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
461 if (!ngx_threaded && !ngx_accept_mutex_held) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
462 rev->event_handler(rev); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
463 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
464 } else if (rev->accept) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
465 if (ngx_accept_disabled <= 0) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
466 rev->event_handler(rev); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
467 } |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
468 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
469 } else { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
470 ngx_post_event(rev); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
471 } |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
472 } |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
473 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
474 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
475 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
476 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
|
477 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
478 if (si.si_band & (POLLOUT|POLLHUP|POLLERR)) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
479 if (wev->active) { |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
480 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
481 if (ngx_threaded) { |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
482 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
483 ngx_accept_mutex_unlock(); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
484 return NGX_ERROR; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
485 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
486 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
487 wev->posted_ready = 1; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
488 ngx_post_event(wev); |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
489 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
490 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
|
491 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
492 } else { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
493 wev->ready = 1; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
494 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
495 if (!ngx_threaded && !ngx_accept_mutex_held) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
496 wev->event_handler(wev); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
497 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
498 } else { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
499 ngx_post_event(wev); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
500 } |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
501 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
502 } |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
503 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
504 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
505 } 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
|
506 ngx_accept_mutex_unlock(); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
507 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
508 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
|
509 "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
|
510 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
511 /* 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
|
512 |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
513 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
|
514 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
|
515 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
|
516 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
517 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
|
518 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
|
519 "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
|
520 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
521 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
522 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
|
523 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
|
524 "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
|
525 } |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
526 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
527 overflow = 1; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
528 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
|
529 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
|
530 |
352
694d7ddc3599
nginx-0.0.4-2004-06-11-10:15:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
351
diff
changeset
|
531 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
|
532 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
533 } else if (signo != -1) { |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
534 ngx_accept_mutex_unlock(); |
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
535 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
536 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
537 "sigtimedwait() returned unexpected signal: %d", signo); |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
328
diff
changeset
|
538 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
539 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
|
540 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
541 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
542 ngx_accept_mutex_unlock(); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
543 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
544 if (expire && delta) { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
545 ngx_event_expire_timers((ngx_msec_t) delta); |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
546 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
547 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
548 if (ngx_posted_events) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
549 if (ngx_threaded) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
550 ngx_wakeup_worker_thread(cycle); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
551 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
552 } else { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
553 ngx_event_process_posted(cycle); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
554 } |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
555 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
556 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
557 if (signo == -1) { |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
558 return NGX_AGAIN; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
559 } else { |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
560 return NGX_OK; |
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
561 } |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
562 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
563 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
564 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
565 /* TODO: old cylces */ |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
566 |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
567 static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle) |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
568 { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
569 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
|
570 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
|
571 ngx_int_t tested, n, i; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
572 ngx_err_t err; |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
573 ngx_event_t *rev, *wev; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
574 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
|
575 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
|
576 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
577 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
|
578 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
579 tested = 0; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
580 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
581 for ( ;; ) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
582 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
583 n = 0; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
584 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
|
585 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
586 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
|
587 break; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
588 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
589 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
590 c = &cycle->connections[overflow_current++]; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
591 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
592 if (c->fd == -1) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
593 continue; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
594 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
595 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
596 events = 0; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
597 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
598 if (c->read->active && c->read->event_handler) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
599 events |= POLLIN; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
600 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
601 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
602 if (c->write->active && c->write->event_handler) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
603 events |= POLLOUT; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
604 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
605 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
606 if (events == 0) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
607 continue; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
608 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
609 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
610 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
|
611 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
|
612 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
|
613 n++; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
614 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
615 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
616 if (n == 0) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
617 break; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
618 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
619 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
620 for ( ;; ) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
621 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
|
622 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
623 if (ready == -1) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
624 err = ngx_errno; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
625 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
|
626 cycle->log, 0, |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
627 "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
|
628 |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
629 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
|
630 continue; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
631 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
632 } |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
633 |
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
634 break; |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
635 } |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
636 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
637 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
|
638 continue; |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
639 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
640 |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
641 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { |
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
642 return NGX_ERROR; |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
643 } |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
644 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
645 for (i = 0; i < n; i++) { |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
646 c = &cycle->connections[overflow_list[i].fd]; |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
647 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
648 rev = c->read; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
649 |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
650 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
|
651 && !rev->closed |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
652 && rev->event_handler |
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
653 && (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
|
654 & (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
|
655 { |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
656 tested++; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
657 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
658 if (ngx_threaded) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
659 rev->posted_ready = 1; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
660 ngx_post_event(rev); |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
661 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
662 } else { |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
663 rev->ready = 1; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
664 rev->event_handler(rev); |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
665 } |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
666 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
667 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
668 wev = c->write; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
669 |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
670 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
|
671 && !wev->closed |
390
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
672 && wev->event_handler |
1471c6fb108a
nginx-0.0.7-2004-07-14-00:24:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
673 && (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
|
674 & (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
|
675 { |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
676 tested++; |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
677 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
678 if (ngx_threaded) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
679 wev->posted_ready = 1; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
680 ngx_post_event(wev); |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
681 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
682 } else { |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
683 wev->ready = 1; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
684 wev->event_handler(wev); |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
685 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
686 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
687 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
688 |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
689 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
|
690 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
691 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
|
692 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
693 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
|
694 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
695 /* |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
696 * 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
|
697 * the new overflow. |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
698 * |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
699 * Learn the /proc/sys/kernel/rtsig-max value because |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
700 * it can be changed sisnce the last checking. |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
701 */ |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
702 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
703 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
|
704 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
|
705 len = sizeof(rtsig_max); |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
706 if (sysctl(name, sizeof(name), &rtsig_max, &len, NULL, 0) == -1) |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
707 { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
708 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
|
709 "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
|
710 return NGX_ERROR; |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
711 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
712 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
713 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
|
714 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
|
715 len = sizeof(rtsig_nr); |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
716 if (sysctl(name, sizeof(name), &rtsig_nr, &len, NULL, 0) == -1) |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
717 { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
718 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
|
719 "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
|
720 return NGX_ERROR; |
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 /* |
402
f209f3391020
nginx-0.0.9-2004-07-28-20:16:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
724 * 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
|
725 * is bigger than |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
726 * /proc/sys/kernel/rtsig-max / rtsig_overflow_threshold |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
727 */ |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
728 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
729 if (rtsig_max / rtscf->overflow_threshold < rtsig_nr) { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
730 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
|
731 "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
|
732 rtsig_nr, rtsig_max); |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
733 while (ngx_rtsig_process_events(cycle) == NGX_OK) { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
734 /* void */ |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
735 } |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
736 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
737 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
738 } else { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
739 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
740 /* |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
741 * 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
|
742 * 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
|
743 */ |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
744 |
349
a958aa92f9a5
nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
348
diff
changeset
|
745 while (ngx_rtsig_process_events(cycle) == NGX_OK) { /* void */ } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
746 } |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
747 |
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
748 tested = 0; |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
749 } |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
750 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
751 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
752 if (ngx_posted_events) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
753 if (ngx_threaded) { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
754 ngx_wakeup_worker_thread(cycle); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
755 |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
756 } else { |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
757 ngx_event_process_posted(cycle); |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
380
diff
changeset
|
758 } |
348
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
759 } |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
760 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
761 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
762 "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
|
763 |
68ff8000a974
nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
764 overflow = 0; |
380
5ce6561246a5
nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
375
diff
changeset
|
765 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
|
766 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
767 return NGX_OK; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
768 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
769 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
770 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
771 static void *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
|
772 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
773 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
|
774 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
775 ngx_test_null(rtscf, ngx_palloc(cycle->pool, sizeof(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
|
776 NGX_CONF_ERROR); |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
777 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
778 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
|
779 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
|
780 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
|
781 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
|
782 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
783 return rtscf; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
784 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
785 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
786 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
787 static char *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
|
788 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
789 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
|
790 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
791 /* LinuxThreads use the first 3 RT signals */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
792 ngx_conf_init_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
|
793 |
351
af4c6b45a687
nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
350
diff
changeset
|
794 ngx_conf_init_value(rtscf->overflow_events, 16); |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
795 ngx_conf_init_value(rtscf->overflow_test, 32); |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
352
diff
changeset
|
796 ngx_conf_init_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
|
797 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
798 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
|
799 } |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
800 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
801 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
802 static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
803 void *post, void *data) |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
804 { |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
805 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
|
806 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
|
807 } |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
808 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
809 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
|
810 "\"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
|
811 "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
|
812 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
390
diff
changeset
|
813 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
|
814 } |