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.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nginxtra +1 -1
  3. data/bin/nginxtra_rails +1 -1
  4. data/lib/nginxtra/version.rb +1 -1
  5. data/vendor/nginx/CHANGES +358 -14
  6. data/vendor/nginx/CHANGES.ru +372 -18
  7. data/vendor/nginx/LICENSE +2 -2
  8. data/vendor/nginx/auto/cc/clang +5 -0
  9. data/vendor/nginx/auto/cc/gcc +5 -0
  10. data/vendor/nginx/auto/lib/google-perftools/conf +1 -1
  11. data/vendor/nginx/auto/lib/openssl/make +0 -5
  12. data/vendor/nginx/auto/lib/perl/conf +9 -1
  13. data/vendor/nginx/auto/make +1 -1
  14. data/vendor/nginx/auto/modules +11 -0
  15. data/vendor/nginx/auto/options +10 -2
  16. data/vendor/nginx/auto/os/darwin +0 -1
  17. data/vendor/nginx/auto/os/freebsd +6 -23
  18. data/vendor/nginx/auto/sources +16 -14
  19. data/vendor/nginx/auto/summary +3 -24
  20. data/vendor/nginx/auto/threads +20 -0
  21. data/vendor/nginx/auto/types/sizeof +2 -12
  22. data/vendor/nginx/auto/unix +50 -6
  23. data/vendor/nginx/configure +5 -0
  24. data/vendor/nginx/contrib/vim/syntax/nginx.vim +183 -50
  25. data/vendor/nginx/src/core/nginx.c +21 -9
  26. data/vendor/nginx/src/core/nginx.h +8 -2
  27. data/vendor/nginx/src/core/ngx_buf.c +88 -0
  28. data/vendor/nginx/src/core/ngx_buf.h +15 -1
  29. data/vendor/nginx/src/core/ngx_conf_file.c +4 -1
  30. data/vendor/nginx/src/core/ngx_connection.c +25 -66
  31. data/vendor/nginx/src/core/ngx_connection.h +1 -3
  32. data/vendor/nginx/src/core/ngx_core.h +11 -3
  33. data/vendor/nginx/src/core/ngx_crypt.c +1 -1
  34. data/vendor/nginx/src/core/ngx_cycle.c +7 -1
  35. data/vendor/nginx/src/core/ngx_cycle.h +6 -2
  36. data/vendor/nginx/src/core/ngx_file.c +13 -5
  37. data/vendor/nginx/src/core/ngx_file.h +6 -0
  38. data/vendor/nginx/src/core/ngx_log.c +215 -21
  39. data/vendor/nginx/src/core/ngx_log.h +9 -1
  40. data/vendor/nginx/src/core/ngx_output_chain.c +104 -15
  41. data/vendor/nginx/src/core/ngx_palloc.c +3 -7
  42. data/vendor/nginx/src/core/ngx_rbtree.c +2 -4
  43. data/vendor/nginx/src/core/ngx_rbtree.h +2 -4
  44. data/vendor/nginx/src/core/ngx_regex.c +14 -6
  45. data/vendor/nginx/src/core/ngx_resolver.c +16 -23
  46. data/vendor/nginx/src/core/ngx_resolver.h +8 -7
  47. data/vendor/nginx/src/core/ngx_shmtx.c +1 -1
  48. data/vendor/nginx/src/core/ngx_slab.c +89 -2
  49. data/vendor/nginx/src/core/ngx_slab.h +3 -0
  50. data/vendor/nginx/src/core/ngx_string.c +58 -2
  51. data/vendor/nginx/src/core/ngx_string.h +1 -0
  52. data/vendor/nginx/src/core/ngx_syslog.c +374 -0
  53. data/vendor/nginx/src/core/ngx_syslog.h +30 -0
  54. data/vendor/nginx/src/core/ngx_thread_pool.c +630 -0
  55. data/vendor/nginx/src/core/ngx_thread_pool.h +36 -0
  56. data/vendor/nginx/src/core/ngx_times.c +19 -2
  57. data/vendor/nginx/src/core/ngx_times.h +1 -0
  58. data/vendor/nginx/src/event/modules/ngx_aio_module.c +1 -1
  59. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +9 -24
  60. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +152 -28
  61. data/vendor/nginx/src/event/modules/ngx_eventport_module.c +43 -25
  62. data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +86 -156
  63. data/vendor/nginx/src/event/modules/ngx_poll_module.c +21 -37
  64. data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +15 -27
  65. data/vendor/nginx/src/event/modules/ngx_select_module.c +10 -12
  66. data/vendor/nginx/src/event/modules/ngx_win32_select_module.c +7 -9
  67. data/vendor/nginx/src/event/ngx_event.c +5 -33
  68. data/vendor/nginx/src/event/ngx_event.h +15 -50
  69. data/vendor/nginx/src/event/ngx_event_accept.c +11 -10
  70. data/vendor/nginx/src/event/ngx_event_connect.c +0 -11
  71. data/vendor/nginx/src/event/ngx_event_connect.h +1 -4
  72. data/vendor/nginx/src/event/ngx_event_openssl.c +622 -38
  73. data/vendor/nginx/src/event/ngx_event_openssl.h +20 -2
  74. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +5 -1
  75. data/vendor/nginx/src/event/ngx_event_pipe.c +45 -19
  76. data/vendor/nginx/src/event/ngx_event_pipe.h +3 -0
  77. data/vendor/nginx/src/event/ngx_event_posted.c +7 -145
  78. data/vendor/nginx/src/event/ngx_event_posted.h +12 -39
  79. data/vendor/nginx/src/event/ngx_event_timer.c +50 -70
  80. data/vendor/nginx/src/event/ngx_event_timer.h +2 -14
  81. data/vendor/nginx/src/http/modules/ngx_http_addition_filter_module.c +1 -1
  82. data/vendor/nginx/src/http/modules/ngx_http_autoindex_module.c +416 -71
  83. data/vendor/nginx/src/http/modules/ngx_http_charset_filter_module.c +19 -15
  84. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +16 -4
  85. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +601 -134
  86. data/vendor/nginx/src/http/modules/ngx_http_geo_module.c +1 -1
  87. data/vendor/nginx/src/http/modules/ngx_http_geoip_module.c +9 -3
  88. data/vendor/nginx/src/http/modules/ngx_http_gunzip_filter_module.c +9 -3
  89. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +9 -3
  90. data/vendor/nginx/src/http/modules/ngx_http_gzip_static_module.c +0 -2
  91. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +197 -91
  92. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +1 -0
  93. data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +65 -162
  94. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +53 -67
  95. data/vendor/nginx/src/http/modules/ngx_http_log_module.c +128 -23
  96. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +25 -6
  97. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +1 -1
  98. data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +39 -13
  99. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +697 -141
  100. data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +5 -1
  101. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +282 -125
  102. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +4 -1
  103. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +44 -1
  104. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.h +2 -0
  105. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +10 -8
  106. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +18 -3
  107. data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +641 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +1 -1
  109. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +3 -21
  110. data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +0 -5
  111. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +449 -125
  112. data/vendor/nginx/src/http/modules/ngx_http_xslt_filter_module.c +4 -2
  113. data/vendor/nginx/src/http/modules/perl/ngx_http_perl_module.c +2 -1
  114. data/vendor/nginx/src/http/ngx_http.c +10 -5
  115. data/vendor/nginx/src/http/ngx_http.h +4 -4
  116. data/vendor/nginx/src/http/ngx_http_cache.h +26 -1
  117. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +109 -68
  118. data/vendor/nginx/src/http/ngx_http_core_module.c +191 -46
  119. data/vendor/nginx/src/http/ngx_http_core_module.h +16 -4
  120. data/vendor/nginx/src/http/ngx_http_file_cache.c +584 -67
  121. data/vendor/nginx/src/http/ngx_http_parse.c +55 -4
  122. data/vendor/nginx/src/http/ngx_http_request.c +14 -6
  123. data/vendor/nginx/src/http/ngx_http_request.h +12 -4
  124. data/vendor/nginx/src/http/ngx_http_request_body.c +114 -28
  125. data/vendor/nginx/src/http/ngx_http_spdy.c +383 -229
  126. data/vendor/nginx/src/http/ngx_http_spdy.h +8 -5
  127. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +12 -4
  128. data/vendor/nginx/src/http/ngx_http_special_response.c +2 -2
  129. data/vendor/nginx/src/http/ngx_http_upstream.c +808 -132
  130. data/vendor/nginx/src/http/ngx_http_upstream.h +33 -3
  131. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +72 -65
  132. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +1 -2
  133. data/vendor/nginx/src/http/ngx_http_variables.c +47 -3
  134. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +15 -6
  135. data/vendor/nginx/src/mail/ngx_mail.c +2 -3
  136. data/vendor/nginx/src/mail/ngx_mail.h +2 -0
  137. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +140 -11
  138. data/vendor/nginx/src/mail/ngx_mail_core_module.c +3 -3
  139. data/vendor/nginx/src/mail/ngx_mail_handler.c +79 -2
  140. data/vendor/nginx/src/mail/ngx_mail_imap_module.c +3 -1
  141. data/vendor/nginx/src/mail/ngx_mail_pop3_module.c +3 -1
  142. data/vendor/nginx/src/mail/ngx_mail_smtp_module.c +3 -1
  143. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +125 -1
  144. data/vendor/nginx/src/mail/ngx_mail_ssl_module.h +8 -0
  145. data/vendor/nginx/src/misc/ngx_cpp_test_module.cpp +1 -1
  146. data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +1 -1
  147. data/vendor/nginx/src/os/unix/ngx_channel.c +0 -7
  148. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +0 -3
  149. data/vendor/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +44 -208
  150. data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +25 -17
  151. data/vendor/nginx/src/os/unix/ngx_files.c +109 -0
  152. data/vendor/nginx/src/os/unix/ngx_files.h +6 -0
  153. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +0 -6
  154. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +78 -206
  155. data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +25 -14
  156. data/vendor/nginx/src/os/unix/ngx_linux_config.h +4 -1
  157. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +235 -194
  158. data/vendor/nginx/src/os/unix/ngx_os.h +25 -3
  159. data/vendor/nginx/src/os/unix/ngx_posix_init.c +4 -2
  160. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +13 -195
  161. data/vendor/nginx/src/os/unix/ngx_process_cycle.h +0 -1
  162. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +27 -108
  163. data/vendor/nginx/src/os/unix/ngx_setproctitle.h +2 -2
  164. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +12 -67
  165. data/vendor/nginx/src/os/unix/ngx_thread.h +26 -83
  166. data/vendor/nginx/src/os/unix/ngx_thread_cond.c +87 -0
  167. data/vendor/nginx/src/os/unix/ngx_thread_id.c +70 -0
  168. data/vendor/nginx/src/os/unix/ngx_thread_mutex.c +174 -0
  169. data/vendor/nginx/src/os/unix/ngx_user.c +2 -20
  170. data/vendor/nginx/src/os/unix/ngx_writev_chain.c +129 -98
  171. metadata +16 -17
  172. data/vendor/nginx/auto/lib/zlib/patch.zlib.h +0 -10
  173. data/vendor/nginx/src/event/ngx_event_busy_lock.c +0 -286
  174. data/vendor/nginx/src/event/ngx_event_busy_lock.h +0 -65
  175. data/vendor/nginx/src/event/ngx_event_mutex.c +0 -70
  176. data/vendor/nginx/src/http/ngx_http_busy_lock.c +0 -307
  177. data/vendor/nginx/src/http/ngx_http_busy_lock.h +0 -54
  178. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +0 -756
  179. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +0 -122
  180. data/vendor/nginx/src/os/unix/ngx_pthread_thread.c +0 -278
  181. data/vendor/nginx/src/os/unix/rfork_thread.S +0 -73
