Mercurial > hg > nginx-quic
annotate src/event/modules/ngx_rtsig_module.c @ 343:6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 28 May 2004 15:49:23 +0000 |
parents | fb4dfb2ac0fc |
children | e366ba5db8f8 |
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 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
14 #define F_SETSIG 10 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
15 #define SIGRTMIN 33 |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
16 #define si_fd __spare__[0] |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
17 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
18 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
|
19 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
|
20 |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
21 |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
22 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
|
23 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
|
24 { |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
25 return -1; |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
26 } |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
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 { |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
32 int signo; |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
33 } 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
|
34 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
35 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
36 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
|
37 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
38 static int ngx_rtsig_init(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
|
39 static void ngx_rtsig_done(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
|
40 static int ngx_rtsig_add_connection(ngx_connection_t *c); |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
41 static int ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags); |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
42 static int ngx_rtsig_process_events(ngx_cycle_t *cycle); |
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
43 static int 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
|
44 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
45 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
|
46 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
|
47 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
48 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
49 static sigset_t set; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
50 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
51 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
52 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
|
53 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
54 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
|
55 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
56 {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
|
57 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
|
58 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
|
59 0, |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
60 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
|
61 NULL}, |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
62 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
63 ngx_null_command |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
64 }; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
65 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
66 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
67 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
|
68 &rtsig_name, |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
69 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
|
70 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
|
71 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
72 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 ngx_rtsig_del_connection, /* delete an connection */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
83 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
84 }; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
85 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
86 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
|
87 NGX_MODULE, |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
88 &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
|
89 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
|
90 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
|
91 NULL, /* init module */ |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
92 NULL /* init child */ |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
93 }; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
94 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
95 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
96 static int 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
|
97 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
98 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
|
99 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
100 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
|
101 return NGX_ERROR; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
102 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
103 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
104 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
|
105 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
106 sigemptyset(&set); |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
107 sigaddset(&set, rtscf->signo); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
108 sigaddset(&set, SIGIO); |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
109 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
110 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
|
111 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
|
112 "sigprocmask() failed"); |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
113 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
114 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
115 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
116 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
|
117 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
118 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
|
119 |
328
fb4dfb2ac0fc
nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
120 ngx_event_flags = NGX_USE_SIGIO_EVENT |
fb4dfb2ac0fc
nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
121 |NGX_HAVE_GREEDY_EVENT |
fb4dfb2ac0fc
nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
122 |NGX_HAVE_INSTANCE_EVENT; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
123 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
124 return NGX_OK; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
125 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
126 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
127 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
128 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
|
129 { |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
130 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
|
131 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
132 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
133 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
134 static int 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
|
135 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
136 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
|
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(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
|
139 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
140 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
141 "rtsig add connection: fd:%d signo:%d", c->fd, rtscf->signo); |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 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
|
144 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
|
145 "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
|
146 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
147 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
149 if (fcntl(c->fd, F_SETSIG, 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
|
150 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
|
151 "fcntl(F_SETSIG) failed"); |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
152 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
153 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
155 if (fcntl(c->fd, F_SETOWN, ngx_getpid()) == -1) { |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
156 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
|
157 "fcntl(F_SETOWN) failed"); |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
159 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
160 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
161 #if (HAVE_ONESIGFD) |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 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
|
163 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
|
164 "fcntl(F_SETAUXFL) failed"); |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
165 return NGX_ERROR; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 #endif |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
169 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
|
170 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
|
171 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 return NGX_OK; |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
173 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
174 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
175 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
176 static int 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
|
177 { |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
178 if (!(flags & NGX_CLOSE_EVENT)) { |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
179 if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK) == -1) { |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
180 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
181 "fcntl(O_RDWR|O_NONBLOCK) failed"); |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
182 return NGX_ERROR; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
183 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
184 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
185 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
186 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
|
187 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
|
188 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
189 return NGX_OK; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
190 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
191 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
192 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
193 int 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
|
194 { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
195 int signo; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
196 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
|
197 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
|
198 size_t n; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
199 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
|
200 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
|
201 siginfo_t si; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
209 for ( ;; ) { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
210 timer = ngx_event_find_timer(); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
211 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
212 if (timer != 0) { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
213 break; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
214 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
215 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
216 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
217 "rtsig expired timer"); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
218 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
219 ngx_event_expire_timers((ngx_msec_t) |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
220 (ngx_elapsed_msec - ngx_old_elapsed_msec)); |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
221 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
222 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
223 expire = 1; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
224 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
225 if (ngx_accept_mutex) { |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
226 if (ngx_accept_disabled > 0) { |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
227 ngx_accept_disabled--; |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
228 |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
229 } else { |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
230 if (ngx_trylock_accept_mutex(cycle) == NGX_ERROR) { |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
231 return NGX_ERROR; |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
232 } |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
233 |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
234 if (ngx_accept_mutex_held == 0 |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
235 && (timer == NGX_TIMER_INFINITE |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
236 || timer > ngx_accept_mutex_delay)) |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
237 { |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
238 timer = ngx_accept_mutex_delay; |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
239 expire = 0; |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
240 } |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
241 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
242 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
243 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
244 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
|
245 tp = NULL; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
246 expire = 0; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
247 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
248 } else { |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
249 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
|
250 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
|
251 tp = &ts; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
252 } |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
253 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
254 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
|
255 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
256 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
|
257 "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
|
258 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
259 /* Linux sigwaitinfo() is sigtimedwait() with the NULL timeout pointer */ |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
260 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
261 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
|
262 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
263 if (signo == -1) { |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
264 err = ngx_errno; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
265 } else { |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
266 err = 0; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
267 } |
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 ngx_gettimeofday(&tv); |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
270 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
|
271 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
272 delta = ngx_elapsed_msec; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
273 ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
274 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
275 if (err) { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
276 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
|
277 cycle->log, err, "sigtimedwait() failed"); |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
278 ngx_accept_mutex_unlock(); |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
279 return NGX_ERROR; |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
280 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
281 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
282 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
|
283 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
|
284 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
285 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
|
286 "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
|
287 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
288 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
289 ngx_log_debug3(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
|
290 "signo:%d fd:%d band:%X", signo, si.si_fd, si.si_band); |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
291 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
292 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
|
293 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
294 if (signo == rtscf->signo) { |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
295 |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
296 /* 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
|
297 |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
298 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
|
299 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
300 /* TODO: stale signals */ |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
301 |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
302 if (si.si_band & (POLLIN|POLLHUP|POLLERR)) { |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
303 if (c->read->active) { |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
304 c->read->ready = 1; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
305 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
306 if (!ngx_threaded && !ngx_accept_mutex_held) { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
307 c->read->event_handler(c->read); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
308 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
309 } else if (c->read->accept) { |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
310 if (ngx_accept_disabled > 0) { |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
311 c->read->event_handler(c->read); |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
312 } |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
313 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
314 } else { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
315 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
|
316 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
|
317 return NGX_ERROR; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
318 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
319 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
320 ngx_post_event(c->read); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
321 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
322 ngx_mutex_unlock(ngx_posted_events_mutex); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
323 } |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
324 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
325 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
326 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
327 if (si.si_band & (POLLOUT|POLLHUP|POLLERR)) { |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
328 if (c->write->active) { |
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
329 c->write->ready = 1; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
330 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
331 if (!ngx_threaded && !ngx_accept_mutex_held) { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
332 c->write->event_handler(c->write); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
333 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
334 } else { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
335 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
336 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
|
337 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
|
338 return NGX_ERROR; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
339 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
340 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
341 ngx_post_event(c->write); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
342 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
343 ngx_mutex_unlock(ngx_posted_events_mutex); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
344 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
345 } |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
346 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
347 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
348 } 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
|
349 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
|
350 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
351 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
352 "signal queue overflowed: " |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
353 "SIGIO, fd:%d, band:%X", 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
|
354 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
355 /* TODO: flush all the used RT signals */ |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
356 |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
357 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
|
358 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
|
359 sigemptyset(&sa.sa_mask); |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
360 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
|
361 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
|
362 "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
|
363 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
246
diff
changeset
|
364 |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
365 ngx_event_actions = ngx_poll_module_ctx.actions; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
366 ngx_event_actions.process = ngx_rtsig_process_overflow; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
367 ngx_event_flags = NGX_OVERFLOW_EVENT |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
368 |NGX_USE_LEVEL_EVENT|NGX_USE_ONESHOT_EVENT; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
369 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
370 /* STUB: add events. WHAT to do with fcntl()s ? */ |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
371 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
372 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
373 } else { |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
374 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
|
375 "sigtimedwait() returned unexpected signal: %d", signo); |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
376 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
|
377 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
|
378 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
379 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
380 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
|
381 |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
382 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
|
383 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
|
384 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
385 |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
386 if (!ngx_threaded) { |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
387 ngx_event_process_posted(cycle); |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
388 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
389 |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
390 return NGX_OK; |
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 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
393 |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
394 static int 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
|
395 { |
305
4b1a3a4acc60
nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
262
diff
changeset
|
396 if (ngx_poll_module_ctx.actions.process(cycle) == NGX_OK) { |
261
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
397 ngx_event_actions = ngx_rtsig_module_ctx.actions; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
398 ngx_event_flags = NGX_USE_SIGIO_EVENT; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
399 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
400 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
401 return NGX_OK; |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
402 } |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
403 |
bdd631bf1a1c
nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
260
diff
changeset
|
404 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
405 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
|
406 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
407 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
|
408 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
409 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
|
410 NGX_CONF_ERROR); |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
411 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
412 rtscf->signo = NGX_CONF_UNSET; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
413 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
414 return rtscf; |
246
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
415 } |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
416 |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
417 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
418 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
|
419 { |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
420 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
|
421 |
260
5dacbb4daaf6
nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
247
diff
changeset
|
422 /* 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
|
423 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
|
424 |
6753e8cdaa2c
nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
60
diff
changeset
|
425 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
|
426 } |