nginxtra 1.6.3.9 → 1.8.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/nginxtra +1 -1
- data/bin/nginxtra_rails +1 -1
- data/lib/nginxtra/version.rb +1 -1
- data/vendor/nginx/CHANGES +358 -14
- data/vendor/nginx/CHANGES.ru +372 -18
- data/vendor/nginx/LICENSE +2 -2
- data/vendor/nginx/auto/cc/clang +5 -0
- data/vendor/nginx/auto/cc/gcc +5 -0
- data/vendor/nginx/auto/lib/google-perftools/conf +1 -1
- data/vendor/nginx/auto/lib/openssl/make +0 -5
- data/vendor/nginx/auto/lib/perl/conf +9 -1
- data/vendor/nginx/auto/make +1 -1
- data/vendor/nginx/auto/modules +11 -0
- data/vendor/nginx/auto/options +10 -2
- data/vendor/nginx/auto/os/darwin +0 -1
- data/vendor/nginx/auto/os/freebsd +6 -23
- data/vendor/nginx/auto/sources +16 -14
- data/vendor/nginx/auto/summary +3 -24
- data/vendor/nginx/auto/threads +20 -0
- data/vendor/nginx/auto/types/sizeof +2 -12
- data/vendor/nginx/auto/unix +50 -6
- data/vendor/nginx/configure +5 -0
- data/vendor/nginx/contrib/vim/syntax/nginx.vim +183 -50
- data/vendor/nginx/src/core/nginx.c +21 -9
- data/vendor/nginx/src/core/nginx.h +8 -2
- data/vendor/nginx/src/core/ngx_buf.c +88 -0
- data/vendor/nginx/src/core/ngx_buf.h +15 -1
- data/vendor/nginx/src/core/ngx_conf_file.c +4 -1
- data/vendor/nginx/src/core/ngx_connection.c +25 -66
- data/vendor/nginx/src/core/ngx_connection.h +1 -3
- data/vendor/nginx/src/core/ngx_core.h +11 -3
- data/vendor/nginx/src/core/ngx_crypt.c +1 -1
- data/vendor/nginx/src/core/ngx_cycle.c +7 -1
- data/vendor/nginx/src/core/ngx_cycle.h +6 -2
- data/vendor/nginx/src/core/ngx_file.c +13 -5
- data/vendor/nginx/src/core/ngx_file.h +6 -0
- data/vendor/nginx/src/core/ngx_log.c +215 -21
- data/vendor/nginx/src/core/ngx_log.h +9 -1
- data/vendor/nginx/src/core/ngx_output_chain.c +104 -15
- data/vendor/nginx/src/core/ngx_palloc.c +3 -7
- data/vendor/nginx/src/core/ngx_rbtree.c +2 -4
- data/vendor/nginx/src/core/ngx_rbtree.h +2 -4
- data/vendor/nginx/src/core/ngx_regex.c +14 -6
- data/vendor/nginx/src/core/ngx_resolver.c +16 -23
- data/vendor/nginx/src/core/ngx_resolver.h +8 -7
- data/vendor/nginx/src/core/ngx_shmtx.c +1 -1
- data/vendor/nginx/src/core/ngx_slab.c +89 -2
- data/vendor/nginx/src/core/ngx_slab.h +3 -0
- data/vendor/nginx/src/core/ngx_string.c +58 -2
- data/vendor/nginx/src/core/ngx_string.h +1 -0
- data/vendor/nginx/src/core/ngx_syslog.c +374 -0
- data/vendor/nginx/src/core/ngx_syslog.h +30 -0
- data/vendor/nginx/src/core/ngx_thread_pool.c +630 -0
- data/vendor/nginx/src/core/ngx_thread_pool.h +36 -0
- data/vendor/nginx/src/core/ngx_times.c +19 -2
- data/vendor/nginx/src/core/ngx_times.h +1 -0
- data/vendor/nginx/src/event/modules/ngx_aio_module.c +1 -1
- data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +9 -24
- data/vendor/nginx/src/event/modules/ngx_epoll_module.c +152 -28
- data/vendor/nginx/src/event/modules/ngx_eventport_module.c +43 -25
- data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +86 -156
- data/vendor/nginx/src/event/modules/ngx_poll_module.c +21 -37
- data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +15 -27
- data/vendor/nginx/src/event/modules/ngx_select_module.c +10 -12
- data/vendor/nginx/src/event/modules/ngx_win32_select_module.c +7 -9
- data/vendor/nginx/src/event/ngx_event.c +5 -33
- data/vendor/nginx/src/event/ngx_event.h +15 -50
- data/vendor/nginx/src/event/ngx_event_accept.c +11 -10
- data/vendor/nginx/src/event/ngx_event_connect.c +0 -11
- data/vendor/nginx/src/event/ngx_event_connect.h +1 -4
- data/vendor/nginx/src/event/ngx_event_openssl.c +622 -38
- data/vendor/nginx/src/event/ngx_event_openssl.h +20 -2
- data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +5 -1
- data/vendor/nginx/src/event/ngx_event_pipe.c +45 -19
- data/vendor/nginx/src/event/ngx_event_pipe.h +3 -0
- data/vendor/nginx/src/event/ngx_event_posted.c +7 -145
- data/vendor/nginx/src/event/ngx_event_posted.h +12 -39
- data/vendor/nginx/src/event/ngx_event_timer.c +50 -70
- data/vendor/nginx/src/event/ngx_event_timer.h +2 -14
- data/vendor/nginx/src/http/modules/ngx_http_addition_filter_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_autoindex_module.c +416 -71
- data/vendor/nginx/src/http/modules/ngx_http_charset_filter_module.c +19 -15
- data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +16 -4
- data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +601 -134
- data/vendor/nginx/src/http/modules/ngx_http_geo_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_geoip_module.c +9 -3
- data/vendor/nginx/src/http/modules/ngx_http_gunzip_filter_module.c +9 -3
- data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +9 -3
- data/vendor/nginx/src/http/modules/ngx_http_gzip_static_module.c +0 -2
- data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +197 -91
- data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +1 -0
- data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +65 -162
- data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +53 -67
- data/vendor/nginx/src/http/modules/ngx_http_log_module.c +128 -23
- data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +25 -6
- data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +39 -13
- data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +697 -141
- data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +5 -1
- data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +282 -125
- data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +4 -1
- data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +44 -1
- data/vendor/nginx/src/http/modules/ngx_http_ssl_module.h +2 -0
- data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +10 -8
- data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +18 -3
- data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +641 -0
- data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +3 -21
- data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +0 -5
- data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +449 -125
- data/vendor/nginx/src/http/modules/ngx_http_xslt_filter_module.c +4 -2
- data/vendor/nginx/src/http/modules/perl/ngx_http_perl_module.c +2 -1
- data/vendor/nginx/src/http/ngx_http.c +10 -5
- data/vendor/nginx/src/http/ngx_http.h +4 -4
- data/vendor/nginx/src/http/ngx_http_cache.h +26 -1
- data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +109 -68
- data/vendor/nginx/src/http/ngx_http_core_module.c +191 -46
- data/vendor/nginx/src/http/ngx_http_core_module.h +16 -4
- data/vendor/nginx/src/http/ngx_http_file_cache.c +584 -67
- data/vendor/nginx/src/http/ngx_http_parse.c +55 -4
- data/vendor/nginx/src/http/ngx_http_request.c +14 -6
- data/vendor/nginx/src/http/ngx_http_request.h +12 -4
- data/vendor/nginx/src/http/ngx_http_request_body.c +114 -28
- data/vendor/nginx/src/http/ngx_http_spdy.c +383 -229
- data/vendor/nginx/src/http/ngx_http_spdy.h +8 -5
- data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +12 -4
- data/vendor/nginx/src/http/ngx_http_special_response.c +2 -2
- data/vendor/nginx/src/http/ngx_http_upstream.c +808 -132
- data/vendor/nginx/src/http/ngx_http_upstream.h +33 -3
- data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +72 -65
- data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +1 -2
- data/vendor/nginx/src/http/ngx_http_variables.c +47 -3
- data/vendor/nginx/src/http/ngx_http_write_filter_module.c +15 -6
- data/vendor/nginx/src/mail/ngx_mail.c +2 -3
- data/vendor/nginx/src/mail/ngx_mail.h +2 -0
- data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +140 -11
- data/vendor/nginx/src/mail/ngx_mail_core_module.c +3 -3
- data/vendor/nginx/src/mail/ngx_mail_handler.c +79 -2
- data/vendor/nginx/src/mail/ngx_mail_imap_module.c +3 -1
- data/vendor/nginx/src/mail/ngx_mail_pop3_module.c +3 -1
- data/vendor/nginx/src/mail/ngx_mail_smtp_module.c +3 -1
- data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +125 -1
- data/vendor/nginx/src/mail/ngx_mail_ssl_module.h +8 -0
- data/vendor/nginx/src/misc/ngx_cpp_test_module.cpp +1 -1
- data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +1 -1
- data/vendor/nginx/src/os/unix/ngx_channel.c +0 -7
- data/vendor/nginx/src/os/unix/ngx_darwin_config.h +0 -3
- data/vendor/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +44 -208
- data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +25 -17
- data/vendor/nginx/src/os/unix/ngx_files.c +109 -0
- data/vendor/nginx/src/os/unix/ngx_files.h +6 -0
- data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +0 -6
- data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +78 -206
- data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +25 -14
- data/vendor/nginx/src/os/unix/ngx_linux_config.h +4 -1
- data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +235 -194
- data/vendor/nginx/src/os/unix/ngx_os.h +25 -3
- data/vendor/nginx/src/os/unix/ngx_posix_init.c +4 -2
- data/vendor/nginx/src/os/unix/ngx_process_cycle.c +13 -195
- data/vendor/nginx/src/os/unix/ngx_process_cycle.h +0 -1
- data/vendor/nginx/src/os/unix/ngx_readv_chain.c +27 -108
- data/vendor/nginx/src/os/unix/ngx_setproctitle.h +2 -2
- data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +12 -67
- data/vendor/nginx/src/os/unix/ngx_thread.h +26 -83
- data/vendor/nginx/src/os/unix/ngx_thread_cond.c +87 -0
- data/vendor/nginx/src/os/unix/ngx_thread_id.c +70 -0
- data/vendor/nginx/src/os/unix/ngx_thread_mutex.c +174 -0
- data/vendor/nginx/src/os/unix/ngx_user.c +2 -20
- data/vendor/nginx/src/os/unix/ngx_writev_chain.c +129 -98
- metadata +16 -17
- data/vendor/nginx/auto/lib/zlib/patch.zlib.h +0 -10
- data/vendor/nginx/src/event/ngx_event_busy_lock.c +0 -286
- data/vendor/nginx/src/event/ngx_event_busy_lock.h +0 -65
- data/vendor/nginx/src/event/ngx_event_mutex.c +0 -70
- data/vendor/nginx/src/http/ngx_http_busy_lock.c +0 -307
- data/vendor/nginx/src/http/ngx_http_busy_lock.h +0 -54
- data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +0 -756
- data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +0 -122
- data/vendor/nginx/src/os/unix/ngx_pthread_thread.c +0 -278
- data/vendor/nginx/src/os/unix/rfork_thread.S +0 -73
@@ -14,10 +14,21 @@
|
|
14
14
|
|
15
15
|
#include <openssl/ssl.h>
|
16
16
|
#include <openssl/err.h>
|
17
|
+
#include <openssl/bn.h>
|
17
18
|
#include <openssl/conf.h>
|
19
|
+
#include <openssl/crypto.h>
|
20
|
+
#include <openssl/dh.h>
|
21
|
+
#ifndef OPENSSL_NO_ENGINE
|
18
22
|
#include <openssl/engine.h>
|
23
|
+
#endif
|
19
24
|
#include <openssl/evp.h>
|
25
|
+
#ifndef OPENSSL_NO_OCSP
|
20
26
|
#include <openssl/ocsp.h>
|
27
|
+
#endif
|
28
|
+
#include <openssl/rand.h>
|
29
|
+
#include <openssl/rsa.h>
|
30
|
+
#include <openssl/x509.h>
|
31
|
+
#include <openssl/x509v3.h>
|
21
32
|
|
22
33
|
#define NGX_SSL_NAME "OpenSSL"
|
23
34
|
|
@@ -112,7 +123,7 @@ typedef struct {
|
|
112
123
|
ngx_int_t ngx_ssl_init(ngx_log_t *log);
|
113
124
|
ngx_int_t ngx_ssl_create(ngx_ssl_t *ssl, ngx_uint_t protocols, void *data);
|
114
125
|
ngx_int_t ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
|
115
|
-
ngx_str_t *cert, ngx_str_t *key);
|
126
|
+
ngx_str_t *cert, ngx_str_t *key, ngx_array_t *passwords);
|
116
127
|
ngx_int_t ngx_ssl_client_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
|
117
128
|
ngx_str_t *cert, ngx_int_t depth);
|
118
129
|
ngx_int_t ngx_ssl_trusted_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
|
@@ -124,6 +135,7 @@ ngx_int_t ngx_ssl_stapling_resolver(ngx_conf_t *cf, ngx_ssl_t *ssl,
|
|
124
135
|
ngx_resolver_t *resolver, ngx_msec_t resolver_timeout);
|
125
136
|
RSA *ngx_ssl_rsa512_key_callback(ngx_ssl_conn_t *ssl_conn, int is_export,
|
126
137
|
int key_length);
|
138
|
+
ngx_array_t *ngx_ssl_read_password_file(ngx_conf_t *cf, ngx_str_t *file);
|
127
139
|
ngx_int_t ngx_ssl_dhparam(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *file);
|
128
140
|
ngx_int_t ngx_ssl_ecdh_curve(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *name);
|
129
141
|
ngx_int_t ngx_ssl_session_cache(ngx_ssl_t *ssl, ngx_str_t *sess_ctx,
|
@@ -150,6 +162,8 @@ ngx_int_t ngx_ssl_set_session(ngx_connection_t *c, ngx_ssl_session_t *session);
|
|
150
162
|
|| n == X509_V_ERR_CERT_UNTRUSTED \
|
151
163
|
|| n == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE)
|
152
164
|
|
165
|
+
ngx_int_t ngx_ssl_check_host(ngx_connection_t *c, ngx_str_t *name);
|
166
|
+
|
153
167
|
|
154
168
|
ngx_int_t ngx_ssl_get_protocol(ngx_connection_t *c, ngx_pool_t *pool,
|
155
169
|
ngx_str_t *s);
|
@@ -159,6 +173,8 @@ ngx_int_t ngx_ssl_get_session_id(ngx_connection_t *c, ngx_pool_t *pool,
|
|
159
173
|
ngx_str_t *s);
|
160
174
|
ngx_int_t ngx_ssl_get_session_reused(ngx_connection_t *c, ngx_pool_t *pool,
|
161
175
|
ngx_str_t *s);
|
176
|
+
ngx_int_t ngx_ssl_get_server_name(ngx_connection_t *c, ngx_pool_t *pool,
|
177
|
+
ngx_str_t *s);
|
162
178
|
ngx_int_t ngx_ssl_get_raw_certificate(ngx_connection_t *c, ngx_pool_t *pool,
|
163
179
|
ngx_str_t *s);
|
164
180
|
ngx_int_t ngx_ssl_get_certificate(ngx_connection_t *c, ngx_pool_t *pool,
|
@@ -169,6 +185,8 @@ ngx_int_t ngx_ssl_get_issuer_dn(ngx_connection_t *c, ngx_pool_t *pool,
|
|
169
185
|
ngx_str_t *s);
|
170
186
|
ngx_int_t ngx_ssl_get_serial_number(ngx_connection_t *c, ngx_pool_t *pool,
|
171
187
|
ngx_str_t *s);
|
188
|
+
ngx_int_t ngx_ssl_get_fingerprint(ngx_connection_t *c, ngx_pool_t *pool,
|
189
|
+
ngx_str_t *s);
|
172
190
|
ngx_int_t ngx_ssl_get_client_verify(ngx_connection_t *c, ngx_pool_t *pool,
|
173
191
|
ngx_str_t *s);
|
174
192
|
|
@@ -176,7 +194,7 @@ ngx_int_t ngx_ssl_get_client_verify(ngx_connection_t *c, ngx_pool_t *pool,
|
|
176
194
|
ngx_int_t ngx_ssl_handshake(ngx_connection_t *c);
|
177
195
|
ssize_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size);
|
178
196
|
ssize_t ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size);
|
179
|
-
ssize_t ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl);
|
197
|
+
ssize_t ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit);
|
180
198
|
ngx_chain_t *ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in,
|
181
199
|
off_t limit);
|
182
200
|
void ngx_ssl_free_buffer(ngx_connection_t *c);
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#include <ngx_event_connect.h>
|
12
12
|
|
13
13
|
|
14
|
-
#
|
14
|
+
#if (!defined OPENSSL_NO_OCSP && defined SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB)
|
15
15
|
|
16
16
|
|
17
17
|
typedef struct {
|
@@ -310,6 +310,7 @@ ngx_ssl_stapling_issuer(ngx_conf_t *cf, ngx_ssl_t *ssl)
|
|
310
310
|
if (X509_STORE_CTX_init(store_ctx, store, NULL, NULL) == 0) {
|
311
311
|
ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
|
312
312
|
"X509_STORE_CTX_init() failed");
|
313
|
+
X509_STORE_CTX_free(store_ctx);
|
313
314
|
return NGX_ERROR;
|
314
315
|
}
|
315
316
|
|
@@ -1118,6 +1119,7 @@ ngx_ssl_ocsp_create_request(ngx_ssl_ocsp_ctx_t *ctx)
|
|
1118
1119
|
if (OCSP_request_add0_id(ocsp, id) == NULL) {
|
1119
1120
|
ngx_ssl_error(NGX_LOG_CRIT, ctx->log, 0,
|
1120
1121
|
"OCSP_request_add0_id() failed");
|
1122
|
+
OCSP_CERTID_free(id);
|
1121
1123
|
goto failed;
|
1122
1124
|
}
|
1123
1125
|
|
@@ -1195,6 +1197,8 @@ ngx_ssl_ocsp_create_request(ngx_ssl_ocsp_ctx_t *ctx)
|
|
1195
1197
|
b->last = p;
|
1196
1198
|
ctx->request = b;
|
1197
1199
|
|
1200
|
+
OCSP_REQUEST_free(ocsp);
|
1201
|
+
|
1198
1202
|
return NGX_OK;
|
1199
1203
|
|
1200
1204
|
failed:
|
@@ -66,11 +66,13 @@ ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write)
|
|
66
66
|
return NGX_ABORT;
|
67
67
|
}
|
68
68
|
|
69
|
-
if (
|
70
|
-
|
69
|
+
if (!rev->delayed) {
|
70
|
+
if (rev->active && !rev->ready) {
|
71
|
+
ngx_add_timer(rev, p->read_timeout);
|
71
72
|
|
72
|
-
|
73
|
-
|
73
|
+
} else if (rev->timer_set) {
|
74
|
+
ngx_del_timer(rev);
|
75
|
+
}
|
74
76
|
}
|
75
77
|
}
|
76
78
|
|
@@ -99,9 +101,11 @@ ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write)
|
|
99
101
|
static ngx_int_t
|
100
102
|
ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
101
103
|
{
|
104
|
+
off_t limit;
|
102
105
|
ssize_t n, size;
|
103
106
|
ngx_int_t rc;
|
104
107
|
ngx_buf_t *b;
|
108
|
+
ngx_msec_t delay;
|
105
109
|
ngx_chain_t *chain, *cl, *ln;
|
106
110
|
|
107
111
|
if (p->upstream_eof || p->upstream_error || p->upstream_done) {
|
@@ -169,6 +173,25 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|
169
173
|
}
|
170
174
|
#endif
|
171
175
|
|
176
|
+
if (p->limit_rate) {
|
177
|
+
if (p->upstream->read->delayed) {
|
178
|
+
break;
|
179
|
+
}
|
180
|
+
|
181
|
+
limit = (off_t) p->limit_rate * (ngx_time() - p->start_sec + 1)
|
182
|
+
- p->read_length;
|
183
|
+
|
184
|
+
if (limit <= 0) {
|
185
|
+
p->upstream->read->delayed = 1;
|
186
|
+
delay = (ngx_msec_t) (- limit * 1000 / p->limit_rate + 1);
|
187
|
+
ngx_add_timer(p->upstream->read, delay);
|
188
|
+
break;
|
189
|
+
}
|
190
|
+
|
191
|
+
} else {
|
192
|
+
limit = 0;
|
193
|
+
}
|
194
|
+
|
172
195
|
if (p->free_raw_bufs) {
|
173
196
|
|
174
197
|
/* use the free bufs if they exist */
|
@@ -270,7 +293,7 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|
270
293
|
break;
|
271
294
|
}
|
272
295
|
|
273
|
-
n = p->upstream->recv_chain(p->upstream, chain);
|
296
|
+
n = p->upstream->recv_chain(p->upstream, chain, limit);
|
274
297
|
|
275
298
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
276
299
|
"pipe recv chain: %z", n);
|
@@ -301,6 +324,8 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|
301
324
|
}
|
302
325
|
}
|
303
326
|
|
327
|
+
delay = p->limit_rate ? (ngx_msec_t) n * 1000 / p->limit_rate : 0;
|
328
|
+
|
304
329
|
p->read_length += n;
|
305
330
|
cl = chain;
|
306
331
|
p->free_raw_bufs = NULL;
|
@@ -337,6 +362,12 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|
337
362
|
ln->next = p->free_raw_bufs;
|
338
363
|
p->free_raw_bufs = cl;
|
339
364
|
}
|
365
|
+
|
366
|
+
if (delay > 0) {
|
367
|
+
p->upstream->read->delayed = 1;
|
368
|
+
ngx_add_timer(p->upstream->read, delay);
|
369
|
+
break;
|
370
|
+
}
|
340
371
|
}
|
341
372
|
|
342
373
|
#if (NGX_DEBUG)
|
@@ -345,7 +376,7 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|
345
376
|
ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
346
377
|
"pipe buf busy s:%d t:%d f:%d "
|
347
378
|
"%p, pos %p, size: %z "
|
348
|
-
"file: %O, size: %
|
379
|
+
"file: %O, size: %O",
|
349
380
|
(cl->buf->shadow ? 1 : 0),
|
350
381
|
cl->buf->temporary, cl->buf->in_file,
|
351
382
|
cl->buf->start, cl->buf->pos,
|
@@ -358,7 +389,7 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|
358
389
|
ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
359
390
|
"pipe buf out s:%d t:%d f:%d "
|
360
391
|
"%p, pos %p, size: %z "
|
361
|
-
"file: %O, size: %
|
392
|
+
"file: %O, size: %O",
|
362
393
|
(cl->buf->shadow ? 1 : 0),
|
363
394
|
cl->buf->temporary, cl->buf->in_file,
|
364
395
|
cl->buf->start, cl->buf->pos,
|
@@ -371,7 +402,7 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|
371
402
|
ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
372
403
|
"pipe buf in s:%d t:%d f:%d "
|
373
404
|
"%p, pos %p, size: %z "
|
374
|
-
"file: %O, size: %
|
405
|
+
"file: %O, size: %O",
|
375
406
|
(cl->buf->shadow ? 1 : 0),
|
376
407
|
cl->buf->temporary, cl->buf->in_file,
|
377
408
|
cl->buf->start, cl->buf->pos,
|
@@ -384,7 +415,7 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|
384
415
|
ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
385
416
|
"pipe buf free s:%d t:%d f:%d "
|
386
417
|
"%p, pos %p, size: %z "
|
387
|
-
"file: %O, size: %
|
418
|
+
"file: %O, size: %O",
|
388
419
|
(cl->buf->shadow ? 1 : 0),
|
389
420
|
cl->buf->temporary, cl->buf->in_file,
|
390
421
|
cl->buf->start, cl->buf->pos,
|
@@ -439,7 +470,11 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|
439
470
|
}
|
440
471
|
}
|
441
472
|
|
442
|
-
if (p->cacheable && p->in) {
|
473
|
+
if (p->cacheable && (p->in || p->buf_to_file)) {
|
474
|
+
|
475
|
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
476
|
+
"pipe write chain");
|
477
|
+
|
443
478
|
if (ngx_event_pipe_write_chain_to_temp_file(p) == NGX_ABORT) {
|
444
479
|
return NGX_ABORT;
|
445
480
|
}
|
@@ -515,15 +550,6 @@ ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
|
515
550
|
p->in = NULL;
|
516
551
|
}
|
517
552
|
|
518
|
-
if (p->cacheable && p->buf_to_file) {
|
519
|
-
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
520
|
-
"pipe write chain");
|
521
|
-
|
522
|
-
if (ngx_event_pipe_write_chain_to_temp_file(p) == NGX_ABORT) {
|
523
|
-
return NGX_ABORT;
|
524
|
-
}
|
525
|
-
}
|
526
|
-
|
527
553
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
528
554
|
"pipe write downstream done");
|
529
555
|
|
@@ -10,164 +10,26 @@
|
|
10
10
|
#include <ngx_event.h>
|
11
11
|
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
#if (NGX_THREADS)
|
17
|
-
ngx_mutex_t *ngx_posted_events_mutex;
|
18
|
-
#endif
|
13
|
+
ngx_queue_t ngx_posted_accept_events;
|
14
|
+
ngx_queue_t ngx_posted_events;
|
19
15
|
|
20
16
|
|
21
17
|
void
|
22
|
-
ngx_event_process_posted(ngx_cycle_t *cycle,
|
23
|
-
ngx_thread_volatile ngx_event_t **posted)
|
18
|
+
ngx_event_process_posted(ngx_cycle_t *cycle, ngx_queue_t *posted)
|
24
19
|
{
|
20
|
+
ngx_queue_t *q;
|
25
21
|
ngx_event_t *ev;
|
26
22
|
|
27
|
-
|
23
|
+
while (!ngx_queue_empty(posted)) {
|
28
24
|
|
29
|
-
|
25
|
+
q = ngx_queue_head(posted);
|
26
|
+
ev = ngx_queue_data(q, ngx_event_t, queue);
|
30
27
|
|
31
28
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
32
29
|
"posted event %p", ev);
|
33
30
|
|
34
|
-
if (ev == NULL) {
|
35
|
-
return;
|
36
|
-
}
|
37
|
-
|
38
31
|
ngx_delete_posted_event(ev);
|
39
32
|
|
40
33
|
ev->handler(ev);
|
41
34
|
}
|
42
35
|
}
|
43
|
-
|
44
|
-
|
45
|
-
#if (NGX_THREADS) && !(NGX_WIN32)
|
46
|
-
|
47
|
-
void
|
48
|
-
ngx_wakeup_worker_thread(ngx_cycle_t *cycle)
|
49
|
-
{
|
50
|
-
ngx_int_t i;
|
51
|
-
#if 0
|
52
|
-
ngx_uint_t busy;
|
53
|
-
ngx_event_t *ev;
|
54
|
-
|
55
|
-
busy = 1;
|
56
|
-
|
57
|
-
if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
|
58
|
-
return;
|
59
|
-
}
|
60
|
-
|
61
|
-
for (ev = (ngx_event_t *) ngx_posted_events; ev; ev = ev->next) {
|
62
|
-
if (*(ev->lock) == 0) {
|
63
|
-
busy = 0;
|
64
|
-
break;
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
ngx_mutex_unlock(ngx_posted_events_mutex);
|
69
|
-
|
70
|
-
if (busy) {
|
71
|
-
return;
|
72
|
-
}
|
73
|
-
#endif
|
74
|
-
|
75
|
-
for (i = 0; i < ngx_threads_n; i++) {
|
76
|
-
if (ngx_threads[i].state == NGX_THREAD_FREE) {
|
77
|
-
ngx_cond_signal(ngx_threads[i].cv);
|
78
|
-
return;
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
ngx_int_t
|
85
|
-
ngx_event_thread_process_posted(ngx_cycle_t *cycle)
|
86
|
-
{
|
87
|
-
ngx_event_t *ev;
|
88
|
-
|
89
|
-
for ( ;; ) {
|
90
|
-
|
91
|
-
ev = (ngx_event_t *) ngx_posted_events;
|
92
|
-
|
93
|
-
for ( ;; ) {
|
94
|
-
|
95
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
96
|
-
"posted event %p", ev);
|
97
|
-
|
98
|
-
if (ev == NULL) {
|
99
|
-
return NGX_OK;
|
100
|
-
}
|
101
|
-
|
102
|
-
if (ngx_trylock(ev->lock) == 0) {
|
103
|
-
|
104
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
105
|
-
"posted event %p is busy", ev);
|
106
|
-
|
107
|
-
ev = ev->next;
|
108
|
-
continue;
|
109
|
-
}
|
110
|
-
|
111
|
-
if (ev->lock != ev->own_lock) {
|
112
|
-
if (*(ev->own_lock)) {
|
113
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
114
|
-
"the own lock of the posted event %p is busy", ev);
|
115
|
-
ngx_unlock(ev->lock);
|
116
|
-
ev = ev->next;
|
117
|
-
continue;
|
118
|
-
}
|
119
|
-
*(ev->own_lock) = 1;
|
120
|
-
}
|
121
|
-
|
122
|
-
ngx_delete_posted_event(ev);
|
123
|
-
|
124
|
-
ev->locked = 1;
|
125
|
-
|
126
|
-
ev->ready |= ev->posted_ready;
|
127
|
-
ev->timedout |= ev->posted_timedout;
|
128
|
-
ev->pending_eof |= ev->posted_eof;
|
129
|
-
#if (NGX_HAVE_KQUEUE)
|
130
|
-
ev->kq_errno |= ev->posted_errno;
|
131
|
-
#endif
|
132
|
-
if (ev->posted_available) {
|
133
|
-
ev->available = ev->posted_available;
|
134
|
-
}
|
135
|
-
|
136
|
-
ev->posted_ready = 0;
|
137
|
-
ev->posted_timedout = 0;
|
138
|
-
ev->posted_eof = 0;
|
139
|
-
#if (NGX_HAVE_KQUEUE)
|
140
|
-
ev->posted_errno = 0;
|
141
|
-
#endif
|
142
|
-
ev->posted_available = 0;
|
143
|
-
|
144
|
-
ngx_mutex_unlock(ngx_posted_events_mutex);
|
145
|
-
|
146
|
-
ev->handler(ev);
|
147
|
-
|
148
|
-
ngx_mutex_lock(ngx_posted_events_mutex);
|
149
|
-
|
150
|
-
if (ev->locked) {
|
151
|
-
ngx_unlock(ev->lock);
|
152
|
-
|
153
|
-
if (ev->lock != ev->own_lock) {
|
154
|
-
ngx_unlock(ev->own_lock);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
|
158
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
159
|
-
"posted event %p is done", ev);
|
160
|
-
|
161
|
-
break;
|
162
|
-
}
|
163
|
-
}
|
164
|
-
}
|
165
|
-
|
166
|
-
#else
|
167
|
-
|
168
|
-
void
|
169
|
-
ngx_wakeup_worker_thread(ngx_cycle_t *cycle)
|
170
|
-
{
|
171
|
-
}
|
172
|
-
|
173
|
-
#endif
|
@@ -14,62 +14,35 @@
|
|
14
14
|
#include <ngx_event.h>
|
15
15
|
|
16
16
|
|
17
|
-
#
|
18
|
-
extern ngx_mutex_t *ngx_posted_events_mutex;
|
19
|
-
#endif
|
20
|
-
|
21
|
-
|
22
|
-
#define ngx_locked_post_event(ev, queue) \
|
17
|
+
#define ngx_post_event(ev, q) \
|
23
18
|
\
|
24
|
-
if (ev->
|
25
|
-
ev->
|
26
|
-
|
27
|
-
*queue = ev; \
|
19
|
+
if (!(ev)->posted) { \
|
20
|
+
(ev)->posted = 1; \
|
21
|
+
ngx_queue_insert_tail(q, &(ev)->queue); \
|
28
22
|
\
|
29
|
-
|
30
|
-
ev->next->prev = &ev->next; \
|
31
|
-
} \
|
32
|
-
\
|
33
|
-
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, "post event %p", ev); \
|
23
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, (ev)->log, 0, "post event %p", ev);\
|
34
24
|
\
|
35
25
|
} else { \
|
36
|
-
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0,
|
26
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, (ev)->log, 0, \
|
37
27
|
"update posted event %p", ev); \
|
38
28
|
}
|
39
29
|
|
40
30
|
|
41
|
-
#define ngx_post_event(ev, queue) \
|
42
|
-
\
|
43
|
-
ngx_mutex_lock(ngx_posted_events_mutex); \
|
44
|
-
ngx_locked_post_event(ev, queue); \
|
45
|
-
ngx_mutex_unlock(ngx_posted_events_mutex);
|
46
|
-
|
47
|
-
|
48
31
|
#define ngx_delete_posted_event(ev) \
|
49
32
|
\
|
50
|
-
|
33
|
+
(ev)->posted = 0; \
|
34
|
+
ngx_queue_remove(&(ev)->queue); \
|
51
35
|
\
|
52
|
-
|
53
|
-
ev->next->prev = ev->prev; \
|
54
|
-
} \
|
55
|
-
\
|
56
|
-
ev->prev = NULL; \
|
57
|
-
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, \
|
36
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, (ev)->log, 0, \
|
58
37
|
"delete posted event %p", ev);
|
59
38
|
|
60
39
|
|
61
40
|
|
62
|
-
void ngx_event_process_posted(ngx_cycle_t *cycle,
|
63
|
-
ngx_thread_volatile ngx_event_t **posted);
|
64
|
-
void ngx_wakeup_worker_thread(ngx_cycle_t *cycle);
|
65
|
-
|
66
|
-
#if (NGX_THREADS)
|
67
|
-
ngx_int_t ngx_event_thread_process_posted(ngx_cycle_t *cycle);
|
68
|
-
#endif
|
41
|
+
void ngx_event_process_posted(ngx_cycle_t *cycle, ngx_queue_t *posted);
|
69
42
|
|
70
43
|
|
71
|
-
extern
|
72
|
-
extern
|
44
|
+
extern ngx_queue_t ngx_posted_accept_events;
|
45
|
+
extern ngx_queue_t ngx_posted_events;
|
73
46
|
|
74
47
|
|
75
48
|
#endif /* _NGX_EVENT_POSTED_H_INCLUDED_ */
|