@@ -139,7 +139,7 @@ static ngx_command_t ngx_core_commands[] = {
139
139
  0,
140
140
  NULL },
141
141
 
142
- #if (NGX_THREADS)
142
+ #if (NGX_OLD_THREADS)
143
143
 
144
144
  { ngx_string("worker_threads"),
145
145
  NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
@@ -217,7 +217,7 @@ main(int argc, char *const *argv)
217
217
  }
218
218
 
219
219
  if (ngx_show_version) {
220
- ngx_write_stderr("nginx version: " NGINX_VER NGX_LINEFEED);
220
+ ngx_write_stderr("nginx version: " NGINX_VER_BUILD NGX_LINEFEED);
221
221
 
222
222
  if (ngx_show_help) {
223
223
  ngx_write_stderr(
@@ -248,18 +248,30 @@ main(int argc, char *const *argv)
248
248
  }
249
249
 
250
250
  if (ngx_show_configure) {
251
- ngx_write_stderr(
251
+
252
252
  #ifdef NGX_COMPILER
253
- "built by " NGX_COMPILER NGX_LINEFEED
253
+ ngx_write_stderr("built by " NGX_COMPILER NGX_LINEFEED);
254
254
  #endif
255
+
255
256
  #if (NGX_SSL)
257
+ if (SSLeay() == SSLEAY_VERSION_NUMBER) {
258
+ ngx_write_stderr("built with " OPENSSL_VERSION_TEXT
259
+ NGX_LINEFEED);
260
+ } else {
261
+ ngx_write_stderr("built with " OPENSSL_VERSION_TEXT
262
+ " (running with ");
263
+ ngx_write_stderr((char *) (uintptr_t)
264
+ SSLeay_version(SSLEAY_VERSION));
265
+ ngx_write_stderr(")" NGX_LINEFEED);
266
+ }
256
267
  #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
257
- "TLS SNI support enabled" NGX_LINEFEED
268
+ ngx_write_stderr("TLS SNI support enabled" NGX_LINEFEED);
258
269
  #else
259
- "TLS SNI support disabled" NGX_LINEFEED
270
+ ngx_write_stderr("TLS SNI support disabled" NGX_LINEFEED);
260
271
  #endif
261
272
  #endif
262
- "configure arguments:" NGX_CONFIGURE NGX_LINEFEED);
273
+
274
+ ngx_write_stderr("configure arguments:" NGX_CONFIGURE NGX_LINEFEED);
263
275
  }
264
276
 
265
277
  if (!ngx_test_config) {
@@ -959,7 +971,7 @@ ngx_core_module_create_conf(ngx_cycle_t *cycle)
959
971
  ccf->user = (ngx_uid_t) NGX_CONF_UNSET_UINT;
960
972
  ccf->group = (ngx_gid_t) NGX_CONF_UNSET_UINT;
961
973
 
962
- #if (NGX_THREADS)
974
+ #if (NGX_OLD_THREADS)
963
975
  ccf->worker_threads = NGX_CONF_UNSET;
964
976
  ccf->thread_stack_size = NGX_CONF_UNSET_SIZE;
965
977
  #endif
@@ -1000,7 +1012,7 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
1000
1012
 
1001
1013
  #endif
1002
1014
 
1003
- #if (NGX_THREADS)
1015
+ #if (NGX_OLD_THREADS)
1004
1016
 
1005
1017
  ngx_conf_init_value(ccf->worker_threads, 0);
1006
1018
  ngx_threads_n = ccf->worker_threads;
@@ -9,10 +9,16 @@
9
9
  #define _NGINX_H_INCLUDED_
10
10
 
11
11
 
12
- #define nginx_version 1006003
13
- #define NGINX_VERSION "1.6.3"
12
+ #define nginx_version 1008000
13
+ #define NGINX_VERSION "1.8.0"
14
14
  #define NGINX_VER "nginx/" NGINX_VERSION
15
15
 
16
+ #ifdef NGX_BUILD
17
+ #define NGINX_VER_BUILD NGINX_VER " (" NGX_BUILD ")"
18
+ #else
19
+ #define NGINX_VER_BUILD NGINX_VER
20
+ #endif
21
+
16
22
  #define NGINX_VAR "NGINX"
17
23
  #define NGX_OLDPID_EXT ".oldbin"
18
24
 
@@ -218,3 +218,91 @@ ngx_chain_update_chains(ngx_pool_t *p, ngx_chain_t **free, ngx_chain_t **busy,
218
218
  *free = cl;
219
219
  }
220
220
  }
221
+
222
+
223
+ off_t
224
+ ngx_chain_coalesce_file(ngx_chain_t **in, off_t limit)
225
+ {
226
+ off_t total, size, aligned, fprev;
227
+ ngx_fd_t fd;
228
+ ngx_chain_t *cl;
229
+
230
+ total = 0;
231
+
232
+ cl = *in;
233
+ fd = cl->buf->file->fd;
234
+
235
+ do {
236
+ size = cl->buf->file_last - cl->buf->file_pos;
237
+
238
+ if (size > limit - total) {
239
+ size = limit - total;
240
+
241
+ aligned = (cl->buf->file_pos + size + ngx_pagesize - 1)
242
+ & ~((off_t) ngx_pagesize - 1);
243
+
244
+ if (aligned <= cl->buf->file_last) {
245
+ size = aligned - cl->buf->file_pos;
246
+ }
247
+ }
248
+
249
+ total += size;
250
+ fprev = cl->buf->file_pos + size;
251
+ cl = cl->next;
252
+
253
+ } while (cl
254
+ && cl->buf->in_file
255
+ && total < limit
256
+ && fd == cl->buf->file->fd
257
+ && fprev == cl->buf->file_pos);
258
+
259
+ *in = cl;
260
+
261
+ return total;
262
+ }
263
+
264
+
265
+ ngx_chain_t *
266
+ ngx_chain_update_sent(ngx_chain_t *in, off_t sent)
267
+ {
268
+ off_t size;
269
+
270
+ for ( /* void */ ; in; in = in->next) {
271
+
272
+ if (ngx_buf_special(in->buf)) {
273
+ continue;
274
+ }
275
+
276
+ if (sent == 0) {
277
+ break;
278
+ }
279
+
280
+ size = ngx_buf_size(in->buf);
281
+
282
+ if (sent >= size) {
283
+ sent -= size;
284
+
285
+ if (ngx_buf_in_memory(in->buf)) {
286
+ in->buf->pos = in->buf->last;
287
+ }
288
+
289
+ if (in->buf->in_file) {
290
+ in->buf->file_pos = in->buf->file_last;
291
+ }
292
+
293
+ continue;
294
+ }
295
+
296
+ if (ngx_buf_in_memory(in->buf)) {
297
+ in->buf->pos += (size_t) sent;
298
+ }
299
+
300
+ if (in->buf->in_file) {
301
+ in->buf->file_pos += sent;
302
+ }
303
+
304
+ break;
305
+ }
306
+
307
+ return in;
308
+ }
@@ -90,10 +90,21 @@ struct ngx_output_chain_ctx_s {
90
90
  #endif
91
91
  unsigned need_in_memory:1;
92
92
  unsigned need_in_temp:1;
93
- #if (NGX_HAVE_FILE_AIO)
93
+ #if (NGX_HAVE_FILE_AIO || NGX_THREADS)
94
94
  unsigned aio:1;
95
+ #endif
95
96
 
97
+ #if (NGX_HAVE_FILE_AIO)
96
98
  ngx_output_chain_aio_pt aio_handler;
99
+ #if (NGX_HAVE_AIO_SENDFILE)
100
+ ssize_t (*aio_preload)(ngx_buf_t *file);
101
+ #endif
102
+ #endif
103
+
104
+ #if (NGX_THREADS)
105
+ ngx_int_t (*thread_handler)(ngx_thread_task_t *task,
106
+ ngx_file_t *file);
107
+ ngx_thread_task_t *thread_task;
97
108
  #endif
98
109
 
99
110
  off_t alignment;
@@ -158,5 +169,8 @@ ngx_chain_t *ngx_chain_get_free_buf(ngx_pool_t *p, ngx_chain_t **free);
158
169
  void ngx_chain_update_chains(ngx_pool_t *p, ngx_chain_t **free,
159
170
  ngx_chain_t **busy, ngx_chain_t **out, ngx_buf_tag_t tag);
160
171
 
172
+ off_t ngx_chain_coalesce_file(ngx_chain_t **in, off_t limit);
173
+
174
+ ngx_chain_t *ngx_chain_update_sent(ngx_chain_t *in, off_t sent);
161
175
 
162
176
  #endif /* _NGX_BUF_H_INCLUDED_ */
@@ -266,7 +266,7 @@ done:
266
266
  ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
267
267
  ngx_close_file_n " %s failed",
268
268
  filename->data);
269
- return NGX_CONF_ERROR;
269
+ rc = NGX_ERROR;
270
270
  }
271
271
 
272
272
  cf->conf_file = prev;
@@ -781,6 +781,9 @@ ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
781
781
 
782
782
  file.len = name.len++;
783
783
  file.data = ngx_pstrdup(cf->pool, &name);
784
+ if (file.data == NULL) {
785
+ return NGX_CONF_ERROR;
786
+ }
784
787
 
785
788
  ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data);
