nginxtra 1.0.15.0 → 1.2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/nginxtra +1 -1
- data/lib/nginxtra/action.rb +10 -0
- data/lib/nginxtra/actions/compile.rb +16 -2
- data/lib/nginxtra/actions/start.rb +18 -2
- data/lib/nginxtra/actions/status.rb +1 -10
- data/lib/nginxtra/actions/stop.rb +18 -0
- data/lib/nginxtra/cli.rb +12 -3
- data/lib/nginxtra/config.rb +10 -0
- data/src/nginx/CHANGES +311 -90
- data/src/nginx/CHANGES.ru +315 -88
- data/src/nginx/auto/lib/pcre/conf +22 -5
- data/src/nginx/auto/lib/pcre/make +1 -1
- data/src/nginx/auto/modules +14 -3
- data/src/nginx/auto/options +17 -3
- data/src/nginx/auto/os/freebsd +8 -0
- data/src/nginx/auto/os/linux +5 -4
- data/src/nginx/auto/os/solaris +2 -1
- data/src/nginx/auto/sources +10 -2
- data/src/nginx/auto/summary +2 -0
- data/src/nginx/auto/types/sizeof +2 -1
- data/src/nginx/auto/types/typedef +1 -1
- data/src/nginx/auto/types/uintptr_t +7 -4
- data/src/nginx/auto/unix +82 -21
- data/src/nginx/conf/fastcgi.conf +1 -0
- data/src/nginx/conf/fastcgi_params +1 -0
- data/src/nginx/conf/scgi_params +1 -0
- data/src/nginx/conf/uwsgi_params +1 -0
- data/src/nginx/man/nginx.8 +49 -49
- data/src/nginx/src/core/nginx.c +10 -12
- data/src/nginx/src/core/nginx.h +2 -2
- data/src/nginx/src/core/ngx_buf.c +9 -7
- data/src/nginx/src/core/ngx_buf.h +2 -2
- data/src/nginx/src/core/ngx_conf_file.c +4 -11
- data/src/nginx/src/core/ngx_conf_file.h +1 -1
- data/src/nginx/src/core/ngx_connection.c +52 -1
- data/src/nginx/src/core/ngx_connection.h +6 -0
- data/src/nginx/src/core/ngx_core.h +5 -0
- data/src/nginx/src/core/ngx_cycle.c +1 -1
- data/src/nginx/src/core/ngx_cycle.h +2 -2
- data/src/nginx/src/core/ngx_file.c +1 -1
- data/src/nginx/src/core/ngx_inet.c +11 -8
- data/src/nginx/src/core/ngx_murmurhash.h +1 -1
- data/src/nginx/src/core/ngx_open_file_cache.c +343 -38
- data/src/nginx/src/core/ngx_open_file_cache.h +10 -0
- data/src/nginx/src/core/ngx_output_chain.c +2 -1
- data/src/nginx/src/core/ngx_parse.h +0 -3
- data/src/nginx/src/core/ngx_rbtree.c +1 -2
- data/src/nginx/src/core/ngx_regex.c +263 -5
- data/src/nginx/src/core/ngx_regex.h +6 -2
- data/src/nginx/src/core/ngx_resolver.c +88 -21
- data/src/nginx/src/core/ngx_resolver.h +7 -8
- data/src/nginx/src/core/ngx_shmtx.c +69 -44
- data/src/nginx/src/core/ngx_shmtx.h +12 -1
- data/src/nginx/src/core/ngx_slab.c +3 -3
- data/src/nginx/src/core/ngx_slab.h +1 -1
- data/src/nginx/src/core/ngx_string.c +19 -16
- data/src/nginx/src/core/ngx_times.c +2 -2
- data/src/nginx/src/event/modules/ngx_epoll_module.c +2 -2
- data/src/nginx/src/event/modules/ngx_eventport_module.c +1 -1
- data/src/nginx/src/event/modules/ngx_kqueue_module.c +1 -1
- data/src/nginx/src/event/ngx_event.c +25 -17
- data/src/nginx/src/event/ngx_event_openssl.c +3 -1
- data/src/nginx/src/event/ngx_event_pipe.c +108 -85
- data/src/nginx/src/event/ngx_event_pipe.h +1 -2
- data/src/nginx/src/event/ngx_event_timer.c +2 -3
- data/src/nginx/src/http/modules/ngx_http_access_module.c +9 -4
- data/src/nginx/src/http/modules/ngx_http_browser_module.c +5 -3
- data/src/nginx/src/http/modules/ngx_http_chunked_filter_module.c +1 -1
- data/src/nginx/src/http/modules/ngx_http_degradation_module.c +1 -1
- data/src/nginx/src/http/modules/ngx_http_fastcgi_module.c +144 -22
- data/src/nginx/src/http/modules/ngx_http_flv_module.c +8 -0
- data/src/nginx/src/http/modules/ngx_http_geo_module.c +3 -3
- data/src/nginx/src/http/modules/ngx_http_gzip_filter_module.c +20 -6
- data/src/nginx/src/http/modules/ngx_http_gzip_static_module.c +8 -0
- data/src/nginx/src/http/modules/ngx_http_headers_filter_module.c +23 -27
- data/src/nginx/src/http/modules/ngx_http_image_filter_module.c +1 -3
- data/src/nginx/src/http/modules/ngx_http_index_module.c +24 -0
- data/src/nginx/src/http/modules/ngx_http_limit_conn_module.c +747 -0
- data/src/nginx/src/http/modules/ngx_http_limit_req_module.c +289 -133
- data/src/nginx/src/http/modules/ngx_http_log_module.c +34 -6
- data/src/nginx/src/http/modules/ngx_http_memcached_module.c +19 -3
- data/src/nginx/src/http/modules/ngx_http_mp4_module.c +8 -0
- data/src/nginx/src/http/modules/ngx_http_proxy_module.c +1446 -239
- data/src/nginx/src/http/modules/ngx_http_realip_module.c +4 -10
- data/src/nginx/src/http/modules/ngx_http_scgi_module.c +90 -21
- data/src/nginx/src/http/modules/ngx_http_split_clients_module.c +8 -11
- data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.c +16 -6
- data/src/nginx/src/http/modules/ngx_http_static_module.c +8 -0
- data/src/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +2 -2
- data/src/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +570 -0
- data/src/nginx/src/http/modules/ngx_http_userid_filter_module.c +1 -5
- data/src/nginx/src/http/modules/ngx_http_uwsgi_module.c +77 -26
- data/src/nginx/src/http/modules/ngx_http_xslt_filter_module.c +171 -37
- data/src/nginx/src/http/modules/perl/nginx.pm +2 -1
- data/src/nginx/src/http/modules/perl/nginx.xs +4 -0
- data/src/nginx/src/http/ngx_http.c +8 -1
- data/src/nginx/src/http/ngx_http.h +1 -0
- data/src/nginx/src/http/ngx_http_busy_lock.c +2 -2
- data/src/nginx/src/http/ngx_http_cache.h +12 -1
- data/src/nginx/src/http/ngx_http_copy_filter_module.c +4 -3
- data/src/nginx/src/http/ngx_http_core_module.c +303 -37
- data/src/nginx/src/http/ngx_http_core_module.h +15 -0
- data/src/nginx/src/http/ngx_http_file_cache.c +226 -52
- data/src/nginx/src/http/ngx_http_parse.c +69 -3
- data/src/nginx/src/http/ngx_http_postpone_filter_module.c +4 -4
- data/src/nginx/src/http/ngx_http_request.c +61 -27
- data/src/nginx/src/http/ngx_http_request.h +3 -3
- data/src/nginx/src/http/ngx_http_request_body.c +1 -1
- data/src/nginx/src/http/ngx_http_script.c +6 -0
- data/src/nginx/src/http/ngx_http_upstream.c +200 -47
- data/src/nginx/src/http/ngx_http_upstream.h +20 -1
- data/src/nginx/src/http/ngx_http_upstream_round_robin.c +22 -6
- data/src/nginx/src/http/ngx_http_upstream_round_robin.h +1 -0
- data/src/nginx/src/http/ngx_http_variables.c +123 -4
- data/src/nginx/src/mail/ngx_mail.c +13 -0
- data/src/nginx/src/mail/ngx_mail.h +12 -0
- data/src/nginx/src/mail/ngx_mail_core_module.c +100 -15
- data/src/nginx/src/os/unix/ngx_daemon.c +2 -1
- data/src/nginx/src/os/unix/ngx_darwin.h +3 -0
- data/src/nginx/src/os/unix/ngx_darwin_config.h +1 -0
- data/src/nginx/src/os/unix/ngx_darwin_init.c +30 -0
- data/src/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +11 -5
- data/src/nginx/src/os/unix/ngx_errno.h +5 -0
- data/src/nginx/src/os/unix/ngx_files.h +50 -1
- data/src/nginx/src/os/unix/ngx_freebsd.h +2 -1
- data/src/nginx/src/os/unix/ngx_freebsd_config.h +2 -0
- data/src/nginx/src/os/unix/ngx_freebsd_init.c +4 -3
- data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +2 -2
- data/src/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +12 -6
- data/src/nginx/src/os/unix/ngx_gcc_atomic_sparc64.h +1 -1
- data/src/nginx/src/os/unix/ngx_linux_config.h +1 -0
- data/src/nginx/src/os/unix/ngx_linux_sendfile_chain.c +6 -4
- data/src/nginx/src/os/unix/ngx_os.h +0 -1
- data/src/nginx/src/os/unix/ngx_posix_config.h +3 -0
- data/src/nginx/src/os/unix/ngx_process.c +50 -11
- data/src/nginx/src/os/unix/ngx_process.h +1 -0
- data/src/nginx/src/os/unix/ngx_process_cycle.c +6 -15
- data/src/nginx/src/os/unix/ngx_readv_chain.c +8 -0
- data/src/nginx/src/os/unix/ngx_setaffinity.c +69 -0
- data/src/nginx/src/os/unix/ngx_setaffinity.h +23 -0
- data/src/nginx/src/os/unix/ngx_setproctitle.c +1 -1
- data/src/nginx/src/os/unix/ngx_solaris_config.h +2 -0
- data/src/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +11 -3
- data/src/nginx/src/os/unix/ngx_writev_chain.c +7 -3
- metadata +7 -4
- data/src/nginx/src/http/modules/ngx_http_limit_zone_module.c +0 -553
@@ -78,16 +78,16 @@ typedef struct {
|
|
78
78
|
typedef struct {
|
79
79
|
/* has to be pointer because of "incomplete type" */
|
80
80
|
ngx_event_t *event;
|
81
|
-
|
82
|
-
/* TODO: DNS peers balancer */
|
83
|
-
/* STUB */
|
84
|
-
ngx_udp_connection_t *udp_connection;
|
85
|
-
|
81
|
+
void *dummy;
|
86
82
|
ngx_log_t *log;
|
87
83
|
|
88
84
|
/* ident must be after 3 pointers */
|
89
85
|
ngx_int_t ident;
|
90
86
|
|
87
|
+
/* simple round robin DNS peers balancer */
|
88
|
+
ngx_array_t udp_connections;
|
89
|
+
ngx_uint_t last_connection;
|
90
|
+
|
91
91
|
ngx_rbtree_t name_rbtree;
|
92
92
|
ngx_rbtree_node_t name_sentinel;
|
93
93
|
|
@@ -124,8 +124,6 @@ struct ngx_resolver_ctx_s {
|
|
124
124
|
in_addr_t *addrs;
|
125
125
|
in_addr_t addr;
|
126
126
|
|
127
|
-
/* TODO: DNS peers balancer ctx */
|
128
|
-
|
129
127
|
ngx_resolver_handler_pt handler;
|
130
128
|
void *data;
|
131
129
|
ngx_msec_t timeout;
|
@@ -136,7 +134,8 @@ struct ngx_resolver_ctx_s {
|
|
136
134
|
};
|
137
135
|
|
138
136
|
|
139
|
-
ngx_resolver_t *ngx_resolver_create(ngx_conf_t *cf,
|
137
|
+
ngx_resolver_t *ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names,
|
138
|
+
ngx_uint_t n);
|
140
139
|
ngx_resolver_ctx_t *ngx_resolve_start(ngx_resolver_t *r,
|
141
140
|
ngx_resolver_ctx_t *temp);
|
142
141
|
ngx_int_t ngx_resolve_name(ngx_resolver_ctx_t *ctx);
|
@@ -12,10 +12,13 @@
|
|
12
12
|
#if (NGX_HAVE_ATOMIC_OPS)
|
13
13
|
|
14
14
|
|
15
|
+
static void ngx_shmtx_wakeup(ngx_shmtx_t *mtx);
|
16
|
+
|
17
|
+
|
15
18
|
ngx_int_t
|
16
|
-
ngx_shmtx_create(ngx_shmtx_t *mtx,
|
19
|
+
ngx_shmtx_create(ngx_shmtx_t *mtx, ngx_shmtx_sh_t *addr, u_char *name)
|
17
20
|
{
|
18
|
-
mtx->lock = addr;
|
21
|
+
mtx->lock = &addr->lock;
|
19
22
|
|
20
23
|
if (mtx->spin == (ngx_uint_t) -1) {
|
21
24
|
return NGX_OK;
|
@@ -25,6 +28,8 @@ ngx_shmtx_create(ngx_shmtx_t *mtx, void *addr, u_char *name)
|
|
25
28
|
|
26
29
|
#if (NGX_HAVE_POSIX_SEM)
|
27
30
|
|
31
|
+
mtx->wait = &addr->wait;
|
32
|
+
|
28
33
|
if (sem_init(&mtx->sem, 1, 0) == -1) {
|
29
34
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_errno,
|
30
35
|
"sem_init() failed");
|
@@ -57,12 +62,7 @@ ngx_shmtx_destory(ngx_shmtx_t *mtx)
|
|
57
62
|
ngx_uint_t
|
58
63
|
ngx_shmtx_trylock(ngx_shmtx_t *mtx)
|
59
64
|
{
|
60
|
-
|
61
|
-
|
62
|
-
val = *mtx->lock;
|
63
|
-
|
64
|
-
return ((val & 0x80000000) == 0
|
65
|
-
&& ngx_atomic_cmp_set(mtx->lock, val, val | 0x80000000));
|
65
|
+
return (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid));
|
66
66
|
}
|
67
67
|
|
68
68
|
|
@@ -70,17 +70,12 @@ void
|
|
70
70
|
ngx_shmtx_lock(ngx_shmtx_t *mtx)
|
71
71
|
{
|
72
72
|
ngx_uint_t i, n;
|
73
|
-
ngx_atomic_uint_t val;
|
74
73
|
|
75
74
|
ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, "shmtx lock");
|
76
75
|
|
77
76
|
for ( ;; ) {
|
78
77
|
|
79
|
-
|
80
|
-
|
81
|
-
if ((val & 0x80000000) == 0
|
82
|
-
&& ngx_atomic_cmp_set(mtx->lock, val, val | 0x80000000))
|
83
|
-
{
|
78
|
+
if (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid)) {
|
84
79
|
return;
|
85
80
|
}
|
86
81
|
|
@@ -92,10 +87,8 @@ ngx_shmtx_lock(ngx_shmtx_t *mtx)
|
|
92
87
|
ngx_cpu_pause();
|
93
88
|
}
|
94
89
|
|
95
|
-
|
96
|
-
|
97
|
-
if ((val & 0x80000000) == 0
|
98
|
-
&& ngx_atomic_cmp_set(mtx->lock, val, val | 0x80000000))
|
90
|
+
if (*mtx->lock == 0
|
91
|
+
&& ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid))
|
99
92
|
{
|
100
93
|
return;
|
101
94
|
}
|
@@ -105,24 +98,24 @@ ngx_shmtx_lock(ngx_shmtx_t *mtx)
|
|
105
98
|
#if (NGX_HAVE_POSIX_SEM)
|
106
99
|
|
107
100
|
if (mtx->semaphore) {
|
108
|
-
|
101
|
+
(void) ngx_atomic_fetch_add(mtx->wait, 1);
|
109
102
|
|
110
|
-
if ((
|
111
|
-
|
112
|
-
|
113
|
-
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
|
114
|
-
"shmtx wait %XA", val);
|
103
|
+
if (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid)) {
|
104
|
+
return;
|
105
|
+
}
|
115
106
|
|
116
|
-
|
117
|
-
|
107
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
|
108
|
+
"shmtx wait %uA", *mtx->wait);
|
118
109
|
|
119
|
-
|
110
|
+
while (sem_wait(&mtx->sem) == -1) {
|
111
|
+
ngx_err_t err;
|
120
112
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
113
|
+
err = ngx_errno;
|
114
|
+
|
115
|
+
if (err != NGX_EINTR) {
|
116
|
+
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, err,
|
117
|
+
"sem_wait() failed while waiting on shmtx");
|
118
|
+
break;
|
126
119
|
}
|
127
120
|
|
128
121
|
ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
|
@@ -142,31 +135,56 @@ ngx_shmtx_lock(ngx_shmtx_t *mtx)
|
|
142
135
|
void
|
143
136
|
ngx_shmtx_unlock(ngx_shmtx_t *mtx)
|
144
137
|
{
|
145
|
-
ngx_atomic_uint_t val, old, wait;
|
146
|
-
|
147
138
|
if (mtx->spin != (ngx_uint_t) -1) {
|
148
139
|
ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, "shmtx unlock");
|
149
140
|
}
|
150
141
|
|
151
|
-
|
142
|
+
if (ngx_atomic_cmp_set(mtx->lock, ngx_pid, 0)) {
|
143
|
+
ngx_shmtx_wakeup(mtx);
|
144
|
+
}
|
145
|
+
}
|
152
146
|
|
153
|
-
old = *mtx->lock;
|
154
|
-
wait = old & 0x7fffffff;
|
155
|
-
val = wait ? wait - 1 : 0;
|
156
147
|
|
157
|
-
|
158
|
-
|
159
|
-
|
148
|
+
ngx_uint_t
|
149
|
+
ngx_shmtx_force_unlock(ngx_shmtx_t *mtx, ngx_pid_t pid)
|
150
|
+
{
|
151
|
+
ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
|
152
|
+
"shmtx forced unlock");
|
153
|
+
|
154
|
+
if (ngx_atomic_cmp_set(mtx->lock, pid, 0)) {
|
155
|
+
ngx_shmtx_wakeup(mtx);
|
156
|
+
return 1;
|
160
157
|
}
|
161
158
|
|
159
|
+
return 0;
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
static void
|
164
|
+
ngx_shmtx_wakeup(ngx_shmtx_t *mtx)
|
165
|
+
{
|
162
166
|
#if (NGX_HAVE_POSIX_SEM)
|
167
|
+
ngx_atomic_uint_t wait;
|
163
168
|
|
164
|
-
if (
|
169
|
+
if (!mtx->semaphore) {
|
165
170
|
return;
|
166
171
|
}
|
167
172
|
|
173
|
+
for ( ;; ) {
|
174
|
+
|
175
|
+
wait = *mtx->wait;
|
176
|
+
|
177
|
+
if (wait == 0) {
|
178
|
+
return;
|
179
|
+
}
|
180
|
+
|
181
|
+
if (ngx_atomic_cmp_set(mtx->wait, wait, wait - 1)) {
|
182
|
+
break;
|
183
|
+
}
|
184
|
+
}
|
185
|
+
|
168
186
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
|
169
|
-
"shmtx wake %
|
187
|
+
"shmtx wake %uA", wait);
|
170
188
|
|
171
189
|
if (sem_post(&mtx->sem) == -1) {
|
172
190
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_errno,
|
@@ -181,7 +199,7 @@ ngx_shmtx_unlock(ngx_shmtx_t *mtx)
|
|
181
199
|
|
182
200
|
|
183
201
|
ngx_int_t
|
184
|
-
ngx_shmtx_create(ngx_shmtx_t *mtx,
|
202
|
+
ngx_shmtx_create(ngx_shmtx_t *mtx, ngx_shmtx_sh_t *addr, u_char *name)
|
185
203
|
{
|
186
204
|
if (mtx->name) {
|
187
205
|
|
@@ -281,4 +299,11 @@ ngx_shmtx_unlock(ngx_shmtx_t *mtx)
|
|
281
299
|
ngx_log_abort(err, ngx_unlock_fd_n " %s failed", mtx->name);
|
282
300
|
}
|
283
301
|
|
302
|
+
|
303
|
+
ngx_uint_t
|
304
|
+
ngx_shmtx_force_unlock(ngx_shmtx_t *mtx, ngx_pid_t pid)
|
305
|
+
{
|
306
|
+
return 0;
|
307
|
+
}
|
308
|
+
|
284
309
|
#endif
|
@@ -13,10 +13,19 @@
|
|
13
13
|
#include <ngx_core.h>
|
14
14
|
|
15
15
|
|
16
|
+
typedef struct {
|
17
|
+
ngx_atomic_t lock;
|
18
|
+
#if (NGX_HAVE_POSIX_SEM)
|
19
|
+
ngx_atomic_t wait;
|
20
|
+
#endif
|
21
|
+
} ngx_shmtx_sh_t;
|
22
|
+
|
23
|
+
|
16
24
|
typedef struct {
|
17
25
|
#if (NGX_HAVE_ATOMIC_OPS)
|
18
26
|
ngx_atomic_t *lock;
|
19
27
|
#if (NGX_HAVE_POSIX_SEM)
|
28
|
+
ngx_atomic_t *wait;
|
20
29
|
ngx_uint_t semaphore;
|
21
30
|
sem_t sem;
|
22
31
|
#endif
|
@@ -28,11 +37,13 @@ typedef struct {
|
|
28
37
|
} ngx_shmtx_t;
|
29
38
|
|
30
39
|
|
31
|
-
ngx_int_t ngx_shmtx_create(ngx_shmtx_t *mtx,
|
40
|
+
ngx_int_t ngx_shmtx_create(ngx_shmtx_t *mtx, ngx_shmtx_sh_t *addr,
|
41
|
+
u_char *name);
|
32
42
|
void ngx_shmtx_destory(ngx_shmtx_t *mtx);
|
33
43
|
ngx_uint_t ngx_shmtx_trylock(ngx_shmtx_t *mtx);
|
34
44
|
void ngx_shmtx_lock(ngx_shmtx_t *mtx);
|
35
45
|
void ngx_shmtx_unlock(ngx_shmtx_t *mtx);
|
46
|
+
ngx_uint_t ngx_shmtx_force_unlock(ngx_shmtx_t *mtx, ngx_pid_t pid);
|
36
47
|
|
37
48
|
|
38
49
|
#endif /* _NGX_SHMTX_H_INCLUDED_ */
|
@@ -43,14 +43,14 @@
|
|
43
43
|
|
44
44
|
#if (NGX_DEBUG_MALLOC)
|
45
45
|
|
46
|
-
#define ngx_slab_junk(p, size) ngx_memset(p,
|
46
|
+
#define ngx_slab_junk(p, size) ngx_memset(p, 0xA5, size)
|
47
47
|
|
48
48
|
#else
|
49
49
|
|
50
|
-
#if (
|
50
|
+
#if (NGX_HAVE_DEBUG_MALLOC)
|
51
51
|
|
52
52
|
#define ngx_slab_junk(p, size) \
|
53
|
-
if (
|
53
|
+
if (ngx_debug_malloc) ngx_memset(p, 0xA5, size)
|
54
54
|
|
55
55
|
#else
|
56
56
|
|
@@ -146,12 +146,12 @@ ngx_vslprintf(u_char *buf, u_char *last, const char *fmt, va_list args)
|
|
146
146
|
{
|
147
147
|
u_char *p, zero;
|
148
148
|
int d;
|
149
|
-
double f
|
149
|
+
double f;
|
150
150
|
size_t len, slen;
|
151
151
|
int64_t i64;
|
152
|
-
uint64_t ui64;
|
152
|
+
uint64_t ui64, frac;
|
153
153
|
ngx_msec_t ms;
|
154
|
-
ngx_uint_t width, sign, hex, max_width, frac_width, n;
|
154
|
+
ngx_uint_t width, sign, hex, max_width, frac_width, scale, n;
|
155
155
|
ngx_str_t *v;
|
156
156
|
ngx_variable_value_t *vv;
|
157
157
|
|
@@ -365,28 +365,31 @@ ngx_vslprintf(u_char *buf, u_char *last, const char *fmt, va_list args)
|
|
365
365
|
}
|
366
366
|
|
367
367
|
ui64 = (int64_t) f;
|
368
|
-
|
369
|
-
buf = ngx_sprintf_num(buf, last, ui64, zero, 0, width);
|
368
|
+
frac = 0;
|
370
369
|
|
371
370
|
if (frac_width) {
|
372
371
|
|
373
|
-
|
374
|
-
|
372
|
+
scale = 1;
|
373
|
+
for (n = frac_width; n; n--) {
|
374
|
+
scale *= 10;
|
375
375
|
}
|
376
376
|
|
377
|
-
|
377
|
+
frac = (uint64_t) ((f - (double) ui64) * scale + 0.5);
|
378
378
|
|
379
|
-
|
380
|
-
|
379
|
+
if (frac == scale) {
|
380
|
+
ui64++;
|
381
|
+
frac = 0;
|
381
382
|
}
|
383
|
+
}
|
382
384
|
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
385
|
+
buf = ngx_sprintf_num(buf, last, ui64, zero, 0, width);
|
386
|
+
|
387
|
+
if (frac_width) {
|
388
|
+
if (buf < last) {
|
389
|
+
*buf++ = '.';
|
390
|
+
}
|
388
391
|
|
389
|
-
buf = ngx_sprintf_num(buf, last,
|
392
|
+
buf = ngx_sprintf_num(buf, last, frac, '0', 0, frac_width);
|
390
393
|
}
|
391
394
|
|
392
395
|
fmt++;
|
@@ -33,7 +33,7 @@ volatile ngx_str_t ngx_cached_http_log_iso8601;
|
|
33
33
|
#if !(NGX_WIN32)
|
34
34
|
|
35
35
|
/*
|
36
|
-
*
|
36
|
+
* localtime() and localtime_r() are not Async-Signal-Safe functions, therefore,
|
37
37
|
* they must not be called by a signal handler, so we use the cached
|
38
38
|
* GMT offset value. Fortunately the value is changed only two times a year.
|
39
39
|
*/
|
@@ -308,7 +308,7 @@ ngx_gmtime(time_t t, ngx_tm_t *tp)
|
|
308
308
|
/*
|
309
309
|
* The "days" should be adjusted to 1 only, however, some March 1st's go
|
310
310
|
* to previous year, so we adjust them to 2. This causes also shift of the
|
311
|
-
* last
|
311
|
+
* last February days to next year, but we catch the case when "yday"
|
312
312
|
* becomes negative.
|
313
313
|
*/
|
314
314
|
|
@@ -445,7 +445,7 @@ ngx_epoll_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
|
|
445
445
|
|
446
446
|
/*
|
447
447
|
* when the file descriptor is closed, the epoll automatically deletes
|
448
|
-
* it from its queue, so we do not need to delete
|
448
|
+
* it from its queue, so we do not need to delete explicitly the event
|
449
449
|
* before the closing the file descriptor
|
450
450
|
*/
|
451
451
|
|
@@ -524,7 +524,7 @@ ngx_epoll_del_connection(ngx_connection_t *c, ngx_uint_t flags)
|
|
524
524
|
|
525
525
|
/*
|
526
526
|
* when the file descriptor is closed the epoll automatically deletes
|
527
|
-
* it from its queue so we do not need to delete
|
527
|
+
* it from its queue so we do not need to delete explicitly the event
|
528
528
|
* before the closing the file descriptor
|
529
529
|
*/
|
530
530
|
|
@@ -322,7 +322,7 @@ ngx_eventport_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
|
|
322
322
|
|
323
323
|
/*
|
324
324
|
* when the file descriptor is closed, the event port automatically
|
325
|
-
* dissociates it from the port, so we do not need to dissociate
|
325
|
+
* dissociates it from the port, so we do not need to dissociate explicitly
|
326
326
|
* the event before the closing the file descriptor
|
327
327
|
*/
|
328
328
|
|
@@ -377,7 +377,7 @@ ngx_kqueue_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
|
|
377
377
|
|
378
378
|
/*
|
379
379
|
* when the file descriptor is closed the kqueue automatically deletes
|
380
|
-
* its filters so we do not need to delete
|
380
|
+
* its filters so we do not need to delete explicitly the event
|
381
381
|
* before the closing the file descriptor.
|
382
382
|
*/
|
383
383
|
|
@@ -21,6 +21,7 @@ extern ngx_module_t ngx_rtsig_module;
|
|
21
21
|
extern ngx_module_t ngx_select_module;
|
22
22
|
|
23
23
|
|
24
|
+
static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf);
|
24
25
|
static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle);
|
25
26
|
static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle);
|
26
27
|
static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
@@ -31,8 +32,8 @@ static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
|
31
32
|
static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd,
|
32
33
|
void *conf);
|
33
34
|
|
34
|
-
static void *
|
35
|
-
static char *
|
35
|
+
static void *ngx_event_core_create_conf(ngx_cycle_t *cycle);
|
36
|
+
static char *ngx_event_core_init_conf(ngx_cycle_t *cycle, void *conf);
|
36
37
|
|
37
38
|
|
38
39
|
static ngx_uint_t ngx_timer_resolution;
|
@@ -93,7 +94,7 @@ static ngx_command_t ngx_events_commands[] = {
|
|
93
94
|
static ngx_core_module_t ngx_events_module_ctx = {
|
94
95
|
ngx_string("events"),
|
95
96
|
NULL,
|
96
|
-
|
97
|
+
ngx_event_init_conf
|
97
98
|
};
|
98
99
|
|
99
100
|
|
@@ -173,8 +174,8 @@ static ngx_command_t ngx_event_core_commands[] = {
|
|
173
174
|
|
174
175
|
ngx_event_module_t ngx_event_core_module_ctx = {
|
175
176
|
&event_core_name,
|
176
|
-
|
177
|
-
|
177
|
+
ngx_event_core_create_conf, /* create configuration */
|
178
|
+
ngx_event_core_init_conf, /* init configuration */
|
178
179
|
|
179
180
|
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
|
180
181
|
};
|
@@ -423,6 +424,19 @@ ngx_handle_write_event(ngx_event_t *wev, size_t lowat)
|
|
423
424
|
}
|
424
425
|
|
425
426
|
|
427
|
+
static char *
|
428
|
+
ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
429
|
+
{
|
430
|
+
if (ngx_get_conf(cycle->conf_ctx, ngx_events_module) == NULL) {
|
431
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
432
|
+
"no \"events\" section in configuration");
|
433
|
+
return NGX_CONF_ERROR;
|
434
|
+
}
|
435
|
+
|
436
|
+
return NGX_CONF_OK;
|
437
|
+
}
|
438
|
+
|
439
|
+
|
426
440
|
static ngx_int_t
|
427
441
|
ngx_event_module_init(ngx_cycle_t *cycle)
|
428
442
|
{
|
@@ -435,13 +449,6 @@ ngx_event_module_init(ngx_cycle_t *cycle)
|
|
435
449
|
ngx_event_conf_t *ecf;
|
436
450
|
|
437
451
|
cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module);
|
438
|
-
|
439
|
-
if (cf == NULL) {
|
440
|
-
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
441
|
-
"no \"events\" section in configuration");
|
442
|
-
return NGX_ERROR;
|
443
|
-
}
|
444
|
-
|
445
452
|
ecf = (*cf)[ngx_event_core_module.ctx_index];
|
446
453
|
|
447
454
|
if (!ngx_test_config && ngx_process <= NGX_PROCESS_MASTER) {
|
@@ -471,7 +478,7 @@ ngx_event_module_init(ngx_cycle_t *cycle)
|
|
471
478
|
(ngx_int_t) rlmt.rlim_cur : ccf->rlimit_nofile;
|
472
479
|
|
473
480
|
ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
|
474
|
-
"%ui worker_connections
|
481
|
+
"%ui worker_connections exceed "
|
475
482
|
"open file resource limit: %i",
|
476
483
|
ecf->connections, limit);
|
477
484
|
}
|
@@ -489,7 +496,7 @@ ngx_event_module_init(ngx_cycle_t *cycle)
|
|
489
496
|
}
|
490
497
|
|
491
498
|
|
492
|
-
/* cl should be equal or
|
499
|
+
/* cl should be equal to or greater than cache line size */
|
493
500
|
|
494
501
|
cl = 128;
|
495
502
|
|
@@ -522,7 +529,8 @@ ngx_event_module_init(ngx_cycle_t *cycle)
|
|
522
529
|
ngx_accept_mutex_ptr = (ngx_atomic_t *) shared;
|
523
530
|
ngx_accept_mutex.spin = (ngx_uint_t) -1;
|
524
531
|
|
525
|
-
if (ngx_shmtx_create(&ngx_accept_mutex, shared,
|
532
|
+
if (ngx_shmtx_create(&ngx_accept_mutex, (ngx_shmtx_sh_t *) shared,
|
533
|
+
cycle->lock_file.data)
|
526
534
|
!= NGX_OK)
|
527
535
|
{
|
528
536
|
return NGX_ERROR;
|
@@ -1115,7 +1123,7 @@ ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
1115
1123
|
|
1116
1124
|
|
1117
1125
|
static void *
|
1118
|
-
|
1126
|
+
ngx_event_core_create_conf(ngx_cycle_t *cycle)
|
1119
1127
|
{
|
1120
1128
|
ngx_event_conf_t *ecf;
|
1121
1129
|
|
@@ -1146,7 +1154,7 @@ ngx_event_create_conf(ngx_cycle_t *cycle)
|
|
1146
1154
|
|
1147
1155
|
|
1148
1156
|
static char *
|
1149
|
-
|
1157
|
+
ngx_event_core_init_conf(ngx_cycle_t *cycle, void *conf)
|
1150
1158
|
{
|
1151
1159
|
ngx_event_conf_t *ecf = conf;
|
1152
1160
|
|