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.
Files changed (238) 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 +363 -25
  6. data/vendor/nginx/CHANGES.ru +365 -21
  7. data/vendor/nginx/LICENSE +2 -2
  8. data/vendor/nginx/auto/cc/conf +32 -0
  9. data/vendor/nginx/auto/cc/gcc +1 -1
  10. data/vendor/nginx/auto/cc/icc +2 -2
  11. data/vendor/nginx/auto/cc/msvc +29 -8
  12. data/vendor/nginx/auto/cc/name +2 -25
  13. data/vendor/nginx/auto/cc/sunc +3 -0
  14. data/vendor/nginx/auto/endianness +7 -2
  15. data/vendor/nginx/auto/install +60 -26
  16. data/vendor/nginx/auto/lib/conf +4 -4
  17. data/vendor/nginx/auto/lib/geoip/conf +6 -1
  18. data/vendor/nginx/auto/lib/libgd/conf +6 -1
  19. data/vendor/nginx/auto/lib/libxslt/conf +11 -2
  20. data/vendor/nginx/auto/lib/make +1 -1
  21. data/vendor/nginx/auto/lib/md5/conf +2 -2
  22. data/vendor/nginx/auto/lib/md5/make +2 -2
  23. data/vendor/nginx/auto/lib/openssl/conf +52 -3
  24. data/vendor/nginx/auto/lib/openssl/make +1 -1
  25. data/vendor/nginx/auto/lib/pcre/conf +2 -2
  26. data/vendor/nginx/auto/lib/pcre/make +2 -2
  27. data/vendor/nginx/auto/lib/perl/conf +6 -3
  28. data/vendor/nginx/auto/lib/perl/make +4 -1
  29. data/vendor/nginx/auto/lib/sha1/conf +2 -2
  30. data/vendor/nginx/auto/lib/sha1/make +2 -2
  31. data/vendor/nginx/auto/lib/zlib/conf +2 -2
  32. data/vendor/nginx/auto/lib/zlib/make +2 -2
  33. data/vendor/nginx/auto/make +281 -16
  34. data/vendor/nginx/auto/module +122 -0
  35. data/vendor/nginx/auto/modules +909 -178
  36. data/vendor/nginx/auto/options +81 -19
  37. data/vendor/nginx/auto/os/conf +9 -0
  38. data/vendor/nginx/auto/os/darwin +3 -0
  39. data/vendor/nginx/auto/os/freebsd +0 -20
  40. data/vendor/nginx/auto/os/linux +0 -12
  41. data/vendor/nginx/auto/os/win32 +5 -1
  42. data/vendor/nginx/auto/sources +11 -311
  43. data/vendor/nginx/auto/summary +1 -0
  44. data/vendor/nginx/auto/types/sizeof +5 -3
  45. data/vendor/nginx/auto/types/typedef +9 -4
  46. data/vendor/nginx/auto/types/uintptr_t +7 -2
  47. data/vendor/nginx/auto/unix +72 -12
  48. data/vendor/nginx/conf/fastcgi.conf +1 -0
  49. data/vendor/nginx/conf/fastcgi_params +1 -0
  50. data/vendor/nginx/conf/scgi_params +1 -0
  51. data/vendor/nginx/conf/uwsgi_params +1 -0
  52. data/vendor/nginx/configure +1 -1
  53. data/vendor/nginx/contrib/vim/syntax/nginx.vim +2 -2
  54. data/vendor/nginx/man/nginx.8 +6 -2
  55. data/vendor/nginx/src/core/nginx.c +281 -114
  56. data/vendor/nginx/src/core/nginx.h +2 -2
  57. data/vendor/nginx/src/core/ngx_conf_file.c +54 -13
  58. data/vendor/nginx/src/core/ngx_conf_file.h +8 -52
  59. data/vendor/nginx/src/core/ngx_config.h +0 -5
  60. data/vendor/nginx/src/core/ngx_connection.c +270 -37
  61. data/vendor/nginx/src/core/ngx_connection.h +35 -12
  62. data/vendor/nginx/src/core/ngx_core.h +4 -0
  63. data/vendor/nginx/src/core/ngx_crypt.c +2 -2
  64. data/vendor/nginx/src/core/ngx_cycle.c +72 -25
  65. data/vendor/nginx/src/core/ngx_cycle.h +28 -39
  66. data/vendor/nginx/src/core/ngx_file.c +14 -5
  67. data/vendor/nginx/src/core/ngx_file.h +2 -0
  68. data/vendor/nginx/src/core/ngx_hash.c +13 -1
  69. data/vendor/nginx/src/core/ngx_inet.c +20 -18
  70. data/vendor/nginx/src/core/ngx_log.c +12 -12
  71. data/vendor/nginx/src/core/ngx_log.h +13 -6
  72. data/vendor/nginx/src/core/ngx_module.c +360 -0
  73. data/vendor/nginx/src/core/ngx_module.h +307 -0
  74. data/vendor/nginx/src/core/ngx_open_file_cache.c +2 -2
  75. data/vendor/nginx/src/core/ngx_output_chain.c +8 -4
  76. data/vendor/nginx/src/core/ngx_palloc.c +42 -44
  77. data/vendor/nginx/src/{http/ngx_http_parse_time.c → core/ngx_parse_time.c} +2 -3
  78. data/vendor/nginx/src/core/ngx_parse_time.h +22 -0
  79. data/vendor/nginx/src/core/ngx_proxy_protocol.c +50 -1
  80. data/vendor/nginx/src/core/ngx_proxy_protocol.h +3 -1
  81. data/vendor/nginx/src/core/ngx_regex.c +1 -38
  82. data/vendor/nginx/src/core/ngx_resolver.c +1814 -320
  83. data/vendor/nginx/src/core/ngx_resolver.h +67 -10
  84. data/vendor/nginx/src/core/ngx_rwlock.c +120 -0
  85. data/vendor/nginx/src/core/ngx_rwlock.h +21 -0
  86. data/vendor/nginx/src/core/ngx_slab.c +6 -5
  87. data/vendor/nginx/src/core/ngx_string.c +1 -1
  88. data/vendor/nginx/src/core/ngx_syslog.c +11 -3
  89. data/vendor/nginx/src/core/ngx_syslog.h +2 -1
  90. data/vendor/nginx/src/core/ngx_thread_pool.c +4 -0
  91. data/vendor/nginx/src/core/ngx_times.c +2 -2
  92. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +3 -1
  93. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +5 -2
  94. data/vendor/nginx/src/event/modules/ngx_eventport_module.c +5 -5
  95. data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +15 -8
  96. data/vendor/nginx/src/event/modules/ngx_poll_module.c +0 -10
  97. data/vendor/nginx/src/event/modules/ngx_select_module.c +0 -10
  98. data/vendor/nginx/src/event/ngx_event.c +60 -103
  99. data/vendor/nginx/src/event/ngx_event.h +22 -26
  100. data/vendor/nginx/src/event/ngx_event_accept.c +414 -88
  101. data/vendor/nginx/src/event/ngx_event_connect.c +27 -18
  102. data/vendor/nginx/src/event/ngx_event_connect.h +1 -0
  103. data/vendor/nginx/src/event/ngx_event_openssl.c +65 -25
  104. data/vendor/nginx/src/event/ngx_event_openssl.h +17 -0
  105. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +73 -7
  106. data/vendor/nginx/src/event/ngx_event_pipe.c +85 -27
  107. data/vendor/nginx/src/event/ngx_event_pipe.h +10 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_auth_basic_module.c +1 -1
  109. data/vendor/nginx/src/http/modules/ngx_http_auth_request_module.c +2 -2
  110. data/vendor/nginx/src/http/modules/ngx_http_chunked_filter_module.c +2 -2
  111. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +6 -6
  112. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +17 -11
  113. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +2 -2
  114. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +9 -9
  115. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +2 -2
  116. data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +2 -2
  117. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +0 -7
  118. data/vendor/nginx/src/http/modules/ngx_http_map_module.c +6 -6
  119. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +2 -1
  120. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +13 -13
  121. data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +2 -2
  122. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +26 -21
  123. data/vendor/nginx/src/http/modules/ngx_http_random_index_module.c +1 -1
  124. data/vendor/nginx/src/http/modules/ngx_http_range_filter_module.c +26 -8
  125. data/vendor/nginx/src/http/modules/ngx_http_realip_module.c +73 -3
  126. data/vendor/nginx/src/http/modules/ngx_http_referer_module.c +1 -1
  127. data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +6 -6
  128. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +5 -3
  129. data/vendor/nginx/src/http/modules/ngx_http_slice_filter_module.c +526 -0
  130. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +7 -7
  131. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +19 -16
  132. data/vendor/nginx/src/http/modules/ngx_http_static_module.c +1 -1
  133. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +1 -1
  134. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +373 -173
  135. data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +72 -46
  136. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +18 -30
  137. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +50 -39
  138. data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +38 -129
  139. data/vendor/nginx/src/http/modules/ngx_http_upstream_zone_module.c +246 -0
  140. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +6 -5
  141. data/vendor/nginx/src/http/modules/perl/nginx.xs +9 -9
  142. data/vendor/nginx/src/http/ngx_http.c +46 -43
  143. data/vendor/nginx/src/http/ngx_http.h +4 -9
  144. data/vendor/nginx/src/http/ngx_http_cache.h +4 -0
  145. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +13 -5
  146. data/vendor/nginx/src/http/ngx_http_core_module.c +92 -91
  147. data/vendor/nginx/src/http/ngx_http_core_module.h +12 -8
  148. data/vendor/nginx/src/http/ngx_http_file_cache.c +61 -10
  149. data/vendor/nginx/src/http/ngx_http_request.c +37 -50
  150. data/vendor/nginx/src/http/ngx_http_request.h +10 -15
  151. data/vendor/nginx/src/http/ngx_http_request_body.c +64 -88
  152. data/vendor/nginx/src/http/ngx_http_script.c +3 -3
  153. data/vendor/nginx/src/http/ngx_http_special_response.c +1 -4
  154. data/vendor/nginx/src/http/ngx_http_upstream.c +245 -109
  155. data/vendor/nginx/src/http/ngx_http_upstream.h +11 -5
  156. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +212 -65
  157. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +66 -5
  158. data/vendor/nginx/src/http/ngx_http_variables.c +28 -15
  159. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +1 -1
  160. data/vendor/nginx/src/http/v2/ngx_http_v2.c +4349 -0
  161. data/vendor/nginx/src/http/v2/ngx_http_v2.h +337 -0
  162. data/vendor/nginx/src/http/v2/ngx_http_v2_filter_module.c +1391 -0
  163. data/vendor/nginx/src/http/v2/ngx_http_v2_huff_decode.c +2714 -0
  164. data/vendor/nginx/src/http/v2/ngx_http_v2_huff_encode.c +254 -0
  165. data/vendor/nginx/src/http/v2/ngx_http_v2_module.c +469 -0
  166. data/vendor/nginx/src/http/{ngx_http_spdy_module.h → v2/ngx_http_v2_module.h} +10 -9
  167. data/vendor/nginx/src/http/v2/ngx_http_v2_table.c +349 -0
  168. data/vendor/nginx/src/mail/ngx_mail.c +49 -82
  169. data/vendor/nginx/src/mail/ngx_mail.h +16 -23
  170. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +1 -1
  171. data/vendor/nginx/src/mail/ngx_mail_core_module.c +60 -34
  172. data/vendor/nginx/src/mail/ngx_mail_handler.c +17 -12
  173. data/vendor/nginx/src/mail/ngx_mail_proxy_module.c +1 -14
  174. data/vendor/nginx/src/mail/ngx_mail_smtp_handler.c +1 -1
  175. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +5 -5
  176. data/vendor/nginx/src/os/unix/ngx_atomic.h +10 -10
  177. data/vendor/nginx/src/os/unix/ngx_channel.h +4 -4
  178. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +2 -0
  179. data/vendor/nginx/src/os/unix/ngx_darwin_init.c +1 -0
  180. data/vendor/nginx/src/os/unix/ngx_dlopen.c +28 -0
  181. data/vendor/nginx/src/os/unix/ngx_dlopen.h +31 -0
  182. data/vendor/nginx/src/os/unix/ngx_errno.h +1 -0
  183. data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +1 -1
  184. data/vendor/nginx/src/os/unix/ngx_files.c +313 -80
  185. data/vendor/nginx/src/os/unix/ngx_files.h +5 -2
  186. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +3 -1
  187. data/vendor/nginx/src/os/unix/ngx_freebsd_init.c +1 -0
  188. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +13 -0
  189. data/vendor/nginx/src/os/unix/ngx_linux.h +0 -2
  190. data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +1 -1
  191. data/vendor/nginx/src/os/unix/ngx_linux_config.h +2 -6
  192. data/vendor/nginx/src/os/unix/ngx_linux_init.c +1 -33
  193. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +55 -12
  194. data/vendor/nginx/src/os/unix/ngx_os.h +3 -9
  195. data/vendor/nginx/src/os/unix/ngx_posix_config.h +14 -1
  196. data/vendor/nginx/src/os/unix/ngx_posix_init.c +2 -1
  197. data/vendor/nginx/src/os/unix/ngx_process.c +1 -1
  198. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +25 -51
  199. data/vendor/nginx/src/os/unix/ngx_process_cycle.h +1 -0
  200. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +24 -28
  201. data/vendor/nginx/src/os/unix/ngx_recv.c +30 -79
  202. data/vendor/nginx/src/os/unix/ngx_send.c +1 -1
  203. data/vendor/nginx/src/os/unix/ngx_setaffinity.c +14 -30
  204. data/vendor/nginx/src/os/unix/ngx_setaffinity.h +15 -1
  205. data/vendor/nginx/src/os/unix/ngx_solaris_config.h +2 -0
  206. data/vendor/nginx/src/os/unix/ngx_solaris_init.c +1 -0
  207. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +23 -0
  208. data/vendor/nginx/src/os/unix/ngx_sunpro_amd64.il +3 -3
  209. data/vendor/nginx/src/os/unix/ngx_sunpro_x86.il +3 -3
  210. data/vendor/nginx/src/os/unix/ngx_udp_recv.c +5 -48
  211. data/vendor/nginx/src/os/unix/ngx_udp_send.c +56 -0
  212. data/vendor/nginx/src/stream/ngx_stream.c +564 -0
  213. data/vendor/nginx/src/stream/ngx_stream.h +212 -0
  214. data/vendor/nginx/src/stream/ngx_stream_access_module.c +451 -0
  215. data/vendor/nginx/src/stream/ngx_stream_core_module.c +562 -0
  216. data/vendor/nginx/src/stream/ngx_stream_handler.c +344 -0
  217. data/vendor/nginx/src/stream/ngx_stream_limit_conn_module.c +632 -0
  218. data/vendor/nginx/src/stream/ngx_stream_proxy_module.c +1674 -0
  219. data/vendor/nginx/src/stream/ngx_stream_ssl_module.c +460 -0
  220. data/vendor/nginx/src/stream/ngx_stream_ssl_module.h +49 -0
  221. data/vendor/nginx/src/stream/ngx_stream_upstream.c +464 -0
  222. data/vendor/nginx/src/stream/ngx_stream_upstream.h +107 -0
  223. data/vendor/nginx/src/stream/ngx_stream_upstream_hash_module.c +656 -0
  224. data/vendor/nginx/src/stream/ngx_stream_upstream_least_conn_module.c +307 -0
  225. data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.c +702 -0
  226. data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.h +139 -0
  227. data/vendor/nginx/src/stream/ngx_stream_upstream_zone_module.c +242 -0
  228. metadata +39 -15
  229. data/vendor/nginx/src/event/modules/ngx_aio_module.c +0 -171
  230. data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +0 -735
  231. data/vendor/nginx/src/http/ngx_http_spdy.c +0 -3701
  232. data/vendor/nginx/src/http/ngx_http_spdy.h +0 -261
  233. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +0 -1222
  234. data/vendor/nginx/src/http/ngx_http_spdy_module.c +0 -408
  235. data/vendor/nginx/src/os/unix/ngx_aio_read.c +0 -109
  236. data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +0 -78
  237. data/vendor/nginx/src/os/unix/ngx_aio_write.c +0 -109
  238. data/vendor/nginx/src/os/unix/ngx_aio_write_chain.c +0 -100