786
789
 
@@ -411,13 +411,11 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
411
411
  if (bind(s, ls[i].sockaddr, ls[i].socklen) == -1) {
412
412
  err = ngx_socket_errno;
413
413
 
414
- if (err == NGX_EADDRINUSE && ngx_test_config) {
415
- continue;
414
+ if (err != NGX_EADDRINUSE || !ngx_test_config) {
415
+ ngx_log_error(NGX_LOG_EMERG, log, err,
416
+ "bind() to %V failed", &ls[i].addr_text);
416
417
  }
417
418
 
418
- ngx_log_error(NGX_LOG_EMERG, log, err,
419
- "bind() to %V failed", &ls[i].addr_text);
420
-
421
419
  if (ngx_close_socket(s) == -1) {
422
420
  ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
423
421
  ngx_close_socket_n " %V failed",
@@ -428,7 +426,9 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
428
426
  return NGX_ERROR;
429
427
  }
430
428
 
431
- failed = 1;
429
+ if (!ngx_test_config) {
430
+ failed = 1;
431
+ }
432
432
 
433
433
  continue;
434
434
  }
@@ -835,8 +835,6 @@ ngx_get_connection(ngx_socket_t s, ngx_log_t *log)
835
835
  return NULL;
836
836
  }
837
837
 
