nginxtra 1.8.1.12 → 1.10.1.12
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 +363 -25
- data/vendor/nginx/CHANGES.ru +365 -21
- data/vendor/nginx/LICENSE +2 -2
- data/vendor/nginx/auto/cc/conf +32 -0
- data/vendor/nginx/auto/cc/gcc +1 -1
- data/vendor/nginx/auto/cc/icc +2 -2
- data/vendor/nginx/auto/cc/msvc +29 -8
- data/vendor/nginx/auto/cc/name +2 -25
- data/vendor/nginx/auto/cc/sunc +3 -0
- data/vendor/nginx/auto/endianness +7 -2
- data/vendor/nginx/auto/install +60 -26
- data/vendor/nginx/auto/lib/conf +4 -4
- data/vendor/nginx/auto/lib/geoip/conf +6 -1
- data/vendor/nginx/auto/lib/libgd/conf +6 -1
- data/vendor/nginx/auto/lib/libxslt/conf +11 -2
- data/vendor/nginx/auto/lib/make +1 -1
- data/vendor/nginx/auto/lib/md5/conf +2 -2
- data/vendor/nginx/auto/lib/md5/make +2 -2
- data/vendor/nginx/auto/lib/openssl/conf +52 -3
- data/vendor/nginx/auto/lib/openssl/make +1 -1
- data/vendor/nginx/auto/lib/pcre/conf +2 -2
- data/vendor/nginx/auto/lib/pcre/make +2 -2
- data/vendor/nginx/auto/lib/perl/conf +6 -3
- data/vendor/nginx/auto/lib/perl/make +4 -1
- data/vendor/nginx/auto/lib/sha1/conf +2 -2
- data/vendor/nginx/auto/lib/sha1/make +2 -2
- data/vendor/nginx/auto/lib/zlib/conf +2 -2
- data/vendor/nginx/auto/lib/zlib/make +2 -2
- data/vendor/nginx/auto/make +281 -16
- data/vendor/nginx/auto/module +122 -0
- data/vendor/nginx/auto/modules +909 -178
- data/vendor/nginx/auto/options +81 -19
- data/vendor/nginx/auto/os/conf +9 -0
- data/vendor/nginx/auto/os/darwin +3 -0
- data/vendor/nginx/auto/os/freebsd +0 -20
- data/vendor/nginx/auto/os/linux +0 -12
- data/vendor/nginx/auto/os/win32 +5 -1
- data/vendor/nginx/auto/sources +11 -311
- data/vendor/nginx/auto/summary +1 -0
- data/vendor/nginx/auto/types/sizeof +5 -3
- data/vendor/nginx/auto/types/typedef +9 -4
- data/vendor/nginx/auto/types/uintptr_t +7 -2
- data/vendor/nginx/auto/unix +72 -12
- data/vendor/nginx/conf/fastcgi.conf +1 -0
- data/vendor/nginx/conf/fastcgi_params +1 -0
- data/vendor/nginx/conf/scgi_params +1 -0
- data/vendor/nginx/conf/uwsgi_params +1 -0
- data/vendor/nginx/configure +1 -1
- data/vendor/nginx/contrib/vim/syntax/nginx.vim +2 -2
- data/vendor/nginx/man/nginx.8 +6 -2
- data/vendor/nginx/src/core/nginx.c +281 -114
- data/vendor/nginx/src/core/nginx.h +2 -2
- data/vendor/nginx/src/core/ngx_conf_file.c +54 -13
- data/vendor/nginx/src/core/ngx_conf_file.h +8 -52
- data/vendor/nginx/src/core/ngx_config.h +0 -5
- data/vendor/nginx/src/core/ngx_connection.c +270 -37
- data/vendor/nginx/src/core/ngx_connection.h +35 -12
- data/vendor/nginx/src/core/ngx_core.h +4 -0
- data/vendor/nginx/src/core/ngx_crypt.c +2 -2
- data/vendor/nginx/src/core/ngx_cycle.c +72 -25
- data/vendor/nginx/src/core/ngx_cycle.h +28 -39
- data/vendor/nginx/src/core/ngx_file.c +14 -5
- data/vendor/nginx/src/core/ngx_file.h +2 -0
- data/vendor/nginx/src/core/ngx_hash.c +13 -1
- data/vendor/nginx/src/core/ngx_inet.c +20 -18
- data/vendor/nginx/src/core/ngx_log.c +12 -12
- data/vendor/nginx/src/core/ngx_log.h +13 -6
- data/vendor/nginx/src/core/ngx_module.c +360 -0
- data/vendor/nginx/src/core/ngx_module.h +307 -0
- data/vendor/nginx/src/core/ngx_open_file_cache.c +2 -2
- data/vendor/nginx/src/core/ngx_output_chain.c +8 -4
- data/vendor/nginx/src/core/ngx_palloc.c +42 -44
- data/vendor/nginx/src/{http/ngx_http_parse_time.c → core/ngx_parse_time.c} +2 -3
- data/vendor/nginx/src/core/ngx_parse_time.h +22 -0
- data/vendor/nginx/src/core/ngx_proxy_protocol.c +50 -1
- data/vendor/nginx/src/core/ngx_proxy_protocol.h +3 -1
- data/vendor/nginx/src/core/ngx_regex.c +1 -38
- data/vendor/nginx/src/core/ngx_resolver.c +1814 -320
- data/vendor/nginx/src/core/ngx_resolver.h +67 -10
- data/vendor/nginx/src/core/ngx_rwlock.c +120 -0
- data/vendor/nginx/src/core/ngx_rwlock.h +21 -0
- data/vendor/nginx/src/core/ngx_slab.c +6 -5
- data/vendor/nginx/src/core/ngx_string.c +1 -1
- data/vendor/nginx/src/core/ngx_syslog.c +11 -3
- data/vendor/nginx/src/core/ngx_syslog.h +2 -1
- data/vendor/nginx/src/core/ngx_thread_pool.c +4 -0
- data/vendor/nginx/src/core/ngx_times.c +2 -2
- data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +3 -1
- data/vendor/nginx/src/event/modules/ngx_epoll_module.c +5 -2
- data/vendor/nginx/src/event/modules/ngx_eventport_module.c +5 -5
- data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +15 -8
- data/vendor/nginx/src/event/modules/ngx_poll_module.c +0 -10
- data/vendor/nginx/src/event/modules/ngx_select_module.c +0 -10
- data/vendor/nginx/src/event/ngx_event.c +60 -103
- data/vendor/nginx/src/event/ngx_event.h +22 -26
- data/vendor/nginx/src/event/ngx_event_accept.c +414 -88
- data/vendor/nginx/src/event/ngx_event_connect.c +27 -18
- data/vendor/nginx/src/event/ngx_event_connect.h +1 -0
- data/vendor/nginx/src/event/ngx_event_openssl.c +65 -25
- data/vendor/nginx/src/event/ngx_event_openssl.h +17 -0
- data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +73 -7
- data/vendor/nginx/src/event/ngx_event_pipe.c +85 -27
- data/vendor/nginx/src/event/ngx_event_pipe.h +10 -0
- data/vendor/nginx/src/http/modules/ngx_http_auth_basic_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_auth_request_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_chunked_filter_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +6 -6
- data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +17 -11
- data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +9 -9
- data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +0 -7
- data/vendor/nginx/src/http/modules/ngx_http_map_module.c +6 -6
- data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +2 -1
- data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +13 -13
- data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +2 -2
- data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +26 -21
- data/vendor/nginx/src/http/modules/ngx_http_random_index_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_range_filter_module.c +26 -8
- data/vendor/nginx/src/http/modules/ngx_http_realip_module.c +73 -3
- data/vendor/nginx/src/http/modules/ngx_http_referer_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +6 -6
- data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +5 -3
- data/vendor/nginx/src/http/modules/ngx_http_slice_filter_module.c +526 -0
- data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +7 -7
- data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +19 -16
- data/vendor/nginx/src/http/modules/ngx_http_static_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +373 -173
- data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +72 -46
- data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +18 -30
- data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +50 -39
- data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +38 -129
- data/vendor/nginx/src/http/modules/ngx_http_upstream_zone_module.c +246 -0
- data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +6 -5
- data/vendor/nginx/src/http/modules/perl/nginx.xs +9 -9
- data/vendor/nginx/src/http/ngx_http.c +46 -43
- data/vendor/nginx/src/http/ngx_http.h +4 -9
- data/vendor/nginx/src/http/ngx_http_cache.h +4 -0
- data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +13 -5
- data/vendor/nginx/src/http/ngx_http_core_module.c +92 -91
- data/vendor/nginx/src/http/ngx_http_core_module.h +12 -8
- data/vendor/nginx/src/http/ngx_http_file_cache.c +61 -10
- data/vendor/nginx/src/http/ngx_http_request.c +37 -50
- data/vendor/nginx/src/http/ngx_http_request.h +10 -15
- data/vendor/nginx/src/http/ngx_http_request_body.c +64 -88
- data/vendor/nginx/src/http/ngx_http_script.c +3 -3
- data/vendor/nginx/src/http/ngx_http_special_response.c +1 -4
- data/vendor/nginx/src/http/ngx_http_upstream.c +245 -109
- data/vendor/nginx/src/http/ngx_http_upstream.h +11 -5
- data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +212 -65
- data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +66 -5
- data/vendor/nginx/src/http/ngx_http_variables.c +28 -15
- data/vendor/nginx/src/http/ngx_http_write_filter_module.c +1 -1
- data/vendor/nginx/src/http/v2/ngx_http_v2.c +4349 -0
- data/vendor/nginx/src/http/v2/ngx_http_v2.h +337 -0
- data/vendor/nginx/src/http/v2/ngx_http_v2_filter_module.c +1391 -0
- data/vendor/nginx/src/http/v2/ngx_http_v2_huff_decode.c +2714 -0
- data/vendor/nginx/src/http/v2/ngx_http_v2_huff_encode.c +254 -0
- data/vendor/nginx/src/http/v2/ngx_http_v2_module.c +469 -0
- data/vendor/nginx/src/http/{ngx_http_spdy_module.h → v2/ngx_http_v2_module.h} +10 -9
- data/vendor/nginx/src/http/v2/ngx_http_v2_table.c +349 -0
- data/vendor/nginx/src/mail/ngx_mail.c +49 -82
- data/vendor/nginx/src/mail/ngx_mail.h +16 -23
- data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +1 -1
- data/vendor/nginx/src/mail/ngx_mail_core_module.c +60 -34
- data/vendor/nginx/src/mail/ngx_mail_handler.c +17 -12
- data/vendor/nginx/src/mail/ngx_mail_proxy_module.c +1 -14
- data/vendor/nginx/src/mail/ngx_mail_smtp_handler.c +1 -1
- data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +5 -5
- data/vendor/nginx/src/os/unix/ngx_atomic.h +10 -10
- data/vendor/nginx/src/os/unix/ngx_channel.h +4 -4
- data/vendor/nginx/src/os/unix/ngx_darwin_config.h +2 -0
- data/vendor/nginx/src/os/unix/ngx_darwin_init.c +1 -0
- data/vendor/nginx/src/os/unix/ngx_dlopen.c +28 -0
- data/vendor/nginx/src/os/unix/ngx_dlopen.h +31 -0
- data/vendor/nginx/src/os/unix/ngx_errno.h +1 -0
- data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +1 -1
- data/vendor/nginx/src/os/unix/ngx_files.c +313 -80
- data/vendor/nginx/src/os/unix/ngx_files.h +5 -2
- data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +3 -1
- data/vendor/nginx/src/os/unix/ngx_freebsd_init.c +1 -0
- data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +13 -0
- data/vendor/nginx/src/os/unix/ngx_linux.h +0 -2
- data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +1 -1
- data/vendor/nginx/src/os/unix/ngx_linux_config.h +2 -6
- data/vendor/nginx/src/os/unix/ngx_linux_init.c +1 -33
- data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +55 -12
- data/vendor/nginx/src/os/unix/ngx_os.h +3 -9
- data/vendor/nginx/src/os/unix/ngx_posix_config.h +14 -1
- data/vendor/nginx/src/os/unix/ngx_posix_init.c +2 -1
- data/vendor/nginx/src/os/unix/ngx_process.c +1 -1
- data/vendor/nginx/src/os/unix/ngx_process_cycle.c +25 -51
- data/vendor/nginx/src/os/unix/ngx_process_cycle.h +1 -0
- data/vendor/nginx/src/os/unix/ngx_readv_chain.c +24 -28
- data/vendor/nginx/src/os/unix/ngx_recv.c +30 -79
- data/vendor/nginx/src/os/unix/ngx_send.c +1 -1
- data/vendor/nginx/src/os/unix/ngx_setaffinity.c +14 -30
- data/vendor/nginx/src/os/unix/ngx_setaffinity.h +15 -1
- data/vendor/nginx/src/os/unix/ngx_solaris_config.h +2 -0
- data/vendor/nginx/src/os/unix/ngx_solaris_init.c +1 -0
- data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +23 -0
- data/vendor/nginx/src/os/unix/ngx_sunpro_amd64.il +3 -3
- data/vendor/nginx/src/os/unix/ngx_sunpro_x86.il +3 -3
- data/vendor/nginx/src/os/unix/ngx_udp_recv.c +5 -48
- data/vendor/nginx/src/os/unix/ngx_udp_send.c +56 -0
- data/vendor/nginx/src/stream/ngx_stream.c +564 -0
- data/vendor/nginx/src/stream/ngx_stream.h +212 -0
- data/vendor/nginx/src/stream/ngx_stream_access_module.c +451 -0
- data/vendor/nginx/src/stream/ngx_stream_core_module.c +562 -0
- data/vendor/nginx/src/stream/ngx_stream_handler.c +344 -0
- data/vendor/nginx/src/stream/ngx_stream_limit_conn_module.c +632 -0
- data/vendor/nginx/src/stream/ngx_stream_proxy_module.c +1674 -0
- data/vendor/nginx/src/stream/ngx_stream_ssl_module.c +460 -0
- data/vendor/nginx/src/stream/ngx_stream_ssl_module.h +49 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream.c +464 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream.h +107 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream_hash_module.c +656 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream_least_conn_module.c +307 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.c +702 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.h +139 -0
- data/vendor/nginx/src/stream/ngx_stream_upstream_zone_module.c +242 -0
- metadata +39 -15
- data/vendor/nginx/src/event/modules/ngx_aio_module.c +0 -171
- data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +0 -735
- data/vendor/nginx/src/http/ngx_http_spdy.c +0 -3701
- data/vendor/nginx/src/http/ngx_http_spdy.h +0 -261
- data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +0 -1222
- data/vendor/nginx/src/http/ngx_http_spdy_module.c +0 -408
- data/vendor/nginx/src/os/unix/ngx_aio_read.c +0 -109
- data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +0 -78
- data/vendor/nginx/src/os/unix/ngx_aio_write.c +0 -109
- data/vendor/nginx/src/os/unix/ngx_aio_write_chain.c +0 -100
@@ -1,171 +0,0 @@
|
|
1
|
-
|
2
|
-
/*
|
3
|
-
* Copyright (C) Igor Sysoev
|
4
|
-
* Copyright (C) Nginx, Inc.
|
5
|
-
*/
|
6
|
-
|
7
|
-
|
8
|
-
#include <ngx_config.h>
|
9
|
-
#include <ngx_core.h>
|
10
|
-
#include <ngx_event.h>
|
11
|
-
|
12
|
-
|
13
|
-
extern ngx_event_module_t ngx_kqueue_module_ctx;
|
14
|
-
|
15
|
-
|
16
|
-
static ngx_int_t ngx_aio_init(ngx_cycle_t *cycle, ngx_msec_t timer);
|
17
|
-
static void ngx_aio_done(ngx_cycle_t *cycle);
|
18
|
-
static ngx_int_t ngx_aio_add_event(ngx_event_t *ev, ngx_int_t event,
|
19
|
-
ngx_uint_t flags);
|
20
|
-
static ngx_int_t ngx_aio_del_event(ngx_event_t *ev, ngx_int_t event,
|
21
|
-
ngx_uint_t flags);
|
22
|
-
static ngx_int_t ngx_aio_del_connection(ngx_connection_t *c, ngx_uint_t flags);
|
23
|
-
static ngx_int_t ngx_aio_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
|
24
|
-
ngx_uint_t flags);
|
25
|
-
|
26
|
-
|
27
|
-
ngx_os_io_t ngx_os_aio = {
|
28
|
-
ngx_aio_read,
|
29
|
-
ngx_aio_read_chain,
|
30
|
-
NULL,
|
31
|
-
ngx_aio_write,
|
32
|
-
ngx_aio_write_chain,
|
33
|
-
0
|
34
|
-
};
|
35
|
-
|
36
|
-
|
37
|
-
static ngx_str_t aio_name = ngx_string("aio");
|
38
|
-
|
39
|
-
ngx_event_module_t ngx_aio_module_ctx = {
|
40
|
-
&aio_name,
|
41
|
-
NULL, /* create configuration */
|
42
|
-
NULL, /* init configuration */
|
43
|
-
|
44
|
-
{
|
45
|
-
ngx_aio_add_event, /* add an event */
|
46
|
-
ngx_aio_del_event, /* delete an event */
|
47
|
-
NULL, /* enable an event */
|
48
|
-
NULL, /* disable an event */
|
49
|
-
NULL, /* add an connection */
|
50
|
-
ngx_aio_del_connection, /* delete an connection */
|
51
|
-
NULL, /* trigger a notify */
|
52
|
-
ngx_aio_process_events, /* process the events */
|
53
|
-
ngx_aio_init, /* init the events */
|
54
|
-
ngx_aio_done /* done the events */
|
55
|
-
}
|
56
|
-
|
57
|
-
};
|
58
|
-
|
59
|
-
ngx_module_t ngx_aio_module = {
|
60
|
-
NGX_MODULE_V1,
|
61
|
-
&ngx_aio_module_ctx, /* module context */
|
62
|
-
NULL, /* module directives */
|
63
|
-
NGX_EVENT_MODULE, /* module type */
|
64
|
-
NULL, /* init master */
|
65
|
-
NULL, /* init module */
|
66
|
-
NULL, /* init process */
|
67
|
-
NULL, /* init thread */
|
68
|
-
NULL, /* exit thread */
|
69
|
-
NULL, /* exit process */
|
70
|
-
NULL, /* exit master */
|
71
|
-
NGX_MODULE_V1_PADDING
|
72
|
-
};
|
73
|
-
|
74
|
-
|
75
|
-
#if (NGX_HAVE_KQUEUE)
|
76
|
-
|
77
|
-
static ngx_int_t
|
78
|
-
ngx_aio_init(ngx_cycle_t *cycle, ngx_msec_t timer)
|
79
|
-
{
|
80
|
-
if (ngx_kqueue_module_ctx.actions.init(cycle, timer) == NGX_ERROR) {
|
81
|
-
return NGX_ERROR;
|
82
|
-
}
|
83
|
-
|
84
|
-
ngx_io = ngx_os_aio;
|
85
|
-
|
86
|
-
ngx_event_flags = NGX_USE_AIO_EVENT;
|
87
|
-
ngx_event_actions = ngx_aio_module_ctx.actions;
|
88
|
-
|
89
|
-
|
90
|
-
return NGX_OK;
|
91
|
-
}
|
92
|
-
|
93
|
-
|
94
|
-
static void
|
95
|
-
ngx_aio_done(ngx_cycle_t *cycle)
|
96
|
-
{
|
97
|
-
ngx_kqueue_module_ctx.actions.done(cycle);
|
98
|
-
}
|
99
|
-
|
100
|
-
|
101
|
-
/* the event adding and deleting are needed for the listening sockets */
|
102
|
-
|
103
|
-
static ngx_int_t
|
104
|
-
ngx_aio_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
|
105
|
-
{
|
106
|
-
return ngx_kqueue_module_ctx.actions.add(ev, event, flags);
|
107
|
-
}
|
108
|
-
|
109
|
-
|
110
|
-
static ngx_int_t
|
111
|
-
ngx_aio_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
|
112
|
-
{
|
113
|
-
return ngx_kqueue_module_ctx.actions.del(ev, event, flags);
|
114
|
-
}
|
115
|
-
|
116
|
-
|
117
|
-
static ngx_int_t
|
118
|
-
ngx_aio_del_connection(ngx_connection_t *c, ngx_uint_t flags)
|
119
|
-
{
|
120
|
-
int rc;
|
121
|
-
|
122
|
-
if (c->read->active == 0 && c->write->active == 0) {
|
123
|
-
return NGX_OK;
|
124
|
-
}
|
125
|
-
|
126
|
-
if (flags & NGX_CLOSE_EVENT) {
|
127
|
-
return NGX_OK;
|
128
|
-
}
|
129
|
-
|
130
|
-
rc = aio_cancel(c->fd, NULL);
|
131
|
-
|
132
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "aio_cancel: %d", rc);
|
133
|
-
|
134
|
-
if (rc == AIO_CANCELED) {
|
135
|
-
c->read->active = 0;
|
136
|
-
c->write->active = 0;
|
137
|
-
return NGX_OK;
|
138
|
-
}
|
139
|
-
|
140
|
-
if (rc == AIO_ALLDONE) {
|
141
|
-
c->read->active = 0;
|
142
|
-
c->write->active = 0;
|
143
|
-
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
144
|
-
"aio_cancel() returned AIO_ALLDONE");
|
145
|
-
return NGX_OK;
|
146
|
-
}
|
147
|
-
|
148
|
-
if (rc == -1) {
|
149
|
-
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
150
|
-
"aio_cancel() failed");
|
151
|
-
return NGX_ERROR;
|
152
|
-
}
|
153
|
-
|
154
|
-
if (rc == AIO_NOTCANCELED) {
|
155
|
-
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
156
|
-
"aio_cancel() returned AIO_NOTCANCELED");
|
157
|
-
|
158
|
-
return NGX_ERROR;
|
159
|
-
}
|
160
|
-
|
161
|
-
return NGX_OK;
|
162
|
-
}
|
163
|
-
|
164
|
-
|
165
|
-
static ngx_int_t
|
166
|
-
ngx_aio_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags)
|
167
|
-
{
|
168
|
-
return ngx_kqueue_module_ctx.actions.process_events(cycle, timer, flags);
|
169
|
-
}
|
170
|
-
|
171
|
-
#endif /* NGX_HAVE_KQUEUE */
|
@@ -1,735 +0,0 @@
|
|
1
|
-
|
2
|
-
/*
|
3
|
-
* Copyright (C) Igor Sysoev
|
4
|
-
* Copyright (C) Nginx, Inc.
|
5
|
-
*/
|
6
|
-
|
7
|
-
|
8
|
-
#include <ngx_config.h>
|
9
|
-
#include <ngx_core.h>
|
10
|
-
#include <ngx_event.h>
|
11
|
-
|
12
|
-
|
13
|
-
#if (NGX_TEST_BUILD_RTSIG)
|
14
|
-
|
15
|
-
#if (NGX_DARWIN)
|
16
|
-
|
17
|
-
#define SIGRTMIN 33
|
18
|
-
#define si_fd __pad[0]
|
19
|
-
|
20
|
-
#else
|
21
|
-
|
22
|
-
#ifdef SIGRTMIN
|
23
|
-
#define si_fd _reason.__spare__.__spare2__[0]
|
24
|
-
#else
|
25
|
-
#define SIGRTMIN 33
|
26
|
-
#define si_fd __spare__[0]
|
27
|
-
#endif
|
28
|
-
|
29
|
-
#endif
|
30
|
-
|
31
|
-
#define F_SETSIG 10
|
32
|
-
#define KERN_RTSIGNR 30
|
33
|
-
#define KERN_RTSIGMAX 31
|
34
|
-
|
35
|
-
int sigtimedwait(const sigset_t *set, siginfo_t *info,
|
36
|
-
const struct timespec *timeout);
|
37
|
-
|
38
|
-
int sigtimedwait(const sigset_t *set, siginfo_t *info,
|
39
|
-
const struct timespec *timeout)
|
40
|
-
{
|
41
|
-
return -1;
|
42
|
-
}
|
43
|
-
|
44
|
-
int ngx_linux_rtsig_max;
|
45
|
-
|
46
|
-
#endif
|
47
|
-
|
48
|
-
|
49
|
-
typedef struct {
|
50
|
-
ngx_uint_t signo;
|
51
|
-
ngx_uint_t overflow_events;
|
52
|
-
ngx_uint_t overflow_test;
|
53
|
-
ngx_uint_t overflow_threshold;
|
54
|
-
} ngx_rtsig_conf_t;
|
55
|
-
|
56
|
-
|
57
|
-
extern ngx_event_module_t ngx_poll_module_ctx;
|
58
|
-
|
59
|
-
static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle, ngx_msec_t timer);
|
60
|
-
static void ngx_rtsig_done(ngx_cycle_t *cycle);
|
61
|
-
static ngx_int_t ngx_rtsig_add_connection(ngx_connection_t *c);
|
62
|
-
static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c,
|
63
|
-
ngx_uint_t flags);
|
64
|
-
static ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle,
|
65
|
-
ngx_msec_t timer, ngx_uint_t flags);
|
66
|
-
static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle,
|
67
|
-
ngx_msec_t timer, ngx_uint_t flags);
|
68
|
-
|
69
|
-
static void *ngx_rtsig_create_conf(ngx_cycle_t *cycle);
|
70
|
-
static char *ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf);
|
71
|
-
static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf,
|
72
|
-
void *post, void *data);
|
73
|
-
|
74
|
-
|
75
|
-
static sigset_t set;
|
76
|
-
static ngx_uint_t overflow, overflow_current;
|
77
|
-
static struct pollfd *overflow_list;
|
78
|
-
|
79
|
-
|
80
|
-
static ngx_str_t rtsig_name = ngx_string("rtsig");
|
81
|
-
|
82
|
-
static ngx_conf_num_bounds_t ngx_overflow_threshold_bounds = {
|
83
|
-
ngx_check_ngx_overflow_threshold_bounds, 2, 10
|
84
|
-
};
|
85
|
-
|
86
|
-
|
87
|
-
static ngx_command_t ngx_rtsig_commands[] = {
|
88
|
-
|
89
|
-
{ ngx_string("rtsig_signo"),
|
90
|
-
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
91
|
-
ngx_conf_set_num_slot,
|
92
|
-
0,
|
93
|
-
offsetof(ngx_rtsig_conf_t, signo),
|
94
|
-
NULL },
|
95
|
-
|
96
|
-
{ ngx_string("rtsig_overflow_events"),
|
97
|
-
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
98
|
-
ngx_conf_set_num_slot,
|
99
|
-
0,
|
100
|
-
offsetof(ngx_rtsig_conf_t, overflow_events),
|
101
|
-
NULL },
|
102
|
-
|
103
|
-
{ ngx_string("rtsig_overflow_test"),
|
104
|
-
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
105
|
-
ngx_conf_set_num_slot,
|
106
|
-
0,
|
107
|
-
offsetof(ngx_rtsig_conf_t, overflow_test),
|
108
|
-
NULL },
|
109
|
-
|
110
|
-
{ ngx_string("rtsig_overflow_threshold"),
|
111
|
-
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
112
|
-
ngx_conf_set_num_slot,
|
113
|
-
0,
|
114
|
-
offsetof(ngx_rtsig_conf_t, overflow_threshold),
|
115
|
-
&ngx_overflow_threshold_bounds },
|
116
|
-
|
117
|
-
ngx_null_command
|
118
|
-
};
|
119
|
-
|
120
|
-
|
121
|
-
ngx_event_module_t ngx_rtsig_module_ctx = {
|
122
|
-
&rtsig_name,
|
123
|
-
ngx_rtsig_create_conf, /* create configuration */
|
124
|
-
ngx_rtsig_init_conf, /* init configuration */
|
125
|
-
|
126
|
-
{
|
127
|
-
NULL, /* add an event */
|
128
|
-
NULL, /* delete an event */
|
129
|
-
NULL, /* enable an event */
|
130
|
-
NULL, /* disable an event */
|
131
|
-
ngx_rtsig_add_connection, /* add an connection */
|
132
|
-
ngx_rtsig_del_connection, /* delete an connection */
|
133
|
-
NULL, /* trigger a notify */
|
134
|
-
ngx_rtsig_process_events, /* process the events */
|
135
|
-
ngx_rtsig_init, /* init the events */
|
136
|
-
ngx_rtsig_done, /* done the events */
|
137
|
-
}
|
138
|
-
|
139
|
-
};
|
140
|
-
|
141
|
-
ngx_module_t ngx_rtsig_module = {
|
142
|
-
NGX_MODULE_V1,
|
143
|
-
&ngx_rtsig_module_ctx, /* module context */
|
144
|
-
ngx_rtsig_commands, /* module directives */
|
145
|
-
NGX_EVENT_MODULE, /* module type */
|
146
|
-
NULL, /* init master */
|
147
|
-
NULL, /* init module */
|
148
|
-
NULL, /* init process */
|
149
|
-
NULL, /* init thread */
|
150
|
-
NULL, /* exit thread */
|
151
|
-
NULL, /* exit process */
|
152
|
-
NULL, /* exit master */
|
153
|
-
NGX_MODULE_V1_PADDING
|
154
|
-
};
|
155
|
-
|
156
|
-
|
157
|
-
static ngx_int_t
|
158
|
-
ngx_rtsig_init(ngx_cycle_t *cycle, ngx_msec_t timer)
|
159
|
-
{
|
160
|
-
ngx_rtsig_conf_t *rtscf;
|
161
|
-
|
162
|
-
rtscf = ngx_event_get_conf(cycle->conf_ctx, ngx_rtsig_module);
|
163
|
-
|
164
|
-
sigemptyset(&set);
|
165
|
-
sigaddset(&set, (int) rtscf->signo);
|
166
|
-
sigaddset(&set, (int) rtscf->signo + 1);
|
167
|
-
sigaddset(&set, SIGIO);
|
168
|
-
sigaddset(&set, SIGALRM);
|
169
|
-
|
170
|
-
if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
|
171
|
-
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
172
|
-
"sigprocmask() failed");
|
173
|
-
return NGX_ERROR;
|
174
|
-
}
|
175
|
-
|
176
|
-
if (overflow_list) {
|
177
|
-
ngx_free(overflow_list);
|
178
|
-
}
|
179
|
-
|
180
|
-
overflow_list = ngx_alloc(sizeof(struct pollfd) * rtscf->overflow_events,
|
181
|
-
cycle->log);
|
182
|
-
if (overflow_list == NULL) {
|
183
|
-
return NGX_ERROR;
|
184
|
-
}
|
185
|
-
|
186
|
-
ngx_io = ngx_os_io;
|
187
|
-
|
188
|
-
ngx_event_actions = ngx_rtsig_module_ctx.actions;
|
189
|
-
|
190
|
-
ngx_event_flags = NGX_USE_RTSIG_EVENT
|
191
|
-
|NGX_USE_GREEDY_EVENT
|
192
|
-
|NGX_USE_FD_EVENT;
|
193
|
-
|
194
|
-
return NGX_OK;
|
195
|
-
}
|
196
|
-
|
197
|
-
|
198
|
-
static void
|
199
|
-
ngx_rtsig_done(ngx_cycle_t *cycle)
|
200
|
-
{
|
201
|
-
ngx_free(overflow_list);
|
202
|
-
|
203
|
-
overflow_list = NULL;
|
204
|
-
}
|
205
|
-
|
206
|
-
|
207
|
-
static ngx_int_t
|
208
|
-
ngx_rtsig_add_connection(ngx_connection_t *c)
|
209
|
-
{
|
210
|
-
ngx_uint_t signo;
|
211
|
-
ngx_rtsig_conf_t *rtscf;
|
212
|
-
|
213
|
-
if (c->read->accept && c->read->disabled) {
|
214
|
-
|
215
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
216
|
-
"rtsig enable connection: fd:%d", c->fd);
|
217
|
-
|
218
|
-
if (fcntl(c->fd, F_SETOWN, ngx_pid) == -1) {
|
219
|
-
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
220
|
-
"fcntl(F_SETOWN) failed");
|
221
|
-
return NGX_ERROR;
|
222
|
-
}
|
223
|
-
|
224
|
-
c->read->active = 1;
|
225
|
-
c->read->disabled = 0;
|
226
|
-
}
|
227
|
-
|
228
|
-
rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module);
|
229
|
-
|
230
|
-
signo = rtscf->signo + c->read->instance;
|
231
|
-
|
232
|
-
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
233
|
-
"rtsig add connection: fd:%d signo:%ui", c->fd, signo);
|
234
|
-
|
235
|
-
if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC) == -1) {
|
236
|
-
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
237
|
-
"fcntl(O_RDWR|O_NONBLOCK|O_ASYNC) failed");
|
238
|
-
return NGX_ERROR;
|
239
|
-
}
|
240
|
-
|
241
|
-
if (fcntl(c->fd, F_SETSIG, (int) signo) == -1) {
|
242
|
-
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
243
|
-
"fcntl(F_SETSIG) failed");
|
244
|
-
return NGX_ERROR;
|
245
|
-
}
|
246
|
-
|
247
|
-
if (fcntl(c->fd, F_SETOWN, ngx_pid) == -1) {
|
248
|
-
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
249
|
-
"fcntl(F_SETOWN) failed");
|
250
|
-
return NGX_ERROR;
|
251
|
-
}
|
252
|
-
|
253
|
-
#if (NGX_HAVE_ONESIGFD)
|
254
|
-
if (fcntl(c->fd, F_SETAUXFL, O_ONESIGFD) == -1) {
|
255
|
-
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
256
|
-
"fcntl(F_SETAUXFL) failed");
|
257
|
-
return NGX_ERROR;
|
258
|
-
}
|
259
|
-
#endif
|
260
|
-
|
261
|
-
c->read->active = 1;
|
262
|
-
c->write->active = 1;
|
263
|
-
|
264
|
-
return NGX_OK;
|
265
|
-
}
|
266
|
-
|
267
|
-
|
268
|
-
static ngx_int_t
|
269
|
-
ngx_rtsig_del_connection(ngx_connection_t *c, ngx_uint_t flags)
|
270
|
-
{
|
271
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
272
|
-
"rtsig del connection: fd:%d", c->fd);
|
273
|
-
|
274
|
-
if ((flags & NGX_DISABLE_EVENT) && c->read->accept) {
|
275
|
-
|
276
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
277
|
-
"rtsig disable connection: fd:%d", c->fd);
|
278
|
-
|
279
|
-
c->read->active = 0;
|
280
|
-
c->read->disabled = 1;
|
281
|
-
return NGX_OK;
|
282
|
-
}
|
283
|
-
|
284
|
-
if (flags & NGX_CLOSE_EVENT) {
|
285
|
-
c->read->active = 0;
|
286
|
-
c->write->active = 0;
|
287
|
-
return NGX_OK;
|
288
|
-
}
|
289
|
-
|
290
|
-
if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK) == -1) {
|
291
|
-
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
292
|
-
"fcntl(O_RDWR|O_NONBLOCK) failed");
|
293
|
-
return NGX_ERROR;
|
294
|
-
}
|
295
|
-
|
296
|
-
c->read->active = 0;
|
297
|
-
c->write->active = 0;
|
298
|
-
|
299
|
-
return NGX_OK;
|
300
|
-
}
|
301
|
-
|
302
|
-
|
303
|
-
static ngx_int_t
|
304
|
-
ngx_rtsig_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags)
|
305
|
-
{
|
306
|
-
int signo;
|
307
|
-
ngx_int_t instance;
|
308
|
-
ngx_err_t err;
|
309
|
-
siginfo_t si;
|
310
|
-
ngx_event_t *rev, *wev;
|
311
|
-
ngx_queue_t *queue;
|
312
|
-
struct timespec ts, *tp;
|
313
|
-
struct sigaction sa;
|
314
|
-
ngx_connection_t *c;
|
315
|
-
ngx_rtsig_conf_t *rtscf;
|
316
|
-
|
317
|
-
if (timer == NGX_TIMER_INFINITE) {
|
318
|
-
tp = NULL;
|
319
|
-
|
320
|
-
} else {
|
321
|
-
ts.tv_sec = timer / 1000;
|
322
|
-
ts.tv_nsec = (timer % 1000) * 1000000;
|
323
|
-
tp = &ts;
|
324
|
-
}
|
325
|
-
|
326
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
327
|
-
"rtsig timer: %M", timer);
|
328
|
-
|
329
|
-
/* Linux's sigwaitinfo() is sigtimedwait() with the NULL timeout pointer */
|
330
|
-
|
331
|
-
signo = sigtimedwait(&set, &si, tp);
|
332
|
-
|
333
|
-
if (signo == -1) {
|
334
|
-
err = ngx_errno;
|
335
|
-
|
336
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, err,
|
337
|
-
"rtsig signo:%d", signo);
|
338
|
-
|
339
|
-
if (flags & NGX_UPDATE_TIME) {
|
340
|
-
ngx_time_update();
|
341
|
-
}
|
342
|
-
|
343
|
-
if (err == NGX_EAGAIN) {
|
344
|
-
|
345
|
-
/* timeout */
|
346
|
-
|
347
|
-
if (timer != NGX_TIMER_INFINITE) {
|
348
|
-
return NGX_AGAIN;
|
349
|
-
}
|
350
|
-
|
351
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
|
352
|
-
"sigtimedwait() returned EAGAIN without timeout");
|
353
|
-
return NGX_ERROR;
|
354
|
-
}
|
355
|
-
|
356
|
-
ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
|
357
|
-
cycle->log, err, "sigtimedwait() failed");
|
358
|
-
return NGX_ERROR;
|
359
|
-
}
|
360
|
-
|
361
|
-
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
362
|
-
"rtsig signo:%d fd:%d band:%04Xd",
|
363
|
-
signo, si.si_fd, si.si_band);
|
364
|
-
|
365
|
-
if (flags & NGX_UPDATE_TIME) {
|
366
|
-
ngx_time_update();
|
367
|
-
}
|
368
|
-
|
369
|
-
rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module);
|
370
|
-
|
371
|
-
if (signo == (int) rtscf->signo || signo == (int) rtscf->signo + 1) {
|
372
|
-
|
373
|
-
if (overflow && (ngx_uint_t) si.si_fd > overflow_current) {
|
374
|
-
return NGX_OK;
|
375
|
-
}
|
376
|
-
|
377
|
-
c = ngx_cycle->files[si.si_fd];
|
378
|
-
|
379
|
-
if (c == NULL) {
|
380
|
-
|
381
|
-
/* the stale event */
|
382
|
-
|
383
|
-
return NGX_OK;
|
384
|
-
}
|
385
|
-
|
386
|
-
instance = signo - (int) rtscf->signo;
|
387
|
-
|
388
|
-
rev = c->read;
|
389
|
-
|
390
|
-
if (rev->instance != instance) {
|
391
|
-
|
392
|
-
/*
|
393
|
-
* the stale event from a file descriptor
|
394
|
-
* that was just closed in this iteration
|
395
|
-
*/
|
396
|
-
|
397
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
398
|
-
"rtsig: stale event %p", c);
|
399
|
-
|
400
|
-
return NGX_OK;
|
401
|
-
}
|
402
|
-
|
403
|
-
if ((si.si_band & (POLLIN|POLLHUP|POLLERR)) && rev->active) {
|
404
|
-
|
405
|
-
rev->ready = 1;
|
406
|
-
|
407
|
-
if (flags & NGX_POST_EVENTS) {
|
408
|
-
queue = rev->accept ? &ngx_posted_accept_events
|
409
|
-
: &ngx_posted_events;
|
410
|
-
|
411
|
-
ngx_post_event(rev, queue);
|
412
|
-
|
413
|
-
} else {
|
414
|
-
rev->handler(rev);
|
415
|
-
}
|
416
|
-
}
|
417
|
-
|
418
|
-
wev = c->write;
|
419
|
-
|
420
|
-
if ((si.si_band & (POLLOUT|POLLHUP|POLLERR)) && wev->active) {
|
421
|
-
|
422
|
-
wev->ready = 1;
|
423
|
-
|
424
|
-
if (flags & NGX_POST_EVENTS) {
|
425
|
-
ngx_post_event(wev, &ngx_posted_events);
|
426
|
-
|
427
|
-
} else {
|
428
|
-
wev->handler(wev);
|
429
|
-
}
|
430
|
-
}
|
431
|
-
|
432
|
-
return NGX_OK;
|
433
|
-
|
434
|
-
} else if (signo == SIGALRM) {
|
435
|
-
|
436
|
-
ngx_time_update();
|
437
|
-
|
438
|
-
return NGX_OK;
|
439
|
-
|
440
|
-
} else if (signo == SIGIO) {
|
441
|
-
|
442
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
443
|
-
"rt signal queue overflowed");
|
444
|
-
|
445
|
-
/* flush the RT signal queue */
|
446
|
-
|
447
|
-
ngx_memzero(&sa, sizeof(struct sigaction));
|
448
|
-
sa.sa_handler = SIG_DFL;
|
449
|
-
sigemptyset(&sa.sa_mask);
|
450
|
-
|
451
|
-
if (sigaction(rtscf->signo, &sa, NULL) == -1) {
|
452
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
453
|
-
"sigaction(%d, SIG_DFL) failed", rtscf->signo);
|
454
|
-
}
|
455
|
-
|
456
|
-
if (sigaction(rtscf->signo + 1, &sa, NULL) == -1) {
|
457
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
458
|
-
"sigaction(%d, SIG_DFL) failed", rtscf->signo + 1);
|
459
|
-
}
|
460
|
-
|
461
|
-
overflow = 1;
|
462
|
-
overflow_current = 0;
|
463
|
-
ngx_event_actions.process_events = ngx_rtsig_process_overflow;
|
464
|
-
|
465
|
-
return NGX_ERROR;
|
466
|
-
|
467
|
-
}
|
468
|
-
|
469
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
470
|
-
"sigtimedwait() returned unexpected signal: %d", signo);
|
471
|
-
|
472
|
-
return NGX_ERROR;
|
473
|
-
}
|
474
|
-
|
475
|
-
|
476
|
-
static ngx_int_t
|
477
|
-
ngx_rtsig_process_overflow(ngx_cycle_t *cycle, ngx_msec_t timer,
|
478
|
-
ngx_uint_t flags)
|
479
|
-
{
|
480
|
-
int name[2], rtsig_max, rtsig_nr, events, ready;
|
481
|
-
size_t len;
|
482
|
-
ngx_err_t err;
|
483
|
-
ngx_uint_t tested, n, i;
|
484
|
-
ngx_event_t *rev, *wev;
|
485
|
-
ngx_queue_t *queue;
|
486
|
-
ngx_connection_t *c;
|
487
|
-
ngx_rtsig_conf_t *rtscf;
|
488
|
-
|
489
|
-
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
490
|
-
"rtsig process overflow");
|
491
|
-
|
492
|
-
rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module);
|
493
|
-
|
494
|
-
tested = 0;
|
495
|
-
|
496
|
-
for ( ;; ) {
|
497
|
-
|
498
|
-
n = 0;
|
499
|
-
while (n < rtscf->overflow_events) {
|
500
|
-
|
501
|
-
if (overflow_current == cycle->connection_n) {
|
502
|
-
break;
|
503
|
-
}
|
504
|
-
|
505
|
-
c = cycle->files[overflow_current++];
|
506
|
-
|
507
|
-
if (c == NULL || c->fd == -1) {
|
508
|
-
continue;
|
509
|
-
}
|
510
|
-
|
511
|
-
events = 0;
|
512
|
-
|
513
|
-
if (c->read->active && c->read->handler) {
|
514
|
-
events |= POLLIN;
|
515
|
-
}
|
516
|
-
|
517
|
-
if (c->write->active && c->write->handler) {
|
518
|
-
events |= POLLOUT;
|
519
|
-
}
|
520
|
-
|
521
|
-
if (events == 0) {
|
522
|
-
continue;
|
523
|
-
}
|
524
|
-
|
525
|
-
overflow_list[n].fd = c->fd;
|
526
|
-
overflow_list[n].events = events;
|
527
|
-
overflow_list[n].revents = 0;
|
528
|
-
n++;
|
529
|
-
}
|
530
|
-
|
531
|
-
if (n == 0) {
|
532
|
-
break;
|
533
|
-
}
|
534
|
-
|
535
|
-
for ( ;; ) {
|
536
|
-
ready = poll(overflow_list, n, 0);
|
537
|
-
|
538
|
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
539
|
-
"rtsig overflow poll:%d", ready);
|
540
|
-
|
541
|
-
if (ready == -1) {
|
542
|
-
err = ngx_errno;
|
543
|
-
ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
|
544
|
-
cycle->log, 0,
|
545
|
-
"poll() failed while the overflow recover");
|
546
|
-
|
547
|
-
if (err == NGX_EINTR) {
|
548
|
-
continue;
|
549
|
-
}
|
550
|
-
}
|
551
|
-
|
552
|
-
break;
|
553
|
-
}
|
554
|
-
|
555
|
-
if (ready <= 0) {
|
556
|
-
continue;
|
557
|
-
}
|
558
|
-
|
559
|
-
for (i = 0; i < n; i++) {
|
560
|
-
c = cycle->files[overflow_list[i].fd];
|
561
|
-
|
562
|
-
if (c == NULL) {
|
563
|
-
continue;
|
564
|
-
}
|
565
|
-
|
566
|
-
rev = c->read;
|
567
|
-
|
568
|
-
if (rev->active
|
569
|
-
&& !rev->closed
|
570
|
-
&& rev->handler
|
571
|
-
&& (overflow_list[i].revents
|
572
|
-
& (POLLIN|POLLERR|POLLHUP|POLLNVAL)))
|
573
|
-
{
|
574
|
-
tested++;
|
575
|
-
|
576
|
-
rev->ready = 1;
|
577
|
-
|
578
|
-
if (flags & NGX_POST_EVENTS) {
|
579
|
-
queue = rev->accept ? &ngx_posted_accept_events
|
580
|
-
: &ngx_posted_events;
|
581
|
-
|
582
|
-
ngx_post_event(rev, queue);
|
583
|
-
|
584
|
-
} else {
|
585
|
-
rev->handler(rev);
|
586
|
-
}
|
587
|
-
}
|
588
|
-
|
589
|
-
wev = c->write;
|
590
|
-
|
591
|
-
if (wev->active
|
592
|
-
&& !wev->closed
|
593
|
-
&& wev->handler
|
594
|
-
&& (overflow_list[i].revents
|
595
|
-
& (POLLOUT|POLLERR|POLLHUP|POLLNVAL)))
|
596
|
-
{
|
597
|
-
tested++;
|
598
|
-
|
599
|
-
wev->ready = 1;
|
600
|
-
|
601
|
-
if (flags & NGX_POST_EVENTS) {
|
602
|
-
ngx_post_event(wev, &ngx_posted_events);
|
603
|
-
|
604
|
-
} else {
|
605
|
-
wev->handler(wev);
|
606
|
-
}
|
607
|
-
}
|
608
|
-
}
|
609
|
-
|
610
|
-
if (tested >= rtscf->overflow_test) {
|
611
|
-
|
612
|
-
if (ngx_linux_rtsig_max) {
|
613
|
-
|
614
|
-
/*
|
615
|
-
* Check the current rt queue length to prevent
|
616
|
-
* the new overflow.
|
617
|
-
*
|
618
|
-
* learn the "/proc/sys/kernel/rtsig-max" value because
|
619
|
-
* it can be changed since the last checking
|
620
|
-
*/
|
621
|
-
|
622
|
-
name[0] = CTL_KERN;
|
623
|
-
name[1] = KERN_RTSIGMAX;
|
624
|
-
len = sizeof(rtsig_max);
|
625
|
-
|
626
|
-
if (sysctl(name, 2, &rtsig_max, &len, NULL, 0) == -1) {
|
627
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, errno,
|
628
|
-
"sysctl(KERN_RTSIGMAX) failed");
|
629
|
-
return NGX_ERROR;
|
630
|
-
}
|
631
|
-
|
632
|
-
/* name[0] = CTL_KERN; */
|
633
|
-
name[1] = KERN_RTSIGNR;
|
634
|
-
len = sizeof(rtsig_nr);
|
635
|
-
|
636
|
-
if (sysctl(name, 2, &rtsig_nr, &len, NULL, 0) == -1) {
|
637
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, errno,
|
638
|
-
"sysctl(KERN_RTSIGNR) failed");
|
639
|
-
return NGX_ERROR;
|
640
|
-
}
|
641
|
-
|
642
|
-
/*
|
643
|
-
* drain the rt signal queue if the /"proc/sys/kernel/rtsig-nr"
|
644
|
-
* is bigger than
|
645
|
-
* "/proc/sys/kernel/rtsig-max" / "rtsig_overflow_threshold"
|
646
|
-
*/
|
647
|
-
|
648
|
-
if (rtsig_max / (int) rtscf->overflow_threshold < rtsig_nr) {
|
649
|
-
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
650
|
-
"rtsig queue state: %d/%d",
|
651
|
-
rtsig_nr, rtsig_max);
|
652
|
-
while (ngx_rtsig_process_events(cycle, 0, flags) == NGX_OK)
|
653
|
-
{
|
654
|
-
/* void */
|
655
|
-
}
|
656
|
-
}
|
657
|
-
|
658
|
-
} else {
|
659
|
-
|
660
|
-
/*
|
661
|
-
* Linux has not KERN_RTSIGMAX since 2.6.6-mm2
|
662
|
-
* so drain the rt signal queue unconditionally
|
663
|
-
*/
|
664
|
-
|
665
|
-
while (ngx_rtsig_process_events(cycle, 0, flags) == NGX_OK) {
|
666
|
-
/* void */
|
667
|
-
}
|
668
|
-
}
|
669
|
-
|
670
|
-
tested = 0;
|
671
|
-
}
|
672
|
-
}
|
673
|
-
|
674
|
-
if (flags & NGX_UPDATE_TIME) {
|
675
|
-
ngx_time_update();
|
676
|
-
}
|
677
|
-
|
678
|
-
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
679
|
-
"rt signal queue overflow recovered");
|
680
|
-
|
681
|
-
overflow = 0;
|
682
|
-
ngx_event_actions.process_events = ngx_rtsig_process_events;
|
683
|
-
|
684
|
-
return NGX_OK;
|
685
|
-
}
|
686
|
-
|
687
|
-
|
688
|
-
static void *
|
689
|
-
ngx_rtsig_create_conf(ngx_cycle_t *cycle)
|
690
|
-
{
|
691
|
-
ngx_rtsig_conf_t *rtscf;
|
692
|
-
|
693
|
-
rtscf = ngx_palloc(cycle->pool, sizeof(ngx_rtsig_conf_t));
|
694
|
-
if (rtscf == NULL) {
|
695
|
-
return NULL;
|
696
|
-
}
|
697
|
-
|
698
|
-
rtscf->signo = NGX_CONF_UNSET;
|
699
|
-
rtscf->overflow_events = NGX_CONF_UNSET;
|
700
|
-
rtscf->overflow_test = NGX_CONF_UNSET;
|
701
|
-
rtscf->overflow_threshold = NGX_CONF_UNSET;
|
702
|
-
|
703
|
-
return rtscf;
|
704
|
-
}
|
705
|
-
|
706
|
-
|
707
|
-
static char *
|
708
|
-
ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf)
|
709
|
-
{
|
710
|
-
ngx_rtsig_conf_t *rtscf = conf;
|
711
|
-
|
712
|
-
/* LinuxThreads use the first 3 RT signals */
|
713
|
-
ngx_conf_init_uint_value(rtscf->signo, SIGRTMIN + 10);
|
714
|
-
|
715
|
-
ngx_conf_init_uint_value(rtscf->overflow_events, 16);
|
716
|
-
ngx_conf_init_uint_value(rtscf->overflow_test, 32);
|
717
|
-
ngx_conf_init_uint_value(rtscf->overflow_threshold, 10);
|
718
|
-
|
719
|
-
return NGX_CONF_OK;
|
720
|
-
}
|
721
|
-
|
722
|
-
|
723
|
-
static char *
|
724
|
-
ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf, void *post, void *data)
|
725
|
-
{
|
726
|
-
if (ngx_linux_rtsig_max) {
|
727
|
-
return ngx_conf_check_num_bounds(cf, post, data);
|
728
|
-
}
|
729
|
-
|
730
|
-
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
731
|
-
"\"rtsig_overflow_threshold\" is not supported "
|
732
|
-
"since Linux 2.6.6-mm2, ignored");
|
733
|
-
|
734
|
-
return NGX_CONF_OK;
|
735
|
-
}
|