@@ -9,8 +9,8 @@
9
9
  #define _NGINX_H_INCLUDED_
10
10
 
11
11
 
12
- #define nginx_version 1008001
13
- #define NGINX_VERSION "1.8.1"
12
+ #define nginx_version 1010001
13
+ #define NGINX_VERSION "1.10.1"
14
14
  #define NGINX_VER "nginx/" NGINX_VERSION
15
15
 
16
16
  #ifdef NGX_BUILD
@@ -101,10 +101,13 @@ char *
101
101
  ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
102
102
  {
103
103
  char *rv;
104
+ u_char *p;
105
+ off_t size;
104
106
  ngx_fd_t fd;
105
107
  ngx_int_t rc;
106
- ngx_buf_t buf;
108
+ ngx_buf_t buf, *tbuf;
107
109
  ngx_conf_file_t *prev, conf_file;
110
+ ngx_conf_dump_t *cd;
108
111
  enum {
109
112
  parse_file = 0,
110
113
  parse_block,
@@ -158,6 +161,39 @@ ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
158
161
 
159
162
  type = parse_file;
160
163
 
164
+ if (ngx_dump_config
165
+ #if (NGX_DEBUG)
166
+ || 1
167
+ #endif
168
+ )
169
+ {
170
+ p = ngx_pstrdup(cf->cycle->pool, filename);
171
+ if (p == NULL) {
172
+ goto failed;
173
+ }
174
+
175
+ size = ngx_file_size(&cf->conf_file->file.info);
176
+
177
+ tbuf = ngx_create_temp_buf(cf->cycle->pool, (size_t) size);
178
+ if (tbuf == NULL) {
179
+ goto failed;
180
+ }
181
+
182
+ cd = ngx_array_push(&cf->cycle->config_dump);
183
+ if (cd == NULL) {
184
+ goto failed;
185
+ }
186
+
187
+ cd->name.len = filename->len;
188
+ cd->name.data = p;
189
+ cd->buffer = tbuf;
190
+
191
+ cf->conf_file->dump = tbuf;
192
+
193
+ } else {
194
+ cf->conf_file->dump = NULL;
195
+ }
196
+
161
197
  } else if (cf->conf_file->file.fd != NGX_INVALID_FILE) {
162
198
 
163
199
  type = parse_block;
@@ -293,9 +329,9 @@ ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last)
293
329
 
294
330
  found = 0;
295
331
 
296
- for (i = 0; ngx_modules[i]; i++) {
332
+ for (i = 0; cf->cycle->modules[i]; i++) {
297
333
 
298
- cmd = ngx_modules[i]->commands;
334
+ cmd = cf->cycle->modules[i]->commands;
299
335
  if (cmd == NULL) {
300
336
  continue;
301
337
  }
@@ -312,8 +348,8 @@ ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last)
312
348
 
313
349
  found = 1;
314
350
 
315
- if (ngx_modules[i]->type != NGX_CONF_MODULE
316
- && ngx_modules[i]->type != cf->module_type)
351
+ if (cf->cycle->modules[i]->type != NGX_CONF_MODULE
352
+ && cf->cycle->modules[i]->type != cf->module_type)
317
353
  {
318
354
  continue;
319
355
  }
@@ -375,16 +411,16 @@ ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last)
375
411
  conf = NULL;
376
412
 
377
413
  if (cmd->type & NGX_DIRECT_CONF) {
378
- conf = ((void **) cf->ctx)[ngx_modules[i]->index];
414
+ conf = ((void **) cf->ctx)[cf->cycle->modules[i]->index];
379
415
 
380
416
  } else if (cmd->type & NGX_MAIN_CONF) {
381
- conf = &(((void **) cf->ctx)[ngx_modules[i]->index]);
417
+ conf = &(((void **) cf->ctx)[cf->cycle->modules[i]->index]);
382
418
 
383
419
  } else if (cf->ctx) {
384
420
  confp = *(void **) ((char *) cf->ctx + cmd->conf);
385
421
 
386
422
  if (confp) {
387
- conf = confp[ngx_modules[i]->ctx_index];
423
+ conf = confp[cf->cycle->modules[i]->ctx_index];
388
424
  }
389
425
  }
390
426
 
@@ -437,7 +473,7 @@ ngx_conf_read_token(ngx_conf_t *cf)
437
473
  ngx_uint_t found, need_space, last_space, sharp_comment, variable;
438
474
  ngx_uint_t quoted, s_quoted, d_quoted, start_line;
439
475
  ngx_str_t *word;
440
- ngx_buf_t *b;
476
+ ngx_buf_t *b, *dump;
441
477
 
442
478
  found = 0;
443
479
  need_space = 0;
@@ -450,6 +486,7 @@ ngx_conf_read_token(ngx_conf_t *cf)
450
486
 
451
487
  cf->args->nelts = 0;
452
488
  b = cf->conf_file->buffer;
489
+ dump = cf->conf_file->dump;
453
490
  start = b->pos;
454
491
  start_line = cf->conf_file->line;
455
492
 
@@ -531,6 +568,10 @@ ngx_conf_read_token(ngx_conf_t *cf)
531
568
  b->pos = b->start + len;
532
569
  b->last = b->pos + n;
533
570
  start = b->start;
571
+
572
+ if (dump) {
573
+ dump->last = ngx_cpymem(dump->last, b->pos, size);
574
+ }
534
575
  }
