annotate src/event/modules/ngx_rtsig_module.c @ 375:744ccb59062d

nginx-0.0.7-2004-07-02-19:54:34 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 02 Jul 2004 15:54:34 +0000
parents eaf1f651cf86
children 5ce6561246a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
26 #endif
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
27
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
28
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
29 typedef struct {
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
30 int signo;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
31 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
32 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
33 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
34 } 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
35
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
36
261
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
37 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
38
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
39 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
40 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
41 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
42 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
43 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
44 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
45
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
46 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
47 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
48
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
49
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
50 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
51 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
52 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
53
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
54
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
55 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
56
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
57 static ngx_conf_num_bounds_t 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
58 ngx_conf_check_num_bounds, 2, 10
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
59 };
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
60
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
61
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
62 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
63
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
64 {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
65 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
66 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
67 0,
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
68 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
69 NULL},
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
70
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
71 {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
72 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
73 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
74 0,
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
75 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
76 NULL},
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
77
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
78 {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
79 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
80 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
81 0,
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
82 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
83 NULL},
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
84
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
85 {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
86 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
87 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
88 0,
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
89 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
90 &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
91
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
92 ngx_null_command
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
93 };
60
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
94
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
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 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
97 &rtsig_name,
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
98 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
99 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
100
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
101 {
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111 }
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
112
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
113 };
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
114
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
115 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
116 NGX_MODULE,
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
117 &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
118 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
119 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
120 NULL, /* init module */
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
121 NULL /* init child */
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
122 };
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
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
125 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
126 {
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
127 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
128
261
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
129 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
130 return NGX_ERROR;
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
131 }
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
132
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
133 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
134
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
135 sigemptyset(&set);
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
136 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
137 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
138 sigaddset(&set, SIGIO);
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 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
141 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
142 "sigprocmask() failed");
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
143 return NGX_ERROR;
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
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
146 if (overflow_list) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
147 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
148 }
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
149
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
150 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
151 cycle->log);
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
152 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
153 return NGX_ERROR;
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
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
156 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
157
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
158 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
159
346
55e496a8ece3 nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 344
diff changeset
160 ngx_event_flags = NGX_USE_RTSIG_EVENT
328
fb4dfb2ac0fc nginx-0.0.3-2004-04-28-10:14:50 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
161 |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
162 |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
163
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
164 return NGX_OK;
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
165 }
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
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
168 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
169 {
261
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
170 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
171 }
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
172
60
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
173
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
174 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
175 {
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
176 int signo;
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
177 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
178
349
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
179 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
180
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 352
diff changeset
181 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
182 "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
183
349
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
184 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
185 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
186 "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
187 return NGX_ERROR;
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
188 }
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
189
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
190 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
191 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
192 }
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
193
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
194 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
195
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
196 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
197
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
198 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
199 "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
200
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
201 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
202 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
203 "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
204 return NGX_ERROR;
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
205 }
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
206
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
207 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
208 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
209 "fcntl(F_SETSIG) failed");
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
210 return NGX_ERROR;
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
211 }
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
212
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
213 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
214 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
215 "fcntl(F_SETOWN) failed");
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
216 return NGX_ERROR;
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
217 }
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
218
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
219 #if (HAVE_ONESIGFD)
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
220 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
221 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
222 "fcntl(F_SETAUXFL) failed");
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
223 return NGX_ERROR;
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
224 }
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
225 #endif
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
226
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
227 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
228 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
229
60
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
230 return NGX_OK;
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
231 }
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
232
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
233
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
234 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
235 {
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
236 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
237 "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
238
349
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
239 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
240
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 352
diff changeset
241 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
242 "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
243
349
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
244 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
245 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
246 return NGX_OK;
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
247 }
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
248
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
249 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
250 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
251 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
252 return NGX_OK;
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
253 }
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
254
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
255 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
256 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
257 "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
258 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
259 }
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
260
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
261 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
262 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
263
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
264 return NGX_OK;
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
265 }
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
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
268 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
269 {
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
270 int signo;
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
271 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
272 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
273 size_t n;
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
274 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
275 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
276 siginfo_t si;
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
277 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
278 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
279 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
280 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
281 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
282 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
283
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
284 if (overflow) {
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
285 timer = 0;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
286 expire = 0;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
287
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
288 } else {
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
289 for ( ;; ) {
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
290 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
291
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
292 if (timer != 0) {
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
293 break;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
294 }
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
295
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
296 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
297 "rtsig expired timer");
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
298
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
299 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
300 (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
301 }
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
302
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
303 expire = 1;
316
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
304
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
305 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
306 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
307 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
308
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
309 } else {
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 352
diff changeset
310 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
311
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
312 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
313 return NGX_ERROR;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
314 }
316
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
315
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
316 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
317 && (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
318 || 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
319 {
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
320 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
321 expire = 0;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
322 }
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
323 }
316
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
324 }
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
325 }
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
326
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
327 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
328 tp = NULL;
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
329 expire = 0;
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 } else {
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
332 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
333 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
334 tp = &ts;
316
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
335 }
261
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
336
316
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
337 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
338
305
4b1a3a4acc60 nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
339 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
340 "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
341
261
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
342 /* 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
343
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
344 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
345
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
346 if (signo == -1) {
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
347 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
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
349 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
350
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
351 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
352 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
353 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
354 "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
355 return NGX_ERROR;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
356 }
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
357
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
358 err = 0;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
359 }
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
360
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
361 } else {
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
362 err = 0;
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
363 }
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
364
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
365 ngx_gettimeofday(&tv);
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
366 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
367
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
368 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
369 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
370
261
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
371 if (err) {
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
372 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
373 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
374 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
375 return NGX_ERROR;
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
376 }
60
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
377
316
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
378 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
379 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
380
305
4b1a3a4acc60 nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
381 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
382 "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
383 }
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
384
305
4b1a3a4acc60 nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
385 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
386 "rtsig 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
387
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
388 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
389
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
390 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
391
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
392 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
393 return NGX_OK;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
394 }
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
395
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
396 /* 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
397
247
008276b9e061 nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 246
diff changeset
398 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
399
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
400 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
401
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
402 if (si.si_band & POLLIN) {
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
403 c->read->returned_instance = instance;
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
404 }
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
405
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
406 if (si.si_band & POLLOUT) {
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
407 c->write->returned_instance = instance;
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
408 }
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
409
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
410 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
411
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
412 /*
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
413 * 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
414 * 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
415 */
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
416
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
417 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
418
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
419 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
420 "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
421
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
422 return NGX_OK;
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
423 }
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
424
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
425 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
426 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
427 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
428
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
429 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
430 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
431
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
432 } else if (c->read->accept) {
344
e366ba5db8f8 nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 328
diff changeset
433 if (ngx_accept_disabled <= 0) {
323
ba876b26b76d nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
434 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
435 }
316
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
436
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
437 } else {
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
438 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
439 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
440 return NGX_ERROR;
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
441 }
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
442
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
443 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
444
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
445 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
446 }
247
008276b9e061 nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 246
diff changeset
447 }
008276b9e061 nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 246
diff changeset
448 }
008276b9e061 nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 246
diff changeset
449
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
450 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
451 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
452 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
453
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
454 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
455 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
456
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
457 } else {
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
458
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
459 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
460 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
461 return NGX_ERROR;
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
462 }
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
463
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
464 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
465
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
466 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
467 }
60
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
468 }
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
469 }
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
470
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
471 } 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
472 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
473
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
474 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
475 "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
476
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
477 /* 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
478
247
008276b9e061 nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 246
diff changeset
479 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
480 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
481 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
482
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
483 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
484 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
485 "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
486 }
008276b9e061 nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 246
diff changeset
487
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
488 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
489 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
490 "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
491 }
261
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
492
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
493 overflow = 1;
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
494 overflow_current = 0;
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
495 ngx_event_actions.process = 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
496
352
694d7ddc3599 nginx-0.0.4-2004-06-11-10:15:08 import
Igor Sysoev <igor@sysoev.ru>
parents: 351
diff changeset
497 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
498
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
499 } 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
500 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
501
305
4b1a3a4acc60 nginx-0.0.3-2004-04-02-19:13:20 import
Igor Sysoev <igor@sysoev.ru>
parents: 262
diff changeset
502 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
503 "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
504
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
505 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
506 }
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
507
316
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
508 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
509
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
510 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
511 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
512 }
60
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
513
316
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
514 if (!ngx_threaded) {
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
515 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
516 }
a0beefedaf94 nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents: 306
diff changeset
517
349
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
518 if (signo == -1) {
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
519 return NGX_AGAIN;
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
520 } else {
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
521 return NGX_OK;
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
522 }
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
523 }
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
524
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
525
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
526 /* TODO: old cylces */
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
527
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
528 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
529 {
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 352
diff changeset
530 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
531 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
532 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
533 ngx_err_t err;
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
534 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
535 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
536
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
537 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
538
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
539 tested = 0;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
540
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
541 for ( ;; ) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
542
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
543 n = 0;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
544 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
545
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
546 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
547 break;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
548 }
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
549
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
550 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
551
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
552 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
553 continue;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
554 }
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
555
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
556 events = 0;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
557
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
558 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
559 events |= POLLIN;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
560 }
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
561
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
562 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
563 events |= POLLOUT;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
564 }
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
565
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
566 if (events == 0) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
567 continue;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
568 }
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
569
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
570 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
571 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
572 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
573 n++;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
574 }
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
575
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
576 if (n == 0) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
577 break;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
578 }
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
579
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
580 for ( ;; ) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
581 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
582
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
583 if (ready == -1) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
584 err = ngx_errno;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
585 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
586 cycle->log, 0,
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
587 "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
588
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
589 if (err == NGX_EINTR) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
590 continue;
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 }
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
593
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
594 break;
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
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
597 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
598 continue;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
599 }
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
600
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
601 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
602 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
603
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
604 if (overflow_list[i].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL)) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
605 tested++;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
606 c->read->ready = 1;
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
607
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
608 if (!ngx_threaded) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
609 c->read->event_handler(c->read);
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
610
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
611 } else {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
612 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
613 return NGX_ERROR;
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 ngx_post_event(c->read);
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
617 c->read->returned_instance = c->read->instance;
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
618
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
619 ngx_mutex_unlock(ngx_posted_events_mutex);
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
620 }
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
621 }
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
622
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
623 if (overflow_list[i].revents & (POLLOUT|POLLERR|POLLHUP|POLLNVAL)) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
624 tested++;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
625 c->write->ready = 1;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
626
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
627 if (!ngx_threaded) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
628 c->write->event_handler(c->write);
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
629
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
630 } else {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
631 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
632 return NGX_ERROR;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
633 }
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
634
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
635 ngx_post_event(c->write);
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
636 c->write->returned_instance = c->write->instance;
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
637
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
638 ngx_mutex_unlock(ngx_posted_events_mutex);
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
639 }
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
640 }
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
641 }
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
642
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
643 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
644
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
645 /*
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
646 * Check the current rt queue length to prevent the new overflow.
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
647 *
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
648 * Learn the /proc/sys/kernel/rtsig-max value because
350
7b96b7f8a6af nginx-0.0.4-2004-06-10-00:03:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 349
diff changeset
649 * it can be changed sisnce the last checking.
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
650 */
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
651
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
652 name[0] = CTL_KERN;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
653 name[1] = KERN_RTSIGMAX;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
654 len = sizeof(rtsig_max);
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
655 if (sysctl(name, sizeof(name), &rtsig_max, &len, NULL, 0) == -1) {
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
656 ngx_log_error(NGX_LOG_ALERT, cycle->log, errno,
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
657 "sysctl(KERN_RTSIGMAX) failed");
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
658 return NGX_ERROR;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
659 }
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
660
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
661 name[0] = CTL_KERN;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
662 name[1] = KERN_RTSIGNR;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
663 len = sizeof(rtsig_nr);
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
664 if (sysctl(name, sizeof(name), &rtsig_nr, &len, NULL, 0) == -1) {
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
665 ngx_log_error(NGX_LOG_ALERT, cycle->log, errno,
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
666 "sysctl(KERN_RTSIGNR) failed");
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
667 return NGX_ERROR;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
668 }
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
669
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
670 /*
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
671 * drain rt signal queue if the /proc/sys/kernel/rtsig-nr is bigger
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
672 * than "/proc/sys/kernel/rtsig-max / rtsig_overflow_threshold"
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
673 */
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
674
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
675 if (rtsig_max / rtscf->overflow_threshold < rtsig_nr) {
350
7b96b7f8a6af nginx-0.0.4-2004-06-10-00:03:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 349
diff changeset
676 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
7b96b7f8a6af nginx-0.0.4-2004-06-10-00:03:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 349
diff changeset
677 "rtsig queue state: %d/%d", rtsig_nr, rtsig_max);
349
a958aa92f9a5 nginx-0.0.4-2004-06-09-20:36:55 import
Igor Sysoev <igor@sysoev.ru>
parents: 348
diff changeset
678 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
679 }
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
680
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
681 tested = 0;
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
682 }
261
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
683 }
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
684
348
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
685 if (!ngx_threaded) {
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
686 ngx_event_process_posted(cycle);
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
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
689 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
690 "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
691
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
692 overflow = 0;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
693 ngx_event_actions.process = ngx_rtsig_process_events;
68ff8000a974 nginx-0.0.3-2004-06-09-11:45:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 346
diff changeset
694
261
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
695 return NGX_OK;
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
696 }
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
697
bdd631bf1a1c nginx-0.0.2-2004-02-18-00:11:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 260
diff changeset
698
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
699 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
700 {
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
701 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
702
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
703 ngx_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
704 NGX_CONF_ERROR);
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
705
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
706 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
707 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
708 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
709 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
710
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
711 return rtscf;
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
712 }
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
713
60
50186b49f2ad nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
714
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
715 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
716 {
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
717 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
718
260
5dacbb4daaf6 nginx-0.0.2-2004-02-17-20:53:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 247
diff changeset
719 /* 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
720 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
721
351
af4c6b45a687 nginx-0.0.4-2004-06-10-22:36:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 350
diff changeset
722 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
723 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
724 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
725
246
6753e8cdaa2c nginx-0.0.1-2004-01-30-20:39:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 60
diff changeset
726 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
727 }