838
- /* ngx_mutex_lock */
839
-
840
838
  c = ngx_cycle->free_connections;
841
839
 
842
840
  if (c == NULL) {
@@ -849,16 +847,12 @@ ngx_get_connection(ngx_socket_t s, ngx_log_t *log)
849
847
  "%ui worker_connections are not enough",
850
848
  ngx_cycle->connection_n);
851
849
 
852
- /* ngx_mutex_unlock */
853
-
854
850
  return NULL;
855
851
  }
856
852
 
857
853
  ngx_cycle->free_connections = c->data;
858
854
  ngx_cycle->free_connection_n--;
859
855
 
860
- /* ngx_mutex_unlock */
861
-
862
856
  if (ngx_cycle->files) {
863
857
  ngx_cycle->files[s] = c;
864
858
  }
@@ -896,14 +890,10 @@ ngx_get_connection(ngx_socket_t s, ngx_log_t *log)
896
890
  void
897
891
  ngx_free_connection(ngx_connection_t *c)
898
892
  {
899
- /* ngx_mutex_lock */
900
-
901
893
  c->data = ngx_cycle->free_connections;
902
894
  ngx_cycle->free_connections = c;
903
895
  ngx_cycle->free_connection_n++;
904
896
 
905
- /* ngx_mutex_unlock */
906
-
907
897
  if (ngx_cycle->files) {
908
898
  ngx_cycle->files[c->fd] = NULL;
909
899
  }
@@ -943,48 +933,17 @@ ngx_close_connection(ngx_connection_t *c)
943
933
  }