535
576
 
536
577
  ch = *b->pos++;
@@ -572,9 +613,9 @@ ngx_conf_read_token(ngx_conf_t *cf)
572
613
  need_space = 0;
573
614
 
574
615
  } else {
575
- ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
576
- "unexpected \"%c\"", ch);
577
- return NGX_ERROR;
616
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
617
+ "unexpected \"%c\"", ch);
618
+ return NGX_ERROR;
578
619
  }
579
620
  }
580
621
 
@@ -680,7 +721,7 @@ ngx_conf_read_token(ngx_conf_t *cf)
680
721
  return NGX_ERROR;
681
722
  }
682
723
 
683
- word->data = ngx_pnalloc(cf->pool, b->pos - start + 1);
724
+ word->data = ngx_pnalloc(cf->pool, b->pos - 1 - start + 1);
684
725
  if (word->data == NULL) {
685
726
  return NGX_ERROR;
686
727
  }
@@ -50,7 +50,7 @@
50
50
  #define NGX_DIRECT_CONF 0x00010000
51
51
 
52
52
  #define NGX_MAIN_CONF 0x01000000
53
- #define NGX_ANY_CONF 0x0F000000
53
+ #define NGX_ANY_CONF 0x1F000000
54
54
 
55
55
 
56
56
 
