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
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Maxim Dounin
|
4
|
+
* Copyright (C) Nginx, Inc.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#include <ngx_config.h>
|
9
|
+
#include <ngx_core.h>
|
10
|
+
|
11
|
+
|
12
|
+
#if (NGX_HAVE_DLOPEN)
|
13
|
+
|
14
|
+
char *
|
15
|
+
ngx_dlerror(void)
|
16
|
+
{
|
17
|
+
char *err;
|
18
|
+
|
19
|
+
err = (char *) dlerror();
|
20
|
+
|
21
|
+
if (err == NULL) {
|
22
|
+
return "";
|
23
|
+
}
|
24
|
+
|
25
|
+
return err;
|
26
|
+
}
|
27
|
+
|
28
|
+
#endif
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Maxim Dounin
|
4
|
+
* Copyright (C) Nginx, Inc.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#ifndef _NGX_DLOPEN_H_INCLUDED_
|
9
|
+
#define _NGX_DLOPEN_H_INCLUDED_
|
10
|
+
|
11
|
+
|
12
|
+
#include <ngx_config.h>
|
13
|
+
#include <ngx_core.h>
|
14
|
+
|
15
|
+
|
16
|
+
#define ngx_dlopen(path) dlopen((char *) path, RTLD_NOW | RTLD_GLOBAL)
|
17
|
+
#define ngx_dlopen_n "dlopen()"
|
18
|
+
|
19
|
+
#define ngx_dlsym(handle, symbol) dlsym(handle, symbol)
|
20
|
+
#define ngx_dlsym_n "dlsym()"
|
21
|
+
|
22
|
+
#define ngx_dlclose(handle) dlclose(handle)
|
23
|
+
#define ngx_dlclose_n "dlclose()"
|
24
|
+
|
25
|
+
|
26
|
+
#if (NGX_HAVE_DLOPEN)
|
27
|
+
char *ngx_dlerror(void);
|
28
|
+
#endif
|
29
|
+
|
30
|
+
|
31
|
+
#endif /* _NGX_DLOPEN_H_INCLUDED_ */
|
@@ -84,7 +84,7 @@ ngx_file_aio_read(ngx_file_t *file, u_char *buf, size_t size, off_t offset,
|
|
84
84
|
}
|
85
85
|
|
86
86
|
ngx_log_debug4(NGX_LOG_DEBUG_CORE, file->log, 0,
|
87
|
-
"aio complete:%d @%O:%
|
87
|
+
"aio complete:%d @%O:%uz %V",
|
88
88
|
ev->complete, offset, size, &file->name);
|
89
89
|
|
90
90
|
if (ev->complete) {
|
@@ -12,8 +12,13 @@
|
|
12
12
|
#if (NGX_THREADS)
|
13
13
|
#include <ngx_thread_pool.h>
|
14
14
|
static void ngx_thread_read_handler(void *data, ngx_log_t *log);
|
15
|
+
static void ngx_thread_write_chain_to_file_handler(void *data, ngx_log_t *log);
|
15
16
|
#endif
|
16
17
|
|
18
|
+
static ngx_chain_t *ngx_chain_to_iovec(ngx_iovec_t *vec, ngx_chain_t *cl);
|
19
|
+
static ssize_t ngx_writev_file(ngx_file_t *file, ngx_iovec_t *vec,
|
20
|
+
off_t offset);
|
21
|
+
|
17
22
|
|
18
23
|
#if (NGX_HAVE_FILE_AIO)
|
19
24
|
|
@@ -73,38 +78,39 @@ ngx_read_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset)
|
|
73
78
|
#if (NGX_THREADS)
|
74
79
|
|
75
80
|
typedef struct {
|
76
|
-
ngx_fd_t
|
77
|
-
|
78
|
-
|
79
|
-
|
81
|
+
ngx_fd_t fd;
|
82
|
+
ngx_uint_t write; /* unsigned write:1; */
|
83
|
+
|
84
|
+
u_char *buf;
|
85
|
+
size_t size;
|
86
|
+
ngx_chain_t *chain;
|
87
|
+
off_t offset;
|
80
88
|
|
81
|
-
size_t
|
82
|
-
ngx_err_t
|
83
|
-
}
|
89
|
+
size_t nbytes;
|
90
|
+
ngx_err_t err;
|
91
|
+
} ngx_thread_file_ctx_t;
|
84
92
|
|
85
93
|
|
86
94
|
ssize_t
|
87
|
-
ngx_thread_read(
|
88
|
-
|
95
|
+
ngx_thread_read(ngx_file_t *file, u_char *buf, size_t size, off_t offset,
|
96
|
+
ngx_pool_t *pool)
|
89
97
|
{
|
90
98
|
ngx_thread_task_t *task;
|
91
|
-
|
99
|
+
ngx_thread_file_ctx_t *ctx;
|
92
100
|
|
93
101
|
ngx_log_debug4(NGX_LOG_DEBUG_CORE, file->log, 0,
|
94
102
|
"thread read: %d, %p, %uz, %O",
|
95
103
|
file->fd, buf, size, offset);
|
96
104
|
|
97
|
-
task =
|
105
|
+
task = file->thread_task;
|
98
106
|
|
99
107
|
if (task == NULL) {
|
100
|
-
task = ngx_thread_task_alloc(pool, sizeof(
|
108
|
+
task = ngx_thread_task_alloc(pool, sizeof(ngx_thread_file_ctx_t));
|
101
109
|
if (task == NULL) {
|
102
110
|
return NGX_ERROR;
|
103
111
|
}
|
104
112
|
|
105
|
-
|
106
|
-
|
107
|
-
*taskp = task;
|
113
|
+
file->thread_task = task;
|
108
114
|
}
|
109
115
|
|
110
116
|
ctx = task->ctx;
|
@@ -112,15 +118,25 @@ ngx_thread_read(ngx_thread_task_t **taskp, ngx_file_t *file, u_char *buf,
|
|
112
118
|
if (task->event.complete) {
|
113
119
|
task->event.complete = 0;
|
114
120
|
|
121
|
+
if (ctx->write) {
|
122
|
+
ngx_log_error(NGX_LOG_ALERT, file->log, 0,
|
123
|
+
"invalid thread call, read instead of write");
|
124
|
+
return NGX_ERROR;
|
125
|
+
}
|
126
|
+
|
115
127
|
if (ctx->err) {
|
116
128
|
ngx_log_error(NGX_LOG_CRIT, file->log, ctx->err,
|
117
129
|
"pread() \"%s\" failed", file->name.data);
|
118
130
|
return NGX_ERROR;
|
119
131
|
}
|
120
132
|
|
121
|
-
return ctx->
|
133
|
+
return ctx->nbytes;
|
122
134
|
}
|
123
135
|
|
136
|
+
task->handler = ngx_thread_read_handler;
|
137
|
+
|
138
|
+
ctx->write = 0;
|
139
|
+
|
124
140
|
ctx->fd = file->fd;
|
125
141
|
ctx->buf = buf;
|
126
142
|
ctx->size = size;
|
@@ -139,7 +155,7 @@ ngx_thread_read(ngx_thread_task_t **taskp, ngx_file_t *file, u_char *buf,
|
|
139
155
|
static void
|
140
156
|
ngx_thread_read_handler(void *data, ngx_log_t *log)
|
141
157
|
{
|
142
|
-
|
158
|
+
ngx_thread_file_ctx_t *ctx = data;
|
143
159
|
|
144
160
|
ssize_t n;
|
145
161
|
|
@@ -151,7 +167,7 @@ ngx_thread_read_handler(void *data, ngx_log_t *log)
|
|
151
167
|
ctx->err = ngx_errno;
|
152
168
|
|
153
169
|
} else {
|
154
|
-
ctx->
|
170
|
+
ctx->nbytes = n;
|
155
171
|
ctx->err = 0;
|
156
172
|
}
|
157
173
|
|
@@ -160,7 +176,7 @@ ngx_thread_read_handler(void *data, ngx_log_t *log)
|
|
160
176
|
#endif
|
161
177
|
|
162
178
|
ngx_log_debug4(NGX_LOG_DEBUG_CORE, log, 0,
|
163
|
-
"pread: %z (err: %
|
179
|
+
"pread: %z (err: %d) of %uz @%O",
|
164
180
|
n, ctx->err, ctx->size, ctx->offset);
|
165
181
|
}
|
166
182
|
|
@@ -176,7 +192,8 @@ ngx_thread_read_handler(void *data, ngx_log_t *log)
|
|
176
192
|
ssize_t
|
177
193
|
ngx_write_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset)
|
178
194
|
{
|
179
|
-
ssize_t
|
195
|
+
ssize_t n, written;
|
196
|
+
ngx_err_t err;
|
180
197
|
|
181
198
|
ngx_log_debug4(NGX_LOG_DEBUG_CORE, file->log, 0,
|
182
199
|
"write: %d, %p, %uz, %O", file->fd, buf, size, offset);
|
@@ -189,7 +206,15 @@ ngx_write_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset)
|
|
189
206
|
n = pwrite(file->fd, buf + written, size, offset);
|
190
207
|
|
191
208
|
if (n == -1) {
|
192
|
-
|
209
|
+
err = ngx_errno;
|
210
|
+
|
211
|
+
if (err == NGX_EINTR) {
|
212
|
+
ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
|
213
|
+
"pwrite() was interrupted");
|
214
|
+
continue;
|
215
|
+
}
|
216
|
+
|
217
|
+
ngx_log_error(NGX_LOG_CRIT, file->log, err,
|
193
218
|
"pwrite() \"%s\" failed", file->name.data);
|
194
219
|
return NGX_ERROR;
|
195
220
|
}
|
@@ -221,11 +246,20 @@ ngx_write_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset)
|
|
221
246
|
n = write(file->fd, buf + written, size);
|
222
247
|
|
223
248
|
if (n == -1) {
|
224
|
-
|
249
|
+
err = ngx_errno;
|
250
|
+
|
251
|
+
if (err == NGX_EINTR) {
|
252
|
+
ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
|
253
|
+
"write() was interrupted");
|
254
|
+
continue;
|
255
|
+
}
|
256
|
+
|
257
|
+
ngx_log_error(NGX_LOG_CRIT, file->log, err,
|
225
258
|
"write() \"%s\" failed", file->name.data);
|
226
259
|
return NGX_ERROR;
|
227
260
|
}
|
228
261
|
|
262
|
+
file->sys_offset += n;
|
229
263
|
file->offset += n;
|
230
264
|
written += n;
|
231
265
|
|
@@ -255,17 +289,13 @@ ngx_open_tempfile(u_char *name, ngx_uint_t persistent, ngx_uint_t access)
|
|
255
289
|
}
|
256
290
|
|
257
291
|
|
258
|
-
#define NGX_IOVS 8
|
259
|
-
|
260
292
|
ssize_t
|
261
293
|
ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset,
|
262
294
|
ngx_pool_t *pool)
|
263
295
|
{
|
264
|
-
u_char *prev;
|
265
|
-
size_t size;
|
266
296
|
ssize_t total, n;
|
267
|
-
|
268
|
-
struct iovec
|
297
|
+
ngx_iovec_t vec;
|
298
|
+
struct iovec iovs[NGX_IOVS_PREALLOCATE];
|
269
299
|
|
270
300
|
/* use pwrite() if there is the only buf in a chain */
|
271
301
|
|
@@ -277,92 +307,295 @@ ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset,
|
|
277
307
|
|
278
308
|
total = 0;
|
279
309
|
|
280
|
-
vec.
|
281
|
-
vec.
|
282
|
-
vec.nalloc = NGX_IOVS;
|
283
|
-
vec.pool = pool;
|
310
|
+
vec.iovs = iovs;
|
311
|
+
vec.nalloc = NGX_IOVS_PREALLOCATE;
|
284
312
|
|
285
313
|
do {
|
286
|
-
prev = NULL;
|
287
|
-
iov = NULL;
|
288
|
-
size = 0;
|
289
|
-
|
290
|
-
vec.nelts = 0;
|
291
|
-
|
292
314
|
/* create the iovec and coalesce the neighbouring bufs */
|
315
|
+
cl = ngx_chain_to_iovec(&vec, cl);
|
293
316
|
|
294
|
-
|
295
|
-
if (prev == cl->buf->pos) {
|
296
|
-
iov->iov_len += cl->buf->last - cl->buf->pos;
|
317
|
+
/* use pwrite() if there is the only iovec buffer */
|
297
318
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
return NGX_ERROR;
|
302
|
-
}
|
319
|
+
if (vec.count == 1) {
|
320
|
+
n = ngx_write_file(file, (u_char *) iovs[0].iov_base,
|
321
|
+
iovs[0].iov_len, offset);
|
303
322
|
|
304
|
-
|
305
|
-
|
323
|
+
if (n == NGX_ERROR) {
|
324
|
+
return n;
|
306
325
|
}
|
307
326
|
|
308
|
-
|
309
|
-
prev = cl->buf->last;
|
310
|
-
cl = cl->next;
|
327
|
+
return total + n;
|
311
328
|
}
|
312
329
|
|
313
|
-
|
330
|
+
n = ngx_writev_file(file, &vec, offset);
|
314
331
|
|
315
|
-
if (
|
316
|
-
|
332
|
+
if (n == NGX_ERROR) {
|
333
|
+
return n;
|
334
|
+
}
|
317
335
|
|
318
|
-
|
319
|
-
|
336
|
+
offset += n;
|
337
|
+
total += n;
|
320
338
|
|
321
|
-
|
322
|
-
return n;
|
323
|
-
}
|
339
|
+
} while (cl);
|
324
340
|
|
325
|
-
|
341
|
+
return total;
|
342
|
+
}
|
343
|
+
|
344
|
+
|
345
|
+
static ngx_chain_t *
|
346
|
+
ngx_chain_to_iovec(ngx_iovec_t *vec, ngx_chain_t *cl)
|
347
|
+
{
|
348
|
+
size_t total, size;
|
349
|
+
u_char *prev;
|
350
|
+
ngx_uint_t n;
|
351
|
+
struct iovec *iov;
|
352
|
+
|
353
|
+
iov = NULL;
|
354
|
+
prev = NULL;
|
355
|
+
total = 0;
|
356
|
+
n = 0;
|
357
|
+
|
358
|
+
for ( /* void */ ; cl; cl = cl->next) {
|
359
|
+
|
360
|
+
if (ngx_buf_special(cl->buf)) {
|
361
|
+
continue;
|
326
362
|
}
|
327
363
|
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
364
|
+
size = cl->buf->last - cl->buf->pos;
|
365
|
+
|
366
|
+
if (prev == cl->buf->pos) {
|
367
|
+
iov->iov_len += size;
|
368
|
+
|
369
|
+
} else {
|
370
|
+
if (n == vec->nalloc) {
|
371
|
+
break;
|
333
372
|
}
|
334
373
|
|
335
|
-
|
374
|
+
iov = &vec->iovs[n++];
|
375
|
+
|
376
|
+
iov->iov_base = (void *) cl->buf->pos;
|
377
|
+
iov->iov_len = size;
|
336
378
|
}
|
337
379
|
|
338
|
-
|
380
|
+
prev = cl->buf->pos + size;
|
381
|
+
total += size;
|
382
|
+
}
|
339
383
|
|
340
|
-
|
384
|
+
vec->count = n;
|
385
|
+
vec->size = total;
|
386
|
+
|
387
|
+
return cl;
|
388
|
+
}
|
389
|
+
|
390
|
+
|
391
|
+
static ssize_t
|
392
|
+
ngx_writev_file(ngx_file_t *file, ngx_iovec_t *vec, off_t offset)
|
393
|
+
{
|
394
|
+
ssize_t n;
|
395
|
+
ngx_err_t err;
|
396
|
+
|
397
|
+
ngx_log_debug3(NGX_LOG_DEBUG_CORE, file->log, 0,
|
398
|
+
"writev: %d, %uz, %O", file->fd, vec->size, offset);
|
399
|
+
|
400
|
+
#if (NGX_HAVE_PWRITEV)
|
401
|
+
|
402
|
+
eintr:
|
403
|
+
|
404
|
+
n = pwritev(file->fd, vec->iovs, vec->count, offset);
|
405
|
+
|
406
|
+
if (n == -1) {
|
407
|
+
err = ngx_errno;
|
408
|
+
|
409
|
+
if (err == NGX_EINTR) {
|
410
|
+
ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
|
411
|
+
"pwritev() was interrupted");
|
412
|
+
goto eintr;
|
413
|
+
}
|
414
|
+
|
415
|
+
ngx_log_error(NGX_LOG_CRIT, file->log, err,
|
416
|
+
"pwritev() \"%s\" failed", file->name.data);
|
417
|
+
return NGX_ERROR;
|
418
|
+
}
|
419
|
+
|
420
|
+
if ((size_t) n != vec->size) {
|
421
|
+
ngx_log_error(NGX_LOG_CRIT, file->log, 0,
|
422
|
+
"pwritev() \"%s\" has written only %z of %uz",
|
423
|
+
file->name.data, n, vec->size);
|
424
|
+
return NGX_ERROR;
|
425
|
+
}
|
426
|
+
|
427
|
+
#else
|
428
|
+
|
429
|
+
if (file->sys_offset != offset) {
|
430
|
+
if (lseek(file->fd, offset, SEEK_SET) == -1) {
|
341
431
|
ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
|
342
|
-
"
|
432
|
+
"lseek() \"%s\" failed", file->name.data);
|
343
433
|
return NGX_ERROR;
|
344
434
|
}
|
345
435
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
436
|
+
file->sys_offset = offset;
|
437
|
+
}
|
438
|
+
|
439
|
+
eintr:
|
440
|
+
|
441
|
+
n = writev(file->fd, vec->iovs, vec->count);
|
442
|
+
|
443
|
+
if (n == -1) {
|
444
|
+
err = ngx_errno;
|
445
|
+
|
446
|
+
if (err == NGX_EINTR) {
|
447
|
+
ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
|
448
|
+
"writev() was interrupted");
|
449
|
+
goto eintr;
|
450
|
+
}
|
451
|
+
|
452
|
+
ngx_log_error(NGX_LOG_CRIT, file->log, err,
|
453
|
+
"writev() \"%s\" failed", file->name.data);
|
454
|
+
return NGX_ERROR;
|
455
|
+
}
|
456
|
+
|
457
|
+
if ((size_t) n != vec->size) {
|
458
|
+
ngx_log_error(NGX_LOG_CRIT, file->log, 0,
|
459
|
+
"writev() \"%s\" has written only %z of %uz",
|
460
|
+
file->name.data, n, vec->size);
|
461
|
+
return NGX_ERROR;
|
462
|
+
}
|
463
|
+
|
464
|
+
file->sys_offset += n;
|
465
|
+
|
466
|
+
#endif
|
467
|
+
|
468
|
+
file->offset += n;
|
469
|
+
|
470
|
+
return n;
|
471
|
+
}
|
472
|
+
|
473
|
+
|
474
|
+
#if (NGX_THREADS)
|
475
|
+
|
476
|
+
ssize_t
|
477
|
+
ngx_thread_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset,
|
478
|
+
ngx_pool_t *pool)
|
479
|
+
{
|
480
|
+
ngx_thread_task_t *task;
|
481
|
+
ngx_thread_file_ctx_t *ctx;
|
482
|
+
|
483
|
+
ngx_log_debug3(NGX_LOG_DEBUG_CORE, file->log, 0,
|
484
|
+
"thread write chain: %d, %p, %O",
|
485
|
+
file->fd, cl, offset);
|
486
|
+
|
487
|
+
task = file->thread_task;
|
488
|
+
|
489
|
+
if (task == NULL) {
|
490
|
+
task = ngx_thread_task_alloc(pool,
|
491
|
+
sizeof(ngx_thread_file_ctx_t));
|
492
|
+
if (task == NULL) {
|
350
493
|
return NGX_ERROR;
|
351
494
|
}
|
352
495
|
|
353
|
-
|
354
|
-
|
496
|
+
file->thread_task = task;
|
497
|
+
}
|
355
498
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
499
|
+
ctx = task->ctx;
|
500
|
+
|
501
|
+
if (task->event.complete) {
|
502
|
+
task->event.complete = 0;
|
503
|
+
|
504
|
+
if (!ctx->write) {
|
505
|
+
ngx_log_error(NGX_LOG_ALERT, file->log, 0,
|
506
|
+
"invalid thread call, write instead of read");
|
507
|
+
return NGX_ERROR;
|
508
|
+
}
|
509
|
+
|
510
|
+
if (ctx->err || ctx->nbytes == 0) {
|
511
|
+
ngx_log_error(NGX_LOG_CRIT, file->log, ctx->err,
|
512
|
+
"pwritev() \"%s\" failed", file->name.data);
|
513
|
+
return NGX_ERROR;
|
514
|
+
}
|
515
|
+
|
516
|
+
file->offset += ctx->nbytes;
|
517
|
+
return ctx->nbytes;
|
518
|
+
}
|
519
|
+
|
520
|
+
task->handler = ngx_thread_write_chain_to_file_handler;
|
521
|
+
|
522
|
+
ctx->write = 1;
|
523
|
+
|
524
|
+
ctx->fd = file->fd;
|
525
|
+
ctx->chain = cl;
|
526
|
+
ctx->offset = offset;
|
527
|
+
|
528
|
+
if (file->thread_handler(task, file) != NGX_OK) {
|
529
|
+
return NGX_ERROR;
|
530
|
+
}
|
531
|
+
|
532
|
+
return NGX_AGAIN;
|
533
|
+
}
|
534
|
+
|
535
|
+
|
536
|
+
static void
|
537
|
+
ngx_thread_write_chain_to_file_handler(void *data, ngx_log_t *log)
|
538
|
+
{
|
539
|
+
ngx_thread_file_ctx_t *ctx = data;
|
540
|
+
|
541
|
+
#if (NGX_HAVE_PWRITEV)
|
542
|
+
|
543
|
+
off_t offset;
|
544
|
+
ssize_t n;
|
545
|
+
ngx_err_t err;
|
546
|
+
ngx_chain_t *cl;
|
547
|
+
ngx_iovec_t vec;
|
548
|
+
struct iovec iovs[NGX_IOVS_PREALLOCATE];
|
549
|
+
|
550
|
+
vec.iovs = iovs;
|
551
|
+
vec.nalloc = NGX_IOVS_PREALLOCATE;
|
552
|
+
|
553
|
+
cl = ctx->chain;
|
554
|
+
offset = ctx->offset;
|
555
|
+
|
556
|
+
ctx->nbytes = 0;
|
557
|
+
ctx->err = 0;
|
360
558
|
|
559
|
+
do {
|
560
|
+
/* create the iovec and coalesce the neighbouring bufs */
|
561
|
+
cl = ngx_chain_to_iovec(&vec, cl);
|
562
|
+
|
563
|
+
eintr:
|
564
|
+
|
565
|
+
n = pwritev(ctx->fd, iovs, vec.count, offset);
|
566
|
+
|
567
|
+
if (n == -1) {
|
568
|
+
err = ngx_errno;
|
569
|
+
|
570
|
+
if (err == NGX_EINTR) {
|
571
|
+
ngx_log_debug0(NGX_LOG_DEBUG_CORE, log, err,
|
572
|
+
"pwritev() was interrupted");
|
573
|
+
goto eintr;
|
574
|
+
}
|
575
|
+
|
576
|
+
ctx->err = err;
|
577
|
+
return;
|
578
|
+
}
|
579
|
+
|
580
|
+
if ((size_t) n != vec.size) {
|
581
|
+
ctx->nbytes = 0;
|
582
|
+
return;
|
583
|
+
}
|
584
|
+
|
585
|
+
ctx->nbytes += n;
|
586
|
+
offset += n;
|
361
587
|
} while (cl);
|
362
588
|
|
363
|
-
|
589
|
+
#else
|
590
|
+
|
591
|
+
ctx->err = NGX_ENOSYS;
|
592
|
+
return;
|
593
|
+
|
594
|
+
#endif
|
364
595
|
}
|
365
596
|
|
597
|
+
#endif /* NGX_THREADS */
|
598
|
+
|
366
599
|
|
367
600
|
ngx_int_t
|
368
601
|
ngx_set_file_time(u_char *name, ngx_fd_t fd, time_t s)
|