944
934
  }
945
935
 
946
- #if (NGX_THREADS)
947
-
948
- /*
949
- * we have to clean the connection information before the closing
950
- * because another thread may reopen the same file descriptor
951
- * before we clean the connection
952
- */
953
-
954
- ngx_mutex_lock(ngx_posted_events_mutex);
955
-
956
- if (c->read->prev) {
936
+ if (c->read->posted) {
957
937
  ngx_delete_posted_event(c->read);
958
938
  }
959
939
 
960
- if (c->write->prev) {
940
+ if (c->write->posted) {
961
941
  ngx_delete_posted_event(c->write);
962
942
  }
963
943
 
964
944
  c->read->closed = 1;
965
945
  c->write->closed = 1;
966
946
 
967
- ngx_unlock(&c->lock);
968
- c->read->locked = 0;
969
- c->write->locked = 0;
970
-
971
- ngx_mutex_unlock(ngx_posted_events_mutex);
972
-
973
- #else
974
-
975
- if (c->read->prev) {
976
- ngx_delete_posted_event(c->read);
977
- }
978
-
979
- if (c->write->prev) {
980
- ngx_delete_posted_event(c->write);
981
- }
982
-
983
- c->read->closed = 1;
984
- c->write->closed = 1;
985
-
986
- #endif
987
-
988
947
  ngx_reusable_connection(c, 0);
989
948
 
990
949
  log_error = c->log_error;
@@ -1092,33 +1051,33 @@ ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
1092
1051
  struct sockaddr_in6 *sin6;
1093
1052
  #endif
1094
1053
 
1095
- if (c->local_socklen == 0) {
1096
- return NGX_ERROR;
1097
- }
1054
+ addr = 0;
1098
1055
 
1099
- switch (c->local_sockaddr->sa_family) {
1056
+ if (c->local_socklen) {
1057
+ switch (c->local_sockaddr->sa_family) {
1100
1058
 
1101
1059
  #if (NGX_HAVE_INET6)
1102
- case AF_INET6:
1103
- sin6 = (struct sockaddr_in6 *) c->local_sockaddr;
1060
+ case AF_INET6:
1061
+ sin6 = (struct sockaddr_in6 *) c->local_sockaddr;
1104
1062
 
1105
- for (addr = 0, i = 0; addr == 0 && i < 16; i++) {
1106
- addr |= sin6->sin6_addr.s6_addr[i];
1107
- }
1063
+ for (i = 0; addr == 0 && i < 16; i++) {
1064
+ addr |= sin6->sin6_addr.s6_addr[i];
1065
+ }
1108
1066
 
1109
- break;
1067
+ break;
1110
1068
  #endif
1111
1069
 
1112
1070
  #if (NGX_HAVE_UNIX_DOMAIN)
1113
- case AF_UNIX:
1114
- addr = 1;
1115
- break;
1071
+ case AF_UNIX:
1072
+ addr = 1;
1073
+ break;
1116
1074
  #endif
1117
1075
 
1118
- default: /* AF_INET */
1119
- sin = (struct sockaddr_in *) c->local_sockaddr;
1120
- addr = sin->sin_addr.s_addr;
1121
- break;
1076
+ default: /* AF_INET */
1077
+ sin = (struct sockaddr_in *) c->local_sockaddr;
1078
+ addr = sin->sin_addr.s_addr;
1079
+ break;
1080
+ }
1122
1081
  }
1123
1082
 
1124
1083
  if (addr == 0) {
@@ -181,13 +181,11 @@ struct ngx_connection_s {
181
181
  #endif
182
182
 
183
183
  #if (NGX_HAVE_AIO_SENDFILE)
184
- unsigned aio_sendfile:1;
185
184
  unsigned busy_count:2;
186
- ngx_buf_t *busy_sendfile;
187
185
  #endif
188
186
 
189
187
  #if (NGX_THREADS)
190
- ngx_atomic_t lock;
188
+ ngx_thread_task_t *sendfile_task;
191
189
  #endif
192
190
  };
193
191
 
@@ -9,6 +9,9 @@
9
9
  #define _NGX_CORE_H_INCLUDED_
10
10
 
11
11
 
12
+ #include <ngx_config.h>
13
+
14
+
12
15
  typedef struct ngx_module_s ngx_module_t;
13
16
  typedef struct ngx_conf_s ngx_conf_t;
14
17
  typedef struct ngx_cycle_s ngx_cycle_t;
@@ -22,6 +25,10 @@ typedef struct ngx_event_s ngx_event_t;
22
25
  typedef struct ngx_event_aio_s ngx_event_aio_t;
23
26
  typedef struct ngx_connection_s ngx_connection_t;
24
27
 
28
+ #if (NGX_THREADS)
29
+ typedef struct ngx_thread_task_s ngx_thread_task_t;
30
+ #endif
31
+
25
32
  typedef void (*ngx_event_handler_pt)(ngx_event_t *ev);
26
33
  typedef void (*ngx_connection_handler_pt)(ngx_connection_t *c);
27
34
 
@@ -77,12 +84,13 @@ typedef void (*ngx_connection_handler_pt)(ngx_connection_t *c);
77
84
  #include <ngx_open_file_cache.h>
78
85
  #include <ngx_os.h>
79
86
  #include <ngx_connection.h>
87
+ #include <ngx_syslog.h>
80
88
  #include <ngx_proxy_protocol.h>
81
89
 
82
90
 
83
- #define LF (u_char) 10
84
- #define CR (u_char) 13
85
- #define CRLF "\x0d\x0a"
91
+ #define LF (u_char) '\n'
92
+ #define CR (u_char) '\r'
93
+ #define CRLF "\r\n"
86
94
 
87
95
 
88
96
  #define ngx_abs(value) (((value) >= 0) ? (value) : - (value))