@@ -96,60 +96,20 @@ struct ngx_open_file_s {
96
96
  };
97
97
 
98
98
 
99
- #define NGX_MODULE_V1 0, 0, 0, 0, 0, 0, 1
100
- #define NGX_MODULE_V1_PADDING 0, 0, 0, 0, 0, 0, 0, 0
101
-
102
- struct ngx_module_s {
103
- ngx_uint_t ctx_index;
104
- ngx_uint_t index;
105
-
106
- ngx_uint_t spare0;
107
- ngx_uint_t spare1;
108
- ngx_uint_t spare2;
109
- ngx_uint_t spare3;
110
-
111
- ngx_uint_t version;
112
-
113
- void *ctx;
114
- ngx_command_t *commands;
115
- ngx_uint_t type;
116
-
117
- ngx_int_t (*init_master)(ngx_log_t *log);
118
-
119
- ngx_int_t (*init_module)(ngx_cycle_t *cycle);
120
-
121
- ngx_int_t (*init_process)(ngx_cycle_t *cycle);
122
- ngx_int_t (*init_thread)(ngx_cycle_t *cycle);
123
- void (*exit_thread)(ngx_cycle_t *cycle);
124
- void (*exit_process)(ngx_cycle_t *cycle);
125
-
126
- void (*exit_master)(ngx_cycle_t *cycle);
127
-
128
- uintptr_t spare_hook0;
129
- uintptr_t spare_hook1;
130
- uintptr_t spare_hook2;
131
- uintptr_t spare_hook3;
132
- uintptr_t spare_hook4;
133
- uintptr_t spare_hook5;
134
- uintptr_t spare_hook6;
135
- uintptr_t spare_hook7;
136
- };
137
-
138
-
139
- typedef struct {
140
- ngx_str_t name;
141
- void *(*create_conf)(ngx_cycle_t *cycle);
142
- char *(*init_conf)(ngx_cycle_t *cycle, void *conf);
143
- } ngx_core_module_t;
144
-
145
-
146
99
  typedef struct {
147
100
  ngx_file_t file;
148
101
  ngx_buf_t *buffer;
102
+ ngx_buf_t *dump;
149
103
  ngx_uint_t line;
150
104
  } ngx_conf_file_t;
