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
@@ -0,0 +1,174 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Igor Sysoev
|
4
|
+
* Copyright (C) Nginx, Inc.
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include <ngx_config.h>
|
8
|
+
#include <ngx_core.h>
|
9
|
+
|
10
|
+
|
11
|
+
/*
|
12
|
+
* All modern pthread mutex implementations try to acquire a lock
|
13
|
+
* atomically in userland before going to sleep in kernel. Some
|
14
|
+
* spins before the sleeping.
|
15
|
+
*
|
16
|
+
* In Solaris since version 8 all mutex types spin before sleeping.
|
17
|
+
* The default spin count is 1000. It can be overridden using
|
18
|
+
* _THREAD_ADAPTIVE_SPIN=100 environment variable.
|
19
|
+
*
|
20
|
+
* In MacOSX all mutex types spin to acquire a lock protecting a mutex's
|
21
|
+
* internals. If the mutex is busy, thread calls Mach semaphore_wait().
|
22
|
+
*
|
23
|
+
*
|
24
|
+
* PTHREAD_MUTEX_NORMAL lacks deadlock detection and is the fastest
|
25
|
+
* mutex type.
|
26
|
+
*
|
27
|
+
* Linux: No spinning. The internal name PTHREAD_MUTEX_TIMED_NP
|
28
|
+
* remains from the times when pthread_mutex_timedlock() was
|
29
|
+
* non-standard extension. Alias name: PTHREAD_MUTEX_FAST_NP.
|
30
|
+
* FreeBSD: No spinning.
|
31
|
+
*
|
32
|
+
*
|
33
|
+
* PTHREAD_MUTEX_ERRORCHECK is usually as fast as PTHREAD_MUTEX_NORMAL
|
34
|
+
* yet has lightweight deadlock detection.
|
35
|
+
*
|
36
|
+
* Linux: No spinning. The internal name: PTHREAD_MUTEX_ERRORCHECK_NP.
|
37
|
+
* FreeBSD: No spinning.
|
38
|
+
*
|
39
|
+
*
|
40
|
+
* PTHREAD_MUTEX_RECURSIVE allows recursive locking.
|
41
|
+
*
|
42
|
+
* Linux: No spinning. The internal name: PTHREAD_MUTEX_RECURSIVE_NP.
|
43
|
+
* FreeBSD: No spinning.
|
44
|
+
*
|
45
|
+
*
|
46
|
+
* PTHREAD_MUTEX_ADAPTIVE_NP spins on SMP systems before sleeping.
|
47
|
+
*
|
48
|
+
* Linux: No deadlock detection. Dynamically changes a spin count
|
49
|
+
* for each mutex from 10 to 100 based on spin count taken
|
50
|
+
* previously.
|
51
|
+
* FreeBSD: Deadlock detection. The default spin count is 2000.
|
52
|
+
* It can be overriden using LIBPTHREAD_SPINLOOPS environment
|
53
|
+
* variable or by pthread_mutex_setspinloops_np(). If a lock
|
54
|
+
* is still busy, sched_yield() can be called on both UP and
|
55
|
+
* SMP systems. The default yield loop count is zero, but
|
56
|
+
* it can be set by LIBPTHREAD_YIELDLOOPS environment
|
57
|
+
* variable or by pthread_mutex_setyieldloops_np().
|
58
|
+
* Solaris: No PTHREAD_MUTEX_ADAPTIVE_NP.
|
59
|
+
* MacOSX: No PTHREAD_MUTEX_ADAPTIVE_NP.
|
60
|
+
*
|
61
|
+
*
|
62
|
+
* PTHREAD_MUTEX_ELISION_NP is a Linux extension to elide locks using
|
63
|
+
* Intel Restricted Transactional Memory. It is the most suitable for
|
64
|
+
* rwlock pattern access because it allows simultaneous reads without lock.
|
65
|
+
* Supported since glibc 2.18.
|
66
|
+
*
|
67
|
+
*
|
68
|
+
* PTHREAD_MUTEX_DEFAULT is default mutex type.
|
69
|
+
*
|
70
|
+
* Linux: PTHREAD_MUTEX_NORMAL.
|
71
|
+
* FreeBSD: PTHREAD_MUTEX_ERRORCHECK.
|
72
|
+
* Solaris: PTHREAD_MUTEX_NORMAL.
|
73
|
+
* MacOSX: PTHREAD_MUTEX_NORMAL.
|
74
|
+
*/
|
75
|
+
|
76
|
+
|
77
|
+
ngx_int_t
|
78
|
+
ngx_thread_mutex_create(ngx_thread_mutex_t *mtx, ngx_log_t *log)
|
79
|
+
{
|
80
|
+
ngx_err_t err;
|
81
|
+
pthread_mutexattr_t attr;
|
82
|
+
|
83
|
+
err = pthread_mutexattr_init(&attr);
|
84
|
+
if (err != 0) {
|
85
|
+
ngx_log_error(NGX_LOG_EMERG, log, err,
|
86
|
+
"pthread_mutexattr_init() failed");
|
87
|
+
return NGX_ERROR;
|
88
|
+
}
|
89
|
+
|
90
|
+
err = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
|
91
|
+
if (err != 0) {
|
92
|
+
ngx_log_error(NGX_LOG_EMERG, log, err,
|
93
|
+
"pthread_mutexattr_settype"
|
94
|
+
"(PTHREAD_MUTEX_ERRORCHECK) failed");
|
95
|
+
return NGX_ERROR;
|
96
|
+
}
|
97
|
+
|
98
|
+
err = pthread_mutex_init(mtx, &attr);
|
99
|
+
if (err != 0) {
|
100
|
+
ngx_log_error(NGX_LOG_EMERG, log, err,
|
101
|
+
"pthread_mutex_init() failed");
|
102
|
+
return NGX_ERROR;
|
103
|
+
}
|
104
|
+
|
105
|
+
err = pthread_mutexattr_destroy(&attr);
|
106
|
+
if (err != 0) {
|
107
|
+
ngx_log_error(NGX_LOG_ALERT, log, err,
|
108
|
+
"pthread_mutexattr_destroy() failed");
|
109
|
+
}
|
110
|
+
|
111
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0,
|
112
|
+
"pthread_mutex_init(%p)", mtx);
|
113
|
+
return NGX_OK;
|
114
|
+
}
|
115
|
+
|
116
|
+
|
117
|
+
ngx_int_t
|
118
|
+
ngx_thread_mutex_destroy(ngx_thread_mutex_t *mtx, ngx_log_t *log)
|
119
|
+
{
|
120
|
+
ngx_err_t err;
|
121
|
+
|
122
|
+
err = pthread_mutex_destroy(mtx);
|
123
|
+
if (err != 0) {
|
124
|
+
ngx_log_error(NGX_LOG_ALERT, log, err,
|
125
|
+
"pthread_mutex_destroy() failed");
|
126
|
+
return NGX_ERROR;
|
127
|
+
}
|
128
|
+
|
129
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0,
|
130
|
+
"pthread_mutex_destroy(%p)", mtx);
|
131
|
+
return NGX_OK;
|
132
|
+
}
|
133
|
+
|
134
|
+
|
135
|
+
ngx_int_t
|
136
|
+
ngx_thread_mutex_lock(ngx_thread_mutex_t *mtx, ngx_log_t *log)
|
137
|
+
{
|
138
|
+
ngx_err_t err;
|
139
|
+
|
140
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0,
|
141
|
+
"pthread_mutex_lock(%p) enter", mtx);
|
142
|
+
|
143
|
+
err = pthread_mutex_lock(mtx);
|
144
|
+
if (err == 0) {
|
145
|
+
return NGX_OK;
|
146
|
+
}
|
147
|
+
|
148
|
+
ngx_log_error(NGX_LOG_ALERT, log, err, "pthread_mutex_lock() failed");
|
149
|
+
|
150
|
+
return NGX_ERROR;
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
ngx_int_t
|
155
|
+
ngx_thread_mutex_unlock(ngx_thread_mutex_t *mtx, ngx_log_t *log)
|
156
|
+
{
|
157
|
+
ngx_err_t err;
|
158
|
+
|
159
|
+
err = pthread_mutex_unlock(mtx);
|
160
|
+
|
161
|
+
#if 0
|
162
|
+
ngx_time_update();
|
163
|
+
#endif
|
164
|
+
|
165
|
+
if (err == 0) {
|
166
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0,
|
167
|
+
"pthread_mutex_unlock(%p) exit", mtx);
|
168
|
+
return NGX_OK;
|
169
|
+
}
|
170
|
+
|
171
|
+
ngx_log_error(NGX_LOG_ALERT, log, err, "pthread_mutex_unlock() failed");
|
172
|
+
|
173
|
+
return NGX_ERROR;
|
174
|
+
}
|
@@ -31,8 +31,10 @@ ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
|
|
31
31
|
struct crypt_data cd;
|
32
32
|
|
33
33
|
cd.initialized = 0;
|
34
|
+
#ifdef __GLIBC__
|
34
35
|
/* work around the glibc bug */
|
35
36
|
cd.current_salt[0] = ~salt[0];
|
37
|
+
#endif
|
36
38
|
|
37
39
|
value = crypt_r((char *) key, (char *) salt, &cd);
|
38
40
|
|
@@ -62,16 +64,6 @@ ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
|
|
62
64
|
size_t len;
|
63
65
|
ngx_err_t err;
|
64
66
|
|
65
|
-
#if (NGX_THREADS && NGX_NONREENTRANT_CRYPT)
|
66
|
-
|
67
|
-
/* crypt() is a time consuming function, so we only try to lock */
|
68
|
-
|
69
|
-
if (ngx_mutex_trylock(ngx_crypt_mutex) != NGX_OK) {
|
70
|
-
return NGX_AGAIN;
|
71
|
-
}
|
72
|
-
|
73
|
-
#endif
|
74
|
-
|
75
67
|
value = crypt((char *) key, (char *) salt);
|
76
68
|
|
77
69
|
if (value) {
|
@@ -79,25 +71,15 @@ ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
|
|
79
71
|
|
80
72
|
*encrypted = ngx_pnalloc(pool, len);
|
81
73
|
if (*encrypted == NULL) {
|
82
|
-
#if (NGX_THREADS && NGX_NONREENTRANT_CRYPT)
|
83
|
-
ngx_mutex_unlock(ngx_crypt_mutex);
|
84
|
-
#endif
|
85
74
|
return NGX_ERROR;
|
86
75
|
}
|
87
76
|
|
88
77
|
ngx_memcpy(*encrypted, value, len);
|
89
|
-
#if (NGX_THREADS && NGX_NONREENTRANT_CRYPT)
|
90
|
-
ngx_mutex_unlock(ngx_crypt_mutex);
|
91
|
-
#endif
|
92
78
|
return NGX_OK;
|
93
79
|
}
|
94
80
|
|
95
81
|
err = ngx_errno;
|
96
82
|
|
97
|
-
#if (NGX_THREADS && NGX_NONREENTRANT_CRYPT)
|
98
|
-
ngx_mutex_unlock(ngx_crypt_mutex);
|
99
|
-
#endif
|
100
|
-
|
101
83
|
ngx_log_error(NGX_LOG_CRIT, pool->log, err, "crypt() failed");
|
102
84
|
|
103
85
|
return NGX_ERROR;
|
@@ -10,25 +10,15 @@
|
|
10
10
|
#include <ngx_event.h>
|
11
11
|
|
12
12
|
|
13
|
-
#if (IOV_MAX > 64)
|
14
|
-
#define NGX_IOVS 64
|
15
|
-
#else
|
16
|
-
#define NGX_IOVS IOV_MAX
|
17
|
-
#endif
|
18
|
-
|
19
|
-
|
20
13
|
ngx_chain_t *
|
21
14
|
ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
22
15
|
{
|
23
|
-
|
24
|
-
ssize_t n, size, sent;
|
16
|
+
ssize_t n, sent;
|
25
17
|
off_t send, prev_send;
|
26
|
-
ngx_uint_t eintr, complete;
|
27
|
-
ngx_err_t err;
|
28
|
-
ngx_array_t vec;
|
29
18
|
ngx_chain_t *cl;
|
30
19
|
ngx_event_t *wev;
|
31
|
-
|
20
|
+
ngx_iovec_t vec;
|
21
|
+
struct iovec iovs[NGX_IOVS_PREALLOCATE];
|
32
22
|
|
33
23
|
wev = c->write;
|
34
24
|
|
@@ -55,131 +45,172 @@ ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
|
55
45
|
|
56
46
|
send = 0;
|
57
47
|
|
58
|
-
vec.
|
59
|
-
vec.
|
60
|
-
vec.nalloc = NGX_IOVS;
|
61
|
-
vec.pool = c->pool;
|
48
|
+
vec.iovs = iovs;
|
49
|
+
vec.nalloc = NGX_IOVS_PREALLOCATE;
|
62
50
|
|
63
51
|
for ( ;; ) {
|
64
|
-
prev = NULL;
|
65
|
-
iov = NULL;
|
66
|
-
eintr = 0;
|
67
|
-
complete = 0;
|
68
52
|
prev_send = send;
|
69
53
|
|
70
|
-
vec.nelts = 0;
|
71
|
-
|
72
54
|
/* create the iovec and coalesce the neighbouring bufs */
|
73
55
|
|
74
|
-
|
56
|
+
cl = ngx_output_chain_to_iovec(&vec, in, limit - send, c->log);
|
75
57
|
|
76
|
-
|
77
|
-
|
78
|
-
|
58
|
+
if (cl == NGX_CHAIN_ERROR) {
|
59
|
+
return NGX_CHAIN_ERROR;
|
60
|
+
}
|
79
61
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
62
|
+
if (cl && cl->buf->in_file) {
|
63
|
+
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
64
|
+
"file buf in writev "
|
65
|
+
"t:%d r:%d f:%d %p %p-%p %p %O-%O",
|
66
|
+
cl->buf->temporary,
|
67
|
+
cl->buf->recycled,
|
68
|
+
cl->buf->in_file,
|
69
|
+
cl->buf->start,
|
70
|
+
cl->buf->pos,
|
71
|
+
cl->buf->last,
|
72
|
+
cl->buf->file,
|
73
|
+
cl->buf->file_pos,
|
74
|
+
cl->buf->file_last);
|
75
|
+
|
76
|
+
ngx_debug_point();
|
77
|
+
|
78
|
+
return NGX_CHAIN_ERROR;
|
79
|
+
}
|
85
80
|
|
86
|
-
|
81
|
+
send += vec.size;
|
87
82
|
|
88
|
-
|
89
|
-
size = (ssize_t) (limit - send);
|
90
|
-
}
|
83
|
+
n = ngx_writev(c, &vec);
|
91
84
|
|
92
|
-
|
93
|
-
|
85
|
+
if (n == NGX_ERROR) {
|
86
|
+
return NGX_CHAIN_ERROR;
|
87
|
+
}
|
94
88
|
|
95
|
-
|
96
|
-
if (vec.nelts >= IOV_MAX) {
|
97
|
-
break;
|
98
|
-
}
|
89
|
+
sent = (n == NGX_AGAIN) ? 0 : n;
|
99
90
|
|
100
|
-
|
101
|
-
if (iov == NULL) {
|
102
|
-
return NGX_CHAIN_ERROR;
|
103
|
-
}
|
91
|
+
c->sent += sent;
|
104
92
|
|
105
|
-
|
106
|
-
iov->iov_len = size;
|
107
|
-
}
|
93
|
+
in = ngx_chain_update_sent(in, sent);
|
108
94
|
|
109
|
-
|
110
|
-
|
95
|
+
if (send - prev_send != sent) {
|
96
|
+
wev->ready = 0;
|
97
|
+
return in;
|
111
98
|
}
|
112
99
|
|
113
|
-
|
100
|
+
if (send >= limit || in == NULL) {
|
101
|
+
return in;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
114
105
|
|
115
|
-
if (n == -1) {
|
116
|
-
err = ngx_errno;
|
117
106
|
|
118
|
-
|
119
|
-
|
120
|
-
|
107
|
+
ngx_chain_t *
|
108
|
+
ngx_output_chain_to_iovec(ngx_iovec_t *vec, ngx_chain_t *in, size_t limit,
|
109
|
+
ngx_log_t *log)
|
110
|
+
{
|
111
|
+
size_t total, size;
|
112
|
+
u_char *prev;
|
113
|
+
ngx_uint_t n;
|
114
|
+
struct iovec *iov;
|
121
115
|
|
122
|
-
|
123
|
-
|
124
|
-
|
116
|
+
iov = NULL;
|
117
|
+
prev = NULL;
|
118
|
+
total = 0;
|
119
|
+
n = 0;
|
125
120
|
|
126
|
-
|
127
|
-
wev->error = 1;
|
128
|
-
(void) ngx_connection_error(c, err, "writev() failed");
|
129
|
-
return NGX_CHAIN_ERROR;
|
130
|
-
}
|
121
|
+
for ( /* void */ ; in && total < limit; in = in->next) {
|
131
122
|
|
132
|
-
|
133
|
-
|
123
|
+
if (ngx_buf_special(in->buf)) {
|
124
|
+
continue;
|
134
125
|
}
|
135
126
|
|
136
|
-
|
137
|
-
|
138
|
-
|
127
|
+
if (in->buf->in_file) {
|
128
|
+
break;
|
129
|
+
}
|
139
130
|
|
140
|
-
if (
|
141
|
-
|
131
|
+
if (!ngx_buf_in_memory(in->buf)) {
|
132
|
+
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
133
|
+
"bad buf in output chain "
|
134
|
+
"t:%d r:%d f:%d %p %p-%p %p %O-%O",
|
135
|
+
in->buf->temporary,
|
136
|
+
in->buf->recycled,
|
137
|
+
in->buf->in_file,
|
138
|
+
in->buf->start,
|
139
|
+
in->buf->pos,
|
140
|
+
in->buf->last,
|
141
|
+
in->buf->file,
|
142
|
+
in->buf->file_pos,
|
143
|
+
in->buf->file_last);
|
144
|
+
|
145
|
+
ngx_debug_point();
|
146
|
+
|
147
|
+
return NGX_CHAIN_ERROR;
|
142
148
|
}
|
143
149
|
|
144
|
-
|
150
|
+
size = in->buf->last - in->buf->pos;
|
145
151
|
|
146
|
-
|
152
|
+
if (size > limit - total) {
|
153
|
+
size = limit - total;
|
154
|
+
}
|
147
155
|
|
148
|
-
|
149
|
-
|
150
|
-
}
|
156
|
+
if (prev == in->buf->pos) {
|
157
|
+
iov->iov_len += size;
|
151
158
|
|
152
|
-
|
159
|
+
} else {
|
160
|
+
if (n == vec->nalloc) {
|
153
161
|
break;
|
154
162
|
}
|
155
163
|
|
156
|
-
|
164
|
+
iov = &vec->iovs[n++];
|
157
165
|
|
158
|
-
|
159
|
-
|
160
|
-
|
166
|
+
iov->iov_base = (void *) in->buf->pos;
|
167
|
+
iov->iov_len = size;
|
168
|
+
}
|
161
169
|
|
162
|
-
|
163
|
-
|
170
|
+
prev = in->buf->pos + size;
|
171
|
+
total += size;
|
172
|
+
}
|
164
173
|
|
165
|
-
|
174
|
+
vec->count = n;
|
175
|
+
vec->size = total;
|
166
176
|
|
167
|
-
|
168
|
-
|
177
|
+
return in;
|
178
|
+
}
|
169
179
|
|
170
|
-
if (eintr) {
|
171
|
-
continue;
|
172
|
-
}
|
173
180
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
181
|
+
ssize_t
|
182
|
+
ngx_writev(ngx_connection_t *c, ngx_iovec_t *vec)
|
183
|
+
{
|
184
|
+
ssize_t n;
|
185
|
+
ngx_err_t err;
|
178
186
|
|
179
|
-
|
180
|
-
|
181
|
-
|
187
|
+
eintr:
|
188
|
+
|
189
|
+
n = writev(c->fd, vec->iovs, vec->count);
|
182
190
|
|
183
|
-
|
191
|
+
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
192
|
+
"writev: %z of %uz", n, vec->size);
|
193
|
+
|
194
|
+
if (n == -1) {
|
195
|
+
err = ngx_errno;
|
196
|
+
|
197
|
+
switch (err) {
|
198
|
+
case NGX_EAGAIN:
|
199
|
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
|
200
|
+
"writev() not ready");
|
201
|
+
return NGX_AGAIN;
|
202
|
+
|
203
|
+
case NGX_EINTR:
|
204
|
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
|
205
|
+
"writev() was interrupted");
|
206
|
+
goto eintr;
|
207
|
+
|
208
|
+
default:
|
209
|
+
c->write->error = 1;
|
210
|
+
ngx_connection_error(c, err, "writev() failed");
|
211
|
+
return NGX_ERROR;
|
212
|
+
}
|
184
213
|
}
|
214
|
+
|
215
|
+
return n;
|
185
216
|
}
|