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
@@ -17,7 +17,8 @@
|
|
17
17
|
|
18
18
|
|
19
19
|
typedef ssize_t (*ngx_recv_pt)(ngx_connection_t *c, u_char *buf, size_t size);
|
20
|
-
typedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in
|
20
|
+
typedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in,
|
21
|
+
off_t limit);
|
21
22
|
typedef ssize_t (*ngx_send_pt)(ngx_connection_t *c, u_char *buf, size_t size);
|
22
23
|
typedef ngx_chain_t *(*ngx_send_chain_pt)(ngx_connection_t *c, ngx_chain_t *in,
|
23
24
|
off_t limit);
|
@@ -41,7 +42,7 @@ ngx_int_t ngx_os_signal_process(ngx_cycle_t *cycle, char *sig, ngx_int_t pid);
|
|
41
42
|
|
42
43
|
|
43
44
|
ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size);
|
44
|
-
ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry);
|
45
|
+
ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry, off_t limit);
|
45
46
|
ssize_t ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size);
|
46
47
|
ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size);
|
47
48
|
ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in,
|
@@ -49,13 +50,34 @@ ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in,
|
|
49
50
|
|
50
51
|
#if (NGX_HAVE_AIO)
|
51
52
|
ssize_t ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size);
|
52
|
-
ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl);
|
53
|
+
ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit);
|
53
54
|
ssize_t ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size);
|
54
55
|
ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in,
|
55
56
|
off_t limit);
|
56
57
|
#endif
|
57
58
|
|
58
59
|
|
60
|
+
#if (IOV_MAX > 64)
|
61
|
+
#define NGX_IOVS_PREALLOCATE 64
|
62
|
+
#else
|
63
|
+
#define NGX_IOVS_PREALLOCATE IOV_MAX
|
64
|
+
#endif
|
65
|
+
|
66
|
+
|
67
|
+
typedef struct {
|
68
|
+
struct iovec *iovs;
|
69
|
+
ngx_uint_t count;
|
70
|
+
size_t size;
|
71
|
+
ngx_uint_t nalloc;
|
72
|
+
} ngx_iovec_t;
|
73
|
+
|
74
|
+
ngx_chain_t *ngx_output_chain_to_iovec(ngx_iovec_t *vec, ngx_chain_t *in,
|
75
|
+
size_t limit, ngx_log_t *log);
|
76
|
+
|
77
|
+
|
78
|
+
ssize_t ngx_writev(ngx_connection_t *c, ngx_iovec_t *vec);
|
79
|
+
|
80
|
+
|
59
81
|
extern ngx_os_io_t ngx_os_io;
|
60
82
|
extern ngx_int_t ngx_ncpu;
|
61
83
|
extern ngx_int_t ngx_max_sockets;
|
@@ -40,7 +40,9 @@ ngx_os_init(ngx_log_t *log)
|
|
40
40
|
}
|
41
41
|
#endif
|
42
42
|
|
43
|
-
ngx_init_setproctitle(log)
|
43
|
+
if (ngx_init_setproctitle(log) != NGX_OK) {
|
44
|
+
return NGX_ERROR;
|
45
|
+
}
|
44
46
|
|
45
47
|
ngx_pagesize = getpagesize();
|
46
48
|
ngx_cacheline_size = NGX_CPU_CACHE_LINE;
|
@@ -82,7 +84,7 @@ ngx_os_init(ngx_log_t *log)
|
|
82
84
|
void
|
83
85
|
ngx_os_status(ngx_log_t *log)
|
84
86
|
{
|
85
|
-
ngx_log_error(NGX_LOG_NOTICE, log, 0,
|
87
|
+
ngx_log_error(NGX_LOG_NOTICE, log, 0, NGINX_VER_BUILD);
|
86
88
|
|
87
89
|
#ifdef NGX_COMPILER
|
88
90
|
ngx_log_error(NGX_LOG_NOTICE, log, 0, "built by " NGX_COMPILER);
|
@@ -23,10 +23,6 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
|
|
23
23
|
static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker);
|
24
24
|
static void ngx_worker_process_exit(ngx_cycle_t *cycle);
|
25
25
|
static void ngx_channel_handler(ngx_event_t *ev);
|
26
|
-
#if (NGX_THREADS)
|
27
|
-
static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle);
|
28
|
-
static ngx_thread_value_t ngx_worker_thread_cycle(void *data);
|
29
|
-
#endif
|
30
26
|
static void ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data);
|
31
27
|
static void ngx_cache_manager_process_handler(ngx_event_t *ev);
|
32
28
|
static void ngx_cache_loader_process_handler(ngx_event_t *ev);
|
@@ -34,7 +30,6 @@ static void ngx_cache_loader_process_handler(ngx_event_t *ev);
|
|
34
30
|
|
35
31
|
ngx_uint_t ngx_process;
|
36
32
|
ngx_pid_t ngx_pid;
|
37
|
-
ngx_uint_t ngx_threaded;
|
38
33
|
|
39
34
|
sig_atomic_t ngx_reap;
|
40
35
|
sig_atomic_t ngx_sigio;
|
@@ -56,12 +51,6 @@ ngx_uint_t ngx_noaccepting;
|
|
56
51
|
ngx_uint_t ngx_restart;
|
57
52
|
|
58
53
|
|
59
|
-
#if (NGX_THREADS)
|
60
|
-
volatile ngx_thread_t ngx_threads[NGX_MAX_THREADS];
|
61
|
-
ngx_int_t ngx_threads_n;
|
62
|
-
#endif
|
63
|
-
|
64
|
-
|
65
54
|
static u_char master_process[] = "master process";
|
66
55
|
|
67
56
|
|
@@ -121,6 +110,10 @@ ngx_master_process_cycle(ngx_cycle_t *cycle)
|
|
121
110
|
}
|
122
111
|
|
123
112
|
title = ngx_pnalloc(cycle->pool, size);
|
113
|
+
if (title == NULL) {
|
114
|
+
/* fatal */
|
115
|
+
exit(2);
|
116
|
+
}
|
124
117
|
|
125
118
|
p = ngx_cpymem(title, master_process, sizeof(master_process) - 1);
|
126
119
|
for (i = 0; i < ngx_argc; i++) {
|
@@ -710,11 +703,13 @@ ngx_master_process_exit(ngx_cycle_t *cycle)
|
|
710
703
|
* ngx_cycle->pool is already destroyed.
|
711
704
|
*/
|
712
705
|
|
713
|
-
ngx_exit_log_file.fd = ngx_cycle->log->file->fd;
|
714
706
|
|
715
|
-
ngx_exit_log = *ngx_cycle->log;
|
707
|
+
ngx_exit_log = *ngx_log_get_file_log(ngx_cycle->log);
|
708
|
+
|
709
|
+
ngx_exit_log_file.fd = ngx_exit_log.file->fd;
|
716
710
|
ngx_exit_log.file = &ngx_exit_log_file;
|
717
711
|
ngx_exit_log.next = NULL;
|
712
|
+
ngx_exit_log.writer = NULL;
|
718
713
|
|
719
714
|
ngx_exit_cycle.log = &ngx_exit_log;
|
720
715
|
ngx_exit_cycle.files = ngx_cycle->files;
|
@@ -741,52 +736,6 @@ ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
|
|
741
736
|
|
742
737
|
ngx_setproctitle("worker process");
|
743
738
|
|
744
|
-
#if (NGX_THREADS)
|
745
|
-
{
|
746
|
-
ngx_int_t n;
|
747
|
-
ngx_err_t err;
|
748
|
-
ngx_core_conf_t *ccf;
|
749
|
-
|
750
|
-
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
751
|
-
|
752
|
-
if (ngx_threads_n) {
|
753
|
-
if (ngx_init_threads(ngx_threads_n, ccf->thread_stack_size, cycle)
|
754
|
-
== NGX_ERROR)
|
755
|
-
{
|
756
|
-
/* fatal */
|
757
|
-
exit(2);
|
758
|
-
}
|
759
|
-
|
760
|
-
err = ngx_thread_key_create(&ngx_core_tls_key);
|
761
|
-
if (err != 0) {
|
762
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
|
763
|
-
ngx_thread_key_create_n " failed");
|
764
|
-
/* fatal */
|
765
|
-
exit(2);
|
766
|
-
}
|
767
|
-
|
768
|
-
for (n = 0; n < ngx_threads_n; n++) {
|
769
|
-
|
770
|
-
ngx_threads[n].cv = ngx_cond_init(cycle->log);
|
771
|
-
|
772
|
-
if (ngx_threads[n].cv == NULL) {
|
773
|
-
/* fatal */
|
774
|
-
exit(2);
|
775
|
-
}
|
776
|
-
|
777
|
-
if (ngx_create_thread((ngx_tid_t *) &ngx_threads[n].tid,
|
778
|
-
ngx_worker_thread_cycle,
|
779
|
-
(void *) &ngx_threads[n], cycle->log)
|
780
|
-
!= 0)
|
781
|
-
{
|
782
|
-
/* fatal */
|
783
|
-
exit(2);
|
784
|
-
}
|
785
|
-
}
|
786
|
-
}
|
787
|
-
}
|
788
|
-
#endif
|
789
|
-
|
790
739
|
for ( ;; ) {
|
791
740
|
|
792
741
|
if (ngx_exiting) {
|
@@ -803,6 +752,8 @@ ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
|
|
803
752
|
}
|
804
753
|
}
|
805
754
|
|
755
|
+
ngx_event_cancel_timers();
|
756
|
+
|
806
757
|
if (ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel)
|
807
758
|
{
|
808
759
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
|
@@ -1024,12 +975,6 @@ ngx_worker_process_exit(ngx_cycle_t *cycle)
|
|
1024
975
|
ngx_uint_t i;
|
1025
976
|
ngx_connection_t *c;
|
1026
977
|
|
1027
|
-
#if (NGX_THREADS)
|
1028
|
-
ngx_terminate = 1;
|
1029
|
-
|
1030
|
-
ngx_wakeup_worker_threads(cycle);
|
1031
|
-
#endif
|
1032
|
-
|
1033
978
|
for (i = 0; ngx_modules[i]; i++) {
|
1034
979
|
if (ngx_modules[i]->exit_process) {
|
1035
980
|
ngx_modules[i]->exit_process(cycle);
|
@@ -1065,11 +1010,12 @@ ngx_worker_process_exit(ngx_cycle_t *cycle)
|
|
1065
1010
|
* ngx_cycle->pool is already destroyed.
|
1066
1011
|
*/
|
1067
1012
|
|
1068
|
-
|
1013
|
+
ngx_exit_log = *ngx_log_get_file_log(ngx_cycle->log);
|
1069
1014
|
|
1070
|
-
|
1015
|
+
ngx_exit_log_file.fd = ngx_exit_log.file->fd;
|
1071
1016
|
ngx_exit_log.file = &ngx_exit_log_file;
|
1072
1017
|
ngx_exit_log.next = NULL;
|
1018
|
+
ngx_exit_log.writer = NULL;
|
1073
1019
|
|
1074
1020
|
ngx_exit_cycle.log = &ngx_exit_log;
|
1075
1021
|
ngx_exit_cycle.files = ngx_cycle->files;
|
@@ -1172,134 +1118,6 @@ ngx_channel_handler(ngx_event_t *ev)
|
|
1172
1118
|
}
|
1173
1119
|
|
1174
1120
|
|
1175
|
-
#if (NGX_THREADS)
|
1176
|
-
|
1177
|
-
static void
|
1178
|
-
ngx_wakeup_worker_threads(ngx_cycle_t *cycle)
|
1179
|
-
{
|
1180
|
-
ngx_int_t i;
|
1181
|
-
ngx_uint_t live;
|
1182
|
-
|
1183
|
-
for ( ;; ) {
|
1184
|
-
|
1185
|
-
live = 0;
|
1186
|
-
|
1187
|
-
for (i = 0; i < ngx_threads_n; i++) {
|
1188
|
-
if (ngx_threads[i].state < NGX_THREAD_EXIT) {
|
1189
|
-
if (ngx_cond_signal(ngx_threads[i].cv) == NGX_ERROR) {
|
1190
|
-
ngx_threads[i].state = NGX_THREAD_DONE;
|
1191
|
-
|
1192
|
-
} else {
|
1193
|
-
live = 1;
|
1194
|
-
}
|
1195
|
-
}
|
1196
|
-
|
1197
|
-
if (ngx_threads[i].state == NGX_THREAD_EXIT) {
|
1198
|
-
ngx_thread_join(ngx_threads[i].tid, NULL);
|
1199
|
-
ngx_threads[i].state = NGX_THREAD_DONE;
|
1200
|
-
}
|
1201
|
-
}
|
1202
|
-
|
1203
|
-
if (live == 0) {
|
1204
|
-
ngx_log_debug0(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
1205
|
-
"all worker threads are joined");
|
1206
|
-
|
1207
|
-
/* STUB */
|
1208
|
-
ngx_done_events(cycle);
|
1209
|
-
ngx_mutex_destroy(ngx_event_timer_mutex);
|
1210
|
-
ngx_mutex_destroy(ngx_posted_events_mutex);
|
1211
|
-
|
1212
|
-
return;
|
1213
|
-
}
|
1214
|
-
|
1215
|
-
ngx_sched_yield();
|
1216
|
-
}
|
1217
|
-
}
|
1218
|
-
|
1219
|
-
|
1220
|
-
static ngx_thread_value_t
|
1221
|
-
ngx_worker_thread_cycle(void *data)
|
1222
|
-
{
|
1223
|
-
ngx_thread_t *thr = data;
|
1224
|
-
|
1225
|
-
sigset_t set;
|
1226
|
-
ngx_err_t err;
|
1227
|
-
ngx_core_tls_t *tls;
|
1228
|
-
ngx_cycle_t *cycle;
|
1229
|
-
|
1230
|
-
cycle = (ngx_cycle_t *) ngx_cycle;
|
1231
|
-
|
1232
|
-
sigemptyset(&set);
|
1233
|
-
sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL));
|
1234
|
-
sigaddset(&set, ngx_signal_value(NGX_REOPEN_SIGNAL));
|
1235
|
-
sigaddset(&set, ngx_signal_value(NGX_CHANGEBIN_SIGNAL));
|
1236
|
-
|
1237
|
-
err = ngx_thread_sigmask(SIG_BLOCK, &set, NULL);
|
1238
|
-
if (err) {
|
1239
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
|
1240
|
-
ngx_thread_sigmask_n " failed");
|
1241
|
-
return (ngx_thread_value_t) 1;
|
1242
|
-
}
|
1243
|
-
|
1244
|
-
ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
1245
|
-
"thread " NGX_TID_T_FMT " started", ngx_thread_self());
|
1246
|
-
|
1247
|
-
ngx_setthrtitle("worker thread");
|
1248
|
-
|
1249
|
-
tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log);
|
1250
|
-
if (tls == NULL) {
|
1251
|
-
return (ngx_thread_value_t) 1;
|
1252
|
-
}
|
1253
|
-
|
1254
|
-
err = ngx_thread_set_tls(ngx_core_tls_key, tls);
|
1255
|
-
if (err != 0) {
|
1256
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
|
1257
|
-
ngx_thread_set_tls_n " failed");
|
1258
|
-
return (ngx_thread_value_t) 1;
|
1259
|
-
}
|
1260
|
-
|
1261
|
-
ngx_mutex_lock(ngx_posted_events_mutex);
|
1262
|
-
|
1263
|
-
for ( ;; ) {
|
1264
|
-
thr->state = NGX_THREAD_FREE;
|
1265
|
-
|
1266
|
-
if (ngx_cond_wait(thr->cv, ngx_posted_events_mutex) == NGX_ERROR) {
|
1267
|
-
return (ngx_thread_value_t) 1;
|
1268
|
-
}
|
1269
|
-
|
1270
|
-
if (ngx_terminate) {
|
1271
|
-
thr->state = NGX_THREAD_EXIT;
|
1272
|
-
|
1273
|
-
ngx_mutex_unlock(ngx_posted_events_mutex);
|
1274
|
-
|
1275
|
-
ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
1276
|
-
"thread " NGX_TID_T_FMT " is done",
|
1277
|
-
ngx_thread_self());
|
1278
|
-
|
1279
|
-
return (ngx_thread_value_t) 0;
|
1280
|
-
}
|
1281
|
-
|
1282
|
-
thr->state = NGX_THREAD_BUSY;
|
1283
|
-
|
1284
|
-
if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) {
|
1285
|
-
return (ngx_thread_value_t) 1;
|
1286
|
-
}
|
1287
|
-
|
1288
|
-
if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) {
|
1289
|
-
return (ngx_thread_value_t) 1;
|
1290
|
-
}
|
1291
|
-
|
1292
|
-
if (ngx_process_changes) {
|
1293
|
-
if (ngx_process_changes(cycle, 1) == NGX_ERROR) {
|
1294
|
-
return (ngx_thread_value_t) 1;
|
1295
|
-
}
|
1296
|
-
}
|
1297
|
-
}
|
1298
|
-
}
|
1299
|
-
|
1300
|
-
#endif
|
1301
|
-
|
1302
|
-
|
1303
1121
|
static void
|
1304
1122
|
ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data)
|
1305
1123
|
{
|
@@ -10,23 +10,20 @@
|
|
10
10
|
#include <ngx_event.h>
|
11
11
|
|
12
12
|
|
13
|
-
#define NGX_IOVS 16
|
14
|
-
|
15
|
-
|
16
|
-
#if (NGX_HAVE_KQUEUE)
|
17
|
-
|
18
13
|
ssize_t
|
19
|
-
ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
14
|
+
ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain, off_t limit)
|
20
15
|
{
|
21
16
|
u_char *prev;
|
22
17
|
ssize_t n, size;
|
23
18
|
ngx_err_t err;
|
24
19
|
ngx_array_t vec;
|
25
20
|
ngx_event_t *rev;
|
26
|
-
struct iovec *iov, iovs[
|
21
|
+
struct iovec *iov, iovs[NGX_IOVS_PREALLOCATE];
|
27
22
|
|
28
23
|
rev = c->read;
|
29
24
|
|
25
|
+
#if (NGX_HAVE_KQUEUE)
|
26
|
+
|
30
27
|
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
|
31
28
|
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
32
29
|
"readv: eof:%d, avail:%d, err:%d",
|
@@ -54,6 +51,8 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
|
54
51
|
}
|
55
52
|
}
|
56
53
|
|
54
|
+
#endif
|
55
|
+
|
57
56
|
prev = NULL;
|
58
57
|
iov = NULL;
|
59
58
|
size = 0;
|
@@ -61,14 +60,26 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
|
61
60
|
vec.elts = iovs;
|
62
61
|
vec.nelts = 0;
|
63
62
|
vec.size = sizeof(struct iovec);
|
64
|
-
vec.nalloc =
|
63
|
+
vec.nalloc = NGX_IOVS_PREALLOCATE;
|
65
64
|
vec.pool = c->pool;
|
66
65
|
|
67
66
|
/* coalesce the neighbouring bufs */
|
68
67
|
|
69
68
|
while (chain) {
|
69
|
+
n = chain->buf->end - chain->buf->last;
|
70
|
+
|
71
|
+
if (limit) {
|
72
|
+
if (size >= limit) {
|
73
|
+
break;
|
74
|
+
}
|
75
|
+
|
76
|
+
if (size + n > limit) {
|
77
|
+
n = (ssize_t) (limit - size);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
70
81
|
if (prev == chain->buf->last) {
|
71
|
-
iov->iov_len +=
|
82
|
+
iov->iov_len += n;
|
72
83
|
|
73
84
|
} else {
|
74
85
|
if (vec.nelts >= IOV_MAX) {
|
@@ -81,10 +92,10 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
|
81
92
|
}
|
82
93
|
|
83
94
|
iov->iov_base = (void *) chain->buf->last;
|
84
|
-
iov->iov_len =
|
95
|
+
iov->iov_len = n;
|
85
96
|
}
|
86
97
|
|
87
|
-
size +=
|
98
|
+
size += n;
|
88
99
|
prev = chain->buf->end;
|
89
100
|
chain = chain->next;
|
90
101
|
}
|
@@ -92,12 +103,13 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
|
92
103
|
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
93
104
|
"readv: %d, last:%d", vec.nelts, iov->iov_len);
|
94
105
|
|
95
|
-
rev = c->read;
|
96
|
-
|
97
106
|
do {
|
98
107
|
n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);
|
99
108
|
|
100
109
|
if (n >= 0) {
|
110
|
+
|
111
|
+
#if (NGX_HAVE_KQUEUE)
|
112
|
+
|
101
113
|
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
|
102
114
|
rev->available -= n;
|
103
115
|
|
@@ -137,6 +149,8 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
|
137
149
|
return n;
|
138
150
|
}
|
139
151
|
|
152
|
+
#endif /* NGX_HAVE_KQUEUE */
|
153
|
+
|
140
154
|
if (n < size && !(ngx_event_flags & NGX_USE_GREEDY_EVENT)) {
|
141
155
|
rev->ready = 0;
|
142
156
|
}
|
@@ -170,98 +184,3 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
|
170
184
|
|
171
185
|
return n;
|
172
186
|
}
|
173
|
-
|
174
|
-
#else /* ! NGX_HAVE_KQUEUE */
|
175
|
-
|
176
|
-
ssize_t
|
177
|
-
ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
178
|
-
{
|
179
|
-
u_char *prev;
|
180
|
-
ssize_t n, size;
|
181
|
-
ngx_err_t err;
|
182
|
-
ngx_array_t vec;
|
183
|
-
ngx_event_t *rev;
|
184
|
-
struct iovec *iov, iovs[NGX_IOVS];
|
185
|
-
|
186
|
-
prev = NULL;
|
187
|
-
iov = NULL;
|
188
|
-
size = 0;
|
189
|
-
|
190
|
-
vec.elts = iovs;
|
191
|
-
vec.nelts = 0;
|
192
|
-
vec.size = sizeof(struct iovec);
|
193
|
-
vec.nalloc = NGX_IOVS;
|
194
|
-
vec.pool = c->pool;
|
195
|
-
|
196
|
-
/* coalesce the neighbouring bufs */
|
197
|
-
|
198
|
-
while (chain) {
|
199
|
-
if (prev == chain->buf->last) {
|
200
|
-
iov->iov_len += chain->buf->end - chain->buf->last;
|
201
|
-
|
202
|
-
} else {
|
203
|
-
if (vec.nelts >= IOV_MAX) {
|
204
|
-
break;
|
205
|
-
}
|
206
|
-
|
207
|
-
iov = ngx_array_push(&vec);
|
208
|
-
if (iov == NULL) {
|
209
|
-
return NGX_ERROR;
|
210
|
-
}
|
211
|
-
|
212
|
-
iov->iov_base = (void *) chain->buf->last;
|
213
|
-
iov->iov_len = chain->buf->end - chain->buf->last;
|
214
|
-
}
|
215
|
-
|
216
|
-
size += chain->buf->end - chain->buf->last;
|
217
|
-
prev = chain->buf->end;
|
218
|
-
chain = chain->next;
|
219
|
-
}
|
220
|
-
|
221
|
-
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
222
|
-
"readv: %d:%d", vec.nelts, iov->iov_len);
|
223
|
-
|
224
|
-
rev = c->read;
|
225
|
-
|
226
|
-
do {
|
227
|
-
n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);
|
228
|
-
|
229
|
-
if (n == 0) {
|
230
|
-
rev->ready = 0;
|
231
|
-
rev->eof = 1;
|
232
|
-
|
233
|
-
return n;
|
234
|
-
|
235
|
-
} else if (n > 0) {
|
236
|
-
|
237
|
-
if (n < size && !(ngx_event_flags & NGX_USE_GREEDY_EVENT)) {
|
238
|
-
rev->ready = 0;
|
239
|
-
}
|
240
|
-
|
241
|
-
return n;
|
242
|
-
}
|
243
|
-
|
244
|
-
err = ngx_socket_errno;
|
245
|
-
|
246
|
-
if (err == NGX_EAGAIN || err == NGX_EINTR) {
|
247
|
-
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
|
248
|
-
"readv() not ready");
|
249
|
-
n = NGX_AGAIN;
|
250
|
-
|
251
|
-
} else {
|
252
|
-
n = ngx_connection_error(c, err, "readv() failed");
|
253
|
-
break;
|
254
|
-
}
|
255
|
-
|
256
|
-
} while (err == NGX_EINTR);
|
257
|
-
|
258
|
-
rev->ready = 0;
|
259
|
-
|
260
|
-
if (n == NGX_ERROR) {
|
261
|
-
c->read->error = 1;
|
262
|
-
}
|
263
|
-
|
264
|
-
return n;
|
265
|
-
}
|
266
|
-
|
267
|
-
#endif /* NGX_HAVE_KQUEUE */
|