151
105
 
152
106
 
107
+ typedef struct {
108
+ ngx_str_t name;
109
+ ngx_buf_t *buffer;
110
+ } ngx_conf_dump_t;
111
+
112
+
153
113
  typedef char *(*ngx_conf_handler_pt)(ngx_conf_t *cf,
154
114
  ngx_command_t *dummy, void *conf);
155
115
 
@@ -333,8 +293,4 @@ char *ngx_conf_set_enum_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
333
293
  char *ngx_conf_set_bitmask_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
334
294
 
335
295
 
336
- extern ngx_uint_t ngx_max_module;
337
- extern ngx_module_t *ngx_modules[];
338
-
339
-
340
296
  #endif /* _NGX_CONF_FILE_H_INCLUDED_ */
@@ -125,12 +125,7 @@ typedef intptr_t ngx_flag_t;
125
125
  #endif
126
126
 
127
127
 
128
- #if ((__GNU__ == 2) && (__GNUC_MINOR__ < 8))
129
- #define NGX_MAX_UINT32_VALUE (uint32_t) 0xffffffffLL
130
- #else
131
128
  #define NGX_MAX_UINT32_VALUE (uint32_t) 0xffffffff
132
- #endif
133
-
134
129
  #define NGX_MAX_INT32_VALUE (uint32_t) 0x7fffffff
135
130
 
136
131
 
@@ -47,21 +47,21 @@ ngx_create_listening(ngx_conf_t *cf, void *sockaddr, socklen_t socklen)
47
47
  switch (ls->sockaddr->sa_family) {
48
48
  #if (NGX_HAVE_INET6)
49
49
  case AF_INET6:
50
- ls->addr_text_max_len = NGX_INET6_ADDRSTRLEN;
51
- break;
50
+ ls->addr_text_max_len = NGX_INET6_ADDRSTRLEN;
51
+ break;
52
52
  #endif
53
53
  #if (NGX_HAVE_UNIX_DOMAIN)
54
54
  case AF_UNIX:
55
- ls->addr_text_max_len = NGX_UNIX_ADDRSTRLEN;
56
- len++;
57
- break;
55
+ ls->addr_text_max_len = NGX_UNIX_ADDRSTRLEN;
56
+ len++;
57
+ break;
58
58
  #endif
59
59
  case AF_INET:
60
- ls->addr_text_max_len = NGX_INET_ADDRSTRLEN;
61
- break;
60
+ ls->addr_text_max_len = NGX_INET_ADDRSTRLEN;
61
+ break;
62
62
  default:
63
- ls->addr_text_max_len = NGX_SOCKADDR_STRLEN;
64
- break;
63
+ ls->addr_text_max_len = NGX_SOCKADDR_STRLEN;
64
+ break;
65
65
  }
66
66
 
67
67
  ls->addr_text.data = ngx_pnalloc(cf->pool, len);
@@ -90,6 +90,43 @@ ngx_create_listening(ngx_conf_t *cf, void *sockaddr, socklen_t socklen)
90
90
  }
91
91
 
92
92
 
93
+ ngx_int_t
94
+ ngx_clone_listening(ngx_conf_t *cf, ngx_listening_t *ls)
95
+ {
96
+ #if (NGX_HAVE_REUSEPORT)
97
+
98
+ ngx_int_t n;
99
+ ngx_core_conf_t *ccf;
100
+ ngx_listening_t ols;
101
+
102
+ if (!ls->reuseport) {
103
+ return NGX_OK;
104
+ }
105
+
106
+ ols = *ls;
107
+
108
+ ccf = (ngx_core_conf_t *) ngx_get_conf(cf->cycle->conf_ctx,
109
+ ngx_core_module);
110
+
111
+ for (n = 1; n < ccf->worker_processes; n++) {
112
+
113
+ /* create a socket for each worker process */
114
+
115
+ ls = ngx_array_push(&cf->cycle->listening);
116
+ if (ls == NULL) {
117
+ return NGX_ERROR;
118
+ }
119
+
120
+ *ls = ols;
121
+ ls->worker = n;
122
+ }
123
+
124
+ #endif
125
+
126
+ return NGX_OK;
127
+ }
128
+
129
+
93
130
  ngx_int_t
94
131
  ngx_set_inherited_sockets(ngx_cycle_t *cycle)
95
132
  {
@@ -106,6 +143,9 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
106
143
  #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
107
144
  int timeout;
108
145
  #endif
146
+ #if (NGX_HAVE_REUSEPORT)
147
+ int reuseport;
148
+ #endif
109
149
 
110
150
  ls = cycle->listening.elts;
111
151
  for (i = 0; i < cycle->listening.nelts; i++) {
@@ -128,22 +168,22 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
128
168
 
129
169
  #if (NGX_HAVE_INET6)
130
170
  case AF_INET6:
131
- ls[i].addr_text_max_len = NGX_INET6_ADDRSTRLEN;
132
- len = NGX_INET6_ADDRSTRLEN + sizeof("[]:65535") - 1;
133
- break;
171
+ ls[i].addr_text_max_len = NGX_INET6_ADDRSTRLEN;
172
+ len = NGX_INET6_ADDRSTRLEN + sizeof("[]:65535") - 1;
173
+ break;
134
174
  #endif
135
175
 
136
176
  #if (NGX_HAVE_UNIX_DOMAIN)
137
177
  case AF_UNIX:
138
- ls[i].addr_text_max_len = NGX_UNIX_ADDRSTRLEN;
139
- len = NGX_UNIX_ADDRSTRLEN;
140
- break;
178
+ ls[i].addr_text_max_len = NGX_UNIX_ADDRSTRLEN;
179
+ len = NGX_UNIX_ADDRSTRLEN;
180
+ break;
141
181
  #endif
142
182
 
143
183
  case AF_INET:
144
- ls[i].addr_text_max_len = NGX_INET_ADDRSTRLEN;
145
- len = NGX_INET_ADDRSTRLEN + sizeof(":65535") - 1;
146
- break;
184
+ ls[i].addr_text_max_len = NGX_INET_ADDRSTRLEN;
185
+ len = NGX_INET_ADDRSTRLEN + sizeof(":65535") - 1;
186
+ break;
147
187
 
148
188
  default:
149
189
  ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_socket_errno,
@@ -170,6 +210,18 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
170
210
 
171
211
  olen = sizeof(int);
172
212
 
213
+ if (getsockopt(ls[i].fd, SOL_SOCKET, SO_TYPE, (void *) &ls[i].type,
214
+ &olen)
215
+ == -1)
216
+ {
217
+ ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_socket_errno,
218
+ "getsockopt(SO_TYPE) %V failed", &ls[i].addr_text);
219
+ ls[i].ignore = 1;
220
+ continue;
221
+ }
222
+
223
+ olen = sizeof(int);
224
+
173
225
  if (getsockopt(ls[i].fd, SOL_SOCKET, SO_RCVBUF, (void *) &ls[i].rcvbuf,
174
226
  &olen)
175
227
  == -1)
@@ -215,6 +267,29 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
215
267
  #endif
216
268
  #endif
217
269
 
270
+ #if (NGX_HAVE_REUSEPORT)
271
+
272
+ reuseport = 0;
273
+ olen = sizeof(int);
274
+
275
+ if (getsockopt(ls[i].fd, SOL_SOCKET, SO_REUSEPORT,
276
+ (void *) &reuseport, &olen)
277
+ == -1)
278
+ {
279
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
280
+ "getsockopt(SO_REUSEPORT) %V failed, ignored",
281
+ &ls[i].addr_text);
282
+
283
+ } else {
284
+ ls[i].reuseport = reuseport ? 1 : 0;
285
+ }
286
+
287
+ #endif
288
+
289
+ if (ls[i].type != SOCK_STREAM) {
290
+ continue;
291
+ }
292
+
218
293
  #if (NGX_HAVE_TCP_FASTOPEN)
219
294
 
220
295
  olen = sizeof(int);
@@ -332,6 +407,31 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
332
407
  continue;
333
408
  }
334
409
 
410
+ #if (NGX_HAVE_REUSEPORT)
411
+
412
+ if (ls[i].add_reuseport) {
413
+
414
+ /*
415
+ * to allow transition from a socket without SO_REUSEPORT
416
+ * to multiple sockets with SO_REUSEPORT, we have to set
417
+ * SO_REUSEPORT on the old socket before opening new ones
418
+ */
419
+
420
+ int reuseport = 1;
421
+
422
+ if (setsockopt(ls[i].fd, SOL_SOCKET, SO_REUSEPORT,
423
+ (const void *) &reuseport, sizeof(int))
424
+ == -1)
425
+ {
426
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
427
+ "setsockopt(SO_REUSEPORT) %V failed, ignored",
428
+ &ls[i].addr_text);
429
+ }
430
+
431
+ ls[i].add_reuseport = 0;
432
+ }
433
+ #endif
434
+
335
435
  if (ls[i].fd != (ngx_socket_t) -1) {
336
436
  continue;
337
437
  }
@@ -370,6 +470,32 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
370
470
  return NGX_ERROR;
371
471
  }
372
472
 
473
+ #if (NGX_HAVE_REUSEPORT)
474
+
475
+ if (ls[i].reuseport) {
476
+ int reuseport;
477
+
478
+ reuseport = 1;
479
+
480
+ if (setsockopt(s, SOL_SOCKET, SO_REUSEPORT,
481
+ (const void *) &reuseport, sizeof(int))
482
+ == -1)
483
+ {
484
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
485
+ "setsockopt(SO_REUSEPORT) %V failed, ignored",
486
+ &ls[i].addr_text);
487
+
488
+ if (ngx_close_socket(s) == -1) {
489
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
490
+ ngx_close_socket_n " %V failed",
491
+ &ls[i].addr_text);
492
+ }
493
+
494
+ return NGX_ERROR;
495
+ }
496
+ }
497
+ #endif
498
+
373
499
  #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
374
500
 
375
501
  if (ls[i].sockaddr->sa_family == AF_INET6) {
@@ -389,7 +515,7 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
389
515
  #endif
390
516
  /* TODO: close on exit */
391
517
 
392
- if (!(ngx_event_flags & NGX_USE_AIO_EVENT)) {
518
+ if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)) {
393
519
  if (ngx_nonblocking(s) == -1) {
394
520
  ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
395
521
  ngx_nonblocking_n " %V failed",
@@ -456,10 +582,25 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
456
582
  }
457
583
  #endif
458
584
 
585
+ if (ls[i].type != SOCK_STREAM) {
586
+ ls[i].fd = s;
587
+ continue;
588
+ }
589
+
459
590
  if (listen(s, ls[i].backlog) == -1) {
460
- ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
461
- "listen() to %V, backlog %d failed",
462
- &ls[i].addr_text, ls[i].backlog);
591
+ err = ngx_socket_errno;
592
+
593
+ /*
594
+ * on OpenVZ after suspend/resume EADDRINUSE
595
+ * may be returned by listen() instead of bind(), see
596
+ * https://bugzilla.openvz.org/show_bug.cgi?id=2470
597
+ */
598
+
599
+ if (err != NGX_EADDRINUSE || !ngx_test_config) {
600
+ ngx_log_error(NGX_LOG_EMERG, log, err,
601
+ "listen() to %V, backlog %d failed",
602
+ &ls[i].addr_text, ls[i].backlog);
603
+ }
463
604
 
464
605
  if (ngx_close_socket(s) == -1) {
465
606
  ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
@@ -467,7 +608,15 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
467
608
  &ls[i].addr_text);
468
609
  }
469
610
 
470
- return NGX_ERROR;
611
+ if (err != NGX_EADDRINUSE) {
612
+ return NGX_ERROR;
613
+ }
614
+
615
+ if (!ngx_test_config) {
616
+ failed = 1;
617
+ }
618
+
619
+ continue;
471
620
  }
472
621
 
473
622
  ls[i].listen = 1;
@@ -737,6 +886,67 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
737
886
  #endif
738
887
 
739
888
  #endif /* NGX_HAVE_DEFERRED_ACCEPT */
889
+
890
+ #if (NGX_HAVE_IP_RECVDSTADDR)
891
+
892
+ if (ls[i].wildcard
893
+ && ls[i].type == SOCK_DGRAM
894
+ && ls[i].sockaddr->sa_family == AF_INET)
895
+ {
896
+ value = 1;
897
+
898
+ if (setsockopt(ls[i].fd, IPPROTO_IP, IP_RECVDSTADDR,
899
+ (const void *) &value, sizeof(int))
900
+ == -1)
901
+ {
902
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
903
+ "setsockopt(IP_RECVDSTADDR) "
904
+ "for %V failed, ignored",
905
+ &ls[i].addr_text);
906
+ }
907
+ }
908
+
909
+ #elif (NGX_HAVE_IP_PKTINFO)
910
+
911
+ if (ls[i].wildcard
912
+ && ls[i].type == SOCK_DGRAM
913
+ && ls[i].sockaddr->sa_family == AF_INET)
914
+ {
915
+ value = 1;
916
+
917
+ if (setsockopt(ls[i].fd, IPPROTO_IP, IP_PKTINFO,
918
+ (const void *) &value, sizeof(int))
919
+ == -1)
920
+ {
921
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
922
+ "setsockopt(IP_PKTINFO) "
923
+ "for %V failed, ignored",
924
+ &ls[i].addr_text);
925
+ }
926
+ }
927
+
928
+ #endif
929
+
930
+ #if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO)
931
+
932
+ if (ls[i].wildcard
933
+ && ls[i].type == SOCK_DGRAM
934
+ && ls[i].sockaddr->sa_family == AF_INET6)
935
+ {
936
+ value = 1;
937
+
938
+ if (setsockopt(ls[i].fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
939
+ (const void *) &value, sizeof(int))
940
+ == -1)
941
+ {
942
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
943
+ "setsockopt(IPV6_RECVPKTINFO) "
944
+ "for %V failed, ignored",
945
+ &ls[i].addr_text);
946
+ }
947
+ }
948
+
949
+ #endif
740
950
  }
741
951
 
742
952
  return;
@@ -764,10 +974,7 @@ ngx_close_listening_sockets(ngx_cycle_t *cycle)
764
974
 
765
975
  if (c) {
766
976
  if (c->read->active) {
767
- if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
768
- ngx_del_conn(c, NGX_CLOSE_EVENT);
769
-
770
- } else if (ngx_event_flags & NGX_USE_EPOLL_EVENT) {
977
+ if (ngx_event_flags & NGX_USE_EPOLL_EVENT) {
771
978
 
772
979
  /*
773
980
  * it seems that Linux-2.6.x OpenVZ sends events
@@ -853,7 +1060,7 @@ ngx_get_connection(ngx_socket_t s, ngx_log_t *log)
853
1060
  ngx_cycle->free_connections = c->data;
854
1061
  ngx_cycle->free_connection_n--;
855
1062
 
856
- if (ngx_cycle->files) {
1063
+ if (ngx_cycle->files && ngx_cycle->files[s] == NULL) {
857
1064
  ngx_cycle->files[s] = c;
858
1065
  }
859
1066
 
@@ -894,7 +1101,7 @@ ngx_free_connection(ngx_connection_t *c)
894
1101
  ngx_cycle->free_connections = c;
895
1102
  ngx_cycle->free_connection_n++;
896
1103
 
897
- if (ngx_cycle->files) {
1104
+ if (ngx_cycle->files && ngx_cycle->files[c->fd] == c) {
898
1105
  ngx_cycle->files[c->fd] = NULL;
899
1106
  }
900
1107
  }
@@ -920,16 +1127,18 @@ ngx_close_connection(ngx_connection_t *c)
920
1127
  ngx_del_timer(c->write);
921
1128
  }
922
1129
 
923
- if (ngx_del_conn) {
924
- ngx_del_conn(c, NGX_CLOSE_EVENT);
1130
+ if (!c->shared) {
1131
+ if (ngx_del_conn) {
1132
+ ngx_del_conn(c, NGX_CLOSE_EVENT);
925
1133
 
926
- } else {
927
- if (c->read->active || c->read->disabled) {
928
- ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
929
- }
1134
+ } else {
1135
+ if (c->read->active || c->read->disabled) {
1136
+ ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
1137
+ }
930
1138
 
931
- if (c->write->active || c->write->disabled) {
932
- ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
1139
+ if (c->write->active || c->write->disabled) {
1140
+ ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
1141
+ }
933
1142
  }
934
1143
  }
935
1144
 
@@ -953,6 +1162,10 @@ ngx_close_connection(ngx_connection_t *c)
953
1162
  fd = c->fd;
954
1163
  c->fd = (ngx_socket_t) -1;
955
1164
 
1165
+ if (c->shared) {
1166
+ return;
1167
+ }
1168
+
956
1169
  if (ngx_close_socket(fd) == -1) {
957
1170
 
958
1171
  err = ngx_socket_errno;
@@ -1038,6 +1251,26 @@ ngx_drain_connections(void)
1038
1251
  }
1039
1252
 
1040
1253
 
1254
+ void
1255
+ ngx_close_idle_connections(ngx_cycle_t *cycle)
1256
+ {
1257
+ ngx_uint_t i;
1258
+ ngx_connection_t *c;
1259
+
1260
+ c = cycle->connections;
1261
+
1262
+ for (i = 0; i < cycle->connection_n; i++) {
1263
+
1264
+ /* THREAD: lock */
1265
+
1266
+ if (c[i].fd != (ngx_socket_t) -1 && c[i].idle) {
1267
+ c[i].close = 1;
1268
+ c[i].read->handler(c[i].read);
1269
+ }
1270
+ }
1271
+ }
1272
+
1273
+
1041
1274
  ngx_int_t
1042
1275
  ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
1043
1276
  ngx_uint_t port)