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
@@ -337,12 +337,14 @@ ngx_http_xslt_send(ngx_http_request_t *r, ngx_http_xslt_filter_ctx_t *ctx,
337
337
  r->headers_out.content_length = NULL;
338
338
  }
339
339
 
340
- ngx_http_clear_etag(r);
341
-
342
340
  conf = ngx_http_get_module_loc_conf(r, ngx_http_xslt_filter_module);
343
341
 
344
342
  if (!conf->last_modified) {
345
343
  ngx_http_clear_last_modified(r);
344
+ ngx_http_clear_etag(r);
345
+
346
+ } else {
347
+ ngx_http_weak_etag(r);
346
348
  }
347
349
  }
348
350
 
@@ -577,7 +577,7 @@ ngx_http_perl_create_interpreter(ngx_conf_t *cf,
577
577
 
578
578
  n = (pmcf->modules != NGX_CONF_UNSET_PTR) ? pmcf->modules->nelts * 2 : 0;
579
579
 
580
- embedding = ngx_palloc(cf->pool, (4 + n) * sizeof(char *));
580
+ embedding = ngx_palloc(cf->pool, (5 + n) * sizeof(char *));
581
581
  if (embedding == NULL) {
582
582
  goto fail;
583
583
  }
@@ -595,6 +595,7 @@ ngx_http_perl_create_interpreter(ngx_conf_t *cf,
595
595
  embedding[n++] = "-Mnginx";
596
596
  embedding[n++] = "-e";
597
597
  embedding[n++] = "0";
598
+ embedding[n] = NULL;
598
599
 
599
600
  n = perl_parse(perl, ngx_http_perl_xs_init, n, embedding, NULL);
600
601
 
@@ -69,8 +69,9 @@ static ngx_int_t ngx_http_add_addrs6(ngx_conf_t *cf, ngx_http_port_t *hport,
69
69
  ngx_uint_t ngx_http_max_module;
70
70
 
71
71
 
72
- ngx_int_t (*ngx_http_top_header_filter) (ngx_http_request_t *r);
73
- ngx_int_t (*ngx_http_top_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch);
72
+ ngx_http_output_header_filter_pt ngx_http_top_header_filter;
73
+ ngx_http_output_body_filter_pt ngx_http_top_body_filter;
74
+ ngx_http_request_body_filter_pt ngx_http_top_request_body_filter;
74
75
 
75
76
 
76
77
  ngx_str_t ngx_http_html_default_types[] = {
@@ -742,7 +743,7 @@ ngx_http_init_locations(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
742
743
 
743
744
  if (named) {
744
745
  clcfp = ngx_palloc(cf->pool,
745
- (n + 1) * sizeof(ngx_http_core_loc_conf_t **));
746
+ (n + 1) * sizeof(ngx_http_core_loc_conf_t *));
746
747
  if (clcfp == NULL) {
747
748
  return NGX_ERROR;
748
749
  }
@@ -768,7 +769,7 @@ ngx_http_init_locations(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
768
769
  if (regex) {
769
770
 
770
771
  clcfp = ngx_palloc(cf->pool,
771
- (r + 1) * sizeof(ngx_http_core_loc_conf_t **));
772
+ (r + 1) * sizeof(ngx_http_core_loc_conf_t *));
772
773
  if (clcfp == NULL) {
773
774
  return NGX_ERROR;
774
775
  }
@@ -2005,7 +2006,7 @@ ngx_http_types_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
2005
2006
  if (ngx_strcmp(value[i].data, type[n].key.data) == 0) {
2006
2007
  ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
2007
2008
  "duplicate MIME type \"%V\"", &value[i]);
2008
- continue;
2009
+ goto next;
2009
2010
  }
2010
2011
  }
2011
2012
 
@@ -2017,6 +2018,10 @@ ngx_http_types_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
2017
2018
  type->key = value[i];
2018
2019
  type->key_hash = hash;
2019
2020
  type->value = (void *) 4;
2021
+
2022
+ next:
2023
+
2024
+ continue;
2020
2025
  }
2021
2026
 
2022
2027
  return NGX_CONF_OK;
@@ -36,7 +36,6 @@ typedef u_char *(*ngx_http_log_handler_pt)(ngx_http_request_t *r,
36
36
  #include <ngx_http_script.h>
37
37
  #include <ngx_http_upstream.h>
38
38
  #include <ngx_http_upstream_round_robin.h>
39
- #include <ngx_http_busy_lock.h>
40
39
  #include <ngx_http_core_module.h>
41
40
 
42
41
  #if (NGX_HTTP_SPDY)
@@ -105,6 +104,8 @@ ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b,
105
104
  ngx_uint_t allow_underscores);
106
105
  ngx_int_t ngx_http_parse_multi_header_lines(ngx_array_t *headers,
107
106
  ngx_str_t *name, ngx_str_t *value);
107
+ ngx_int_t ngx_http_parse_set_cookie_lines(ngx_array_t *headers,
108
+ ngx_str_t *name, ngx_str_t *value);
108
109
  ngx_int_t ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len,
109
110
  ngx_str_t *value);
110
111
  void ngx_http_split_args(ngx_http_request_t *r, ngx_str_t *uri,
@@ -129,9 +130,6 @@ void ngx_http_empty_handler(ngx_event_t *wev);
129
130
  void ngx_http_request_empty_handler(ngx_http_request_t *r);
130
131
 
131
132
 
132
- #define ngx_http_ephemeral(r) (void *) (&r->uri_start)
133
-
134
-
135
133
  #define NGX_HTTP_LAST 1
136
134
  #define NGX_HTTP_FLUSH 2
137
135
 
@@ -140,6 +138,7 @@ ngx_int_t ngx_http_send_special(ngx_http_request_t *r, ngx_uint_t flags);
140
138
 
141
139
  ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
142
140
  ngx_http_client_body_handler_pt post_handler);
141
+ ngx_int_t ngx_http_read_unbuffered_request_body(ngx_http_request_t *r);
143
142
 
144
143
  ngx_int_t ngx_http_send_header(ngx_http_request_t *r);
145
144
  ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r,
@@ -179,6 +178,7 @@ extern ngx_str_t ngx_http_html_default_types[];
179
178
 
180
179
  extern ngx_http_output_header_filter_pt ngx_http_top_header_filter;
181
180
  extern ngx_http_output_body_filter_pt ngx_http_top_body_filter;
181
+ extern ngx_http_request_body_filter_pt ngx_http_top_request_body_filter;
182
182
 
183
183
 
184
184
  #endif /* _NGX_HTTP_H_INCLUDED_ */
@@ -24,6 +24,10 @@
24
24
  #define NGX_HTTP_CACHE_SCARCE 8
25
25
 
26
26
  #define NGX_HTTP_CACHE_KEY_LEN 16
27
+ #define NGX_HTTP_CACHE_ETAG_LEN 42
28
+ #define NGX_HTTP_CACHE_VARY_LEN 42
29
+
30
+ #define NGX_HTTP_CACHE_VERSION 3
27
31
 
28
32
 
29
33
  typedef struct {
@@ -53,6 +57,7 @@ typedef struct {
53
57
  time_t valid_sec;
54
58
  size_t body_start;
55
59
  off_t fs_size;
60
+ ngx_msec_t lock_time;
56
61
  } ngx_http_file_cache_node_t;
57
62
 
58
63
 
@@ -61,12 +66,17 @@ struct ngx_http_cache_s {
61
66
  ngx_array_t keys;
62
67
  uint32_t crc32;
63
68
  u_char key[NGX_HTTP_CACHE_KEY_LEN];
69
+ u_char main[NGX_HTTP_CACHE_KEY_LEN];
64
70
 
65
71
  ngx_file_uniq_t uniq;
66
72
  time_t valid_sec;
67
73
  time_t last_modified;
68
74
  time_t date;
69
75
 
76
+ ngx_str_t etag;
77
+ ngx_str_t vary;
78
+ u_char variant[NGX_HTTP_CACHE_KEY_LEN];
79
+
70
80
  size_t header_start;
71
81
  size_t body_start;
72
82
  off_t length;
@@ -81,7 +91,13 @@ struct ngx_http_cache_s {
81
91
  ngx_http_file_cache_t *file_cache;
82
92
  ngx_http_file_cache_node_t *node;
83
93
 
94
+ #if (NGX_THREADS)
95
+ ngx_thread_task_t *thread_task;
96
+ #endif
97
+
84
98
  ngx_msec_t lock_timeout;
99
+ ngx_msec_t lock_age;
100
+ ngx_msec_t lock_time;
85
101
  ngx_msec_t wait_time;
86
102
 
87
103
  ngx_event_t wait_event;
@@ -93,10 +109,13 @@ struct ngx_http_cache_s {
93
109
  unsigned updating:1;
94
110
  unsigned exists:1;
95
111
  unsigned temp_file:1;
112
+ unsigned reading:1;
113
+ unsigned secondary:1;
96
114
  };
97
115
 
98
116
 
99
117
  typedef struct {
118
+ ngx_uint_t version;
100
119
  time_t valid_sec;
101
120
  time_t last_modified;
102
121
  time_t date;
@@ -104,6 +123,11 @@ typedef struct {
104
123
  u_short valid_msec;
105
124
  u_short header_start;
106
125
  u_short body_start;
126
+ u_char etag_len;
127
+ u_char etag[NGX_HTTP_CACHE_ETAG_LEN];
128
+ u_char vary_len;
129
+ u_char vary[NGX_HTTP_CACHE_VARY_LEN];
130
+ u_char variant[NGX_HTTP_CACHE_KEY_LEN];
107
131
  } ngx_http_file_cache_header_t;
108
132
 
109
133
 
@@ -122,6 +146,7 @@ struct ngx_http_file_cache_s {
122
146
  ngx_slab_pool_t *shpool;
123
147
 
124
148
  ngx_path_t *path;
149
+ ngx_path_t *temp_path;
125
150
 
126
151
  off_t max_size;
127
152
  size_t bsize;
@@ -142,7 +167,7 @@ ngx_int_t ngx_http_file_cache_new(ngx_http_request_t *r);
142
167
  ngx_int_t ngx_http_file_cache_create(ngx_http_request_t *r);
143
168
  void ngx_http_file_cache_create_key(ngx_http_request_t *r);
144
169
  ngx_int_t ngx_http_file_cache_open(ngx_http_request_t *r);
145
- void ngx_http_file_cache_set_header(ngx_http_request_t *r, u_char *buf);
170
+ ngx_int_t ngx_http_file_cache_set_header(ngx_http_request_t *r, u_char *buf);
146
171
  void ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf);
147
172
  void ngx_http_file_cache_update_header(ngx_http_request_t *r);
148
173
  ngx_int_t ngx_http_cache_send(ngx_http_request_t *);
@@ -20,9 +20,15 @@ static void ngx_http_copy_aio_handler(ngx_output_chain_ctx_t *ctx,
20
20
  ngx_file_t *file);
21
21
  static void ngx_http_copy_aio_event_handler(ngx_event_t *ev);
22
22
  #if (NGX_HAVE_AIO_SENDFILE)
23
+ static ssize_t ngx_http_copy_aio_sendfile_preload(ngx_buf_t *file);
23
24
  static void ngx_http_copy_aio_sendfile_event_handler(ngx_event_t *ev);
24
25
  #endif
25
26
  #endif
27
+ #if (NGX_THREADS)
28
+ static ngx_int_t ngx_http_copy_thread_handler(ngx_thread_task_t *task,
29
+ ngx_file_t *file);
30
+ static void ngx_http_copy_thread_event_handler(ngx_event_t *ev);
31
+ #endif
26
32
 
27
33
  static void *ngx_http_copy_filter_create_conf(ngx_conf_t *cf);
28
34
  static char *ngx_http_copy_filter_merge_conf(ngx_conf_t *cf,
@@ -120,91 +126,42 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
120
126
  ctx->filter_ctx = r;
121
127
 
122
128
  #if (NGX_HAVE_FILE_AIO)
123
- if (ngx_file_aio) {
124
- if (clcf->aio) {
125
- ctx->aio_handler = ngx_http_copy_aio_handler;
126
- }
129
+ if (ngx_file_aio && clcf->aio == NGX_HTTP_AIO_ON) {
130
+ ctx->aio_handler = ngx_http_copy_aio_handler;
127
131
  #if (NGX_HAVE_AIO_SENDFILE)
128
- c->aio_sendfile = (clcf->aio == NGX_HTTP_AIO_SENDFILE);
132
+ ctx->aio_preload = ngx_http_copy_aio_sendfile_preload;
129
133
  #endif
130
134
  }
131
135
  #endif
132
136
 
137
+ #if (NGX_THREADS)
138
+ if (clcf->aio == NGX_HTTP_AIO_THREADS) {
139
+ ctx->thread_handler = ngx_http_copy_thread_handler;
140
+ }
141
+ #endif
142
+
133
143
  if (in && in->buf && ngx_buf_size(in->buf)) {
134
144
  r->request_output = 1;
135
145
  }
136
146
  }
137
147
 
138
- #if (NGX_HAVE_FILE_AIO)
148
+ #if (NGX_HAVE_FILE_AIO || NGX_THREADS)
139
149
  ctx->aio = r->aio;
140
150
  #endif
141
151
 
142
- for ( ;; ) {
143
- rc = ngx_output_chain(ctx, in);
144
-
145
- if (ctx->in == NULL) {
146
- r->buffered &= ~NGX_HTTP_COPY_BUFFERED;
147
-
148
- } else {
149
- r->buffered |= NGX_HTTP_COPY_BUFFERED;
150
- }
151
-
152
- ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
153
- "http copy filter: %i \"%V?%V\"", rc, &r->uri, &r->args);
154
-
155
- #if (NGX_HAVE_FILE_AIO && NGX_HAVE_AIO_SENDFILE)
156
-
157
- if (c->busy_sendfile) {
158
- ssize_t n;
159
- off_t offset;
160
- ngx_file_t *file;
161
- ngx_http_ephemeral_t *e;
162
-
163
- if (r->aio) {
164
- c->busy_sendfile = NULL;
165
- return rc;
166
- }
167
-
168
- file = c->busy_sendfile->file;
169
- offset = c->busy_sendfile->file_pos;
170
-
171
- if (file->aio) {
172
- c->busy_count = (offset == file->aio->last_offset) ?
173
- c->busy_count + 1 : 0;
174
- file->aio->last_offset = offset;
175
-
176
- if (c->busy_count > 2) {
177
- ngx_log_error(NGX_LOG_ALERT, c->log, 0,
178
- "sendfile(%V) returned busy again",
179
- &file->name);
180
- c->aio_sendfile = 0;
181
- }
182
- }
183
-
184
- c->busy_sendfile = NULL;
185
- e = (ngx_http_ephemeral_t *) &r->uri_start;
186
-
187
- n = ngx_file_aio_read(file, &e->aio_preload, 1, offset, r->pool);
152
+ rc = ngx_output_chain(ctx, in);
188
153
 
189
- if (n > 0) {
190
- in = NULL;
191
- continue;
192
- }
154
+ if (ctx->in == NULL) {
155
+ r->buffered &= ~NGX_HTTP_COPY_BUFFERED;
193
156
 
194
- rc = n;
157
+ } else {
158
+ r->buffered |= NGX_HTTP_COPY_BUFFERED;
159
+ }
195
160
 
196
- if (rc == NGX_AGAIN) {
197
- file->aio->data = r;
198
- file->aio->handler = ngx_http_copy_aio_sendfile_event_handler;
161
+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
162
+ "http copy filter: %i \"%V?%V\"", rc, &r->uri, &r->args);
199
163
 
200
- r->main->blocked++;
201
- r->aio = 1;
202
- }
203
- }
204
- #endif
205
-
206
- return rc;
207
- }
164
+ return rc;
208
165
  }
209
166
 
210
167
 
@@ -244,6 +201,29 @@ ngx_http_copy_aio_event_handler(ngx_event_t *ev)
244
201
 
245
202
  #if (NGX_HAVE_AIO_SENDFILE)
246
203
 
204
+ static ssize_t
205
+ ngx_http_copy_aio_sendfile_preload(ngx_buf_t *file)
206
+ {
207
+ ssize_t n;
208
+ static u_char buf[1];
209
+ ngx_event_aio_t *aio;
210
+ ngx_http_request_t *r;
211
+
212
+ n = ngx_file_aio_read(file->file, buf, 1, file->file_pos, NULL);
213
+
214
+ if (n == NGX_AGAIN) {
215
+ aio = file->file->aio;
216
+ aio->handler = ngx_http_copy_aio_sendfile_event_handler;
217
+
218
+ r = aio->data;
219
+ r->main->blocked++;
220
+ r->aio = 1;
221
+ }
222
+
223
+ return n;
224
+ }
225
+
226
+
247
227
  static void
248
228
  ngx_http_copy_aio_sendfile_event_handler(ngx_event_t *ev)
249
229
  {
@@ -264,6 +244,67 @@ ngx_http_copy_aio_sendfile_event_handler(ngx_event_t *ev)
264
244
  #endif
265
245
 
266
246
 
247
+ #if (NGX_THREADS)
248
+
249
+ static ngx_int_t
250
+ ngx_http_copy_thread_handler(ngx_thread_task_t *task, ngx_file_t *file)
251
+ {
252
+ ngx_str_t name;
253
+ ngx_thread_pool_t *tp;
254
+ ngx_http_request_t *r;
255
+ ngx_http_core_loc_conf_t *clcf;
256
+
257
+ r = file->thread_ctx;
258
+
259
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
260
+ tp = clcf->thread_pool;
261
+
262
+ if (tp == NULL) {
263
+ if (ngx_http_complex_value(r, clcf->thread_pool_value, &name)
264
+ != NGX_OK)
265
+ {
266
+ return NGX_ERROR;
267
+ }
268
+
269
+ tp = ngx_thread_pool_get((ngx_cycle_t *) ngx_cycle, &name);
270
+
271
+ if (tp == NULL) {
272
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
273
+ "thread pool \"%V\" not found", &name);
274
+ return NGX_ERROR;
275
+ }
276
+ }
277
+
278
+ task->event.data = r;
279
+ task->event.handler = ngx_http_copy_thread_event_handler;
280
+
281
+ if (ngx_thread_task_post(tp, task) != NGX_OK) {
282
+ return NGX_ERROR;
283
+ }
284
+
285
+ r->main->blocked++;
286
+ r->aio = 1;
287
+
288
+ return NGX_OK;
289
+ }
290
+
291
+
292
+ static void
293
+ ngx_http_copy_thread_event_handler(ngx_event_t *ev)
294
+ {
295
+ ngx_http_request_t *r;
296
+
297
+ r = ev->data;
298
+
299
+ r->main->blocked--;
300
+ r->aio = 0;
301
+
302
+ r->connection->write->handler(r->connection->write);
303
+ }
304
+
305
+ #endif
306
+
307
+
267
308
  static void *
268
309
  ngx_http_copy_filter_create_conf(ngx_conf_t *cf)
269
310
  {
@@ -26,6 +26,7 @@ static ngx_int_t ngx_http_core_find_static_location(ngx_http_request_t *r,
26
26
  ngx_http_location_tree_node_t *node);
27
27
 
28
28
  static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf);
29
+ static ngx_int_t ngx_http_core_postconfiguration(ngx_conf_t *cf);
29
30
  static void *ngx_http_core_create_main_conf(ngx_conf_t *cf);
30
31
  static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf);
31
32
  static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf);
@@ -54,6 +55,8 @@ static char *ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd,
54
55
  static char *ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
55
56
  static char *ngx_http_core_limit_except(ngx_conf_t *cf, ngx_command_t *cmd,
56
57
  void *conf);
58
+ static char *ngx_http_core_set_aio(ngx_conf_t *cf, ngx_command_t *cmd,
59
+ void *conf);
57
60
  static char *ngx_http_core_directio(ngx_conf_t *cf, ngx_command_t *cmd,
58
61
  void *conf);
59
62
  static char *ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd,
@@ -114,20 +117,6 @@ static ngx_conf_enum_t ngx_http_core_request_body_in_file[] = {
114
117
  };
115
118
 
116
119
 
117
- #if (NGX_HAVE_FILE_AIO)
118
-
119
- static ngx_conf_enum_t ngx_http_core_aio[] = {
120
- { ngx_string("off"), NGX_HTTP_AIO_OFF },
121
- { ngx_string("on"), NGX_HTTP_AIO_ON },
122
- #if (NGX_HAVE_AIO_SENDFILE)
123
- { ngx_string("sendfile"), NGX_HTTP_AIO_SENDFILE },
124
- #endif
125
- { ngx_null_string, 0 }
126
- };
127
-
128
- #endif
129
-
130
-
131
120
  static ngx_conf_enum_t ngx_http_core_satisfy[] = {
132
121
  { ngx_string("all"), NGX_HTTP_SATISFY_ALL },
133
122
  { ngx_string("any"), NGX_HTTP_SATISFY_ANY },
@@ -423,16 +412,12 @@ static ngx_command_t ngx_http_core_commands[] = {
423
412
  offsetof(ngx_http_core_loc_conf_t, sendfile_max_chunk),
424
413
  NULL },
425
414
 
426
- #if (NGX_HAVE_FILE_AIO)
427
-
428
415
  { ngx_string("aio"),
429
416
  NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
430
- ngx_conf_set_enum_slot,
417
+ ngx_http_core_set_aio,
431
418
  NGX_HTTP_LOC_CONF_OFFSET,
432
- offsetof(ngx_http_core_loc_conf_t, aio),
433
- &ngx_http_core_aio },
434
-
435
- #endif
419
+ 0,
420
+ NULL },
436
421
 
437
422
  { ngx_string("read_ahead"),
438
423
  NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
@@ -795,7 +780,7 @@ static ngx_command_t ngx_http_core_commands[] = {
795
780
 
796
781
  static ngx_http_module_t ngx_http_core_module_ctx = {
797
782
  ngx_http_core_preconfiguration, /* preconfiguration */
798
- NULL, /* postconfiguration */
783
+ ngx_http_core_postconfiguration, /* postconfiguration */
799
784
 
800
785
  ngx_http_core_create_main_conf, /* create main configuration */
801
786
  ngx_http_core_init_main_conf, /* init main configuration */
@@ -1245,10 +1230,8 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
1245
1230
  if (!alias) {
1246
1231
  reserve = len > r->uri.len ? len - r->uri.len : 0;
1247
1232
 
1248
- #if (NGX_PCRE)
1249
- } else if (clcf->regex) {
1233
+ } else if (alias == NGX_MAX_SIZE_T_VALUE) {
1250
1234
  reserve = len;
1251
- #endif
1252
1235
 
1253
1236
  } else {
1254
1237
  reserve = len > r->uri.len - alias ? len - (r->uri.len - alias) : 0;
@@ -1355,7 +1338,7 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
1355
1338
  continue;
1356
1339
  }
1357
1340
 
1358
- if (of.is_dir && !test_dir) {
1341
+ if (of.is_dir != test_dir) {
1359
1342
  continue;
1360
1343
  }
1361
1344
 
@@ -1365,13 +1348,12 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
1365
1348
  if (!alias) {
1366
1349
  r->uri = path;
1367
1350
 
1368
- #if (NGX_PCRE)
1369
- } else if (clcf->regex) {
1351
+ } else if (alias == NGX_MAX_SIZE_T_VALUE) {
1370
1352
  if (!test_dir) {
1371
1353
  r->uri = path;
1372
1354
  r->add_uri_to_alias = 1;
1373
1355
  }
1374
- #endif
1356
+
1375
1357
  } else {
1376
1358
  r->uri.len = alias + path.len;
1377
1359
  r->uri.data = ngx_pnalloc(r->pool, r->uri.len);
@@ -1840,6 +1822,7 @@ ngx_http_set_etag(ngx_http_request_t *r)
1840
1822
 
1841
1823
  etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3);
1842
1824
  if (etag->value.data == NULL) {
1825
+ etag->hash = 0;
1843
1826
  return NGX_ERROR;
1844
1827
  }
1845
1828
 
@@ -1854,6 +1837,46 @@ ngx_http_set_etag(ngx_http_request_t *r)
1854
1837
  }
1855
1838
 
1856
1839
 
1840
+ void
1841
+ ngx_http_weak_etag(ngx_http_request_t *r)
1842
+ {
1843
+ size_t len;
1844
+ u_char *p;
1845
+ ngx_table_elt_t *etag;
1846
+
1847
+ etag = r->headers_out.etag;
1848
+
1849
+ if (etag == NULL) {
1850
+ return;
1851
+ }
1852
+
1853
+ if (etag->value.len > 2
1854
+ && etag->value.data[0] == 'W'
1855
+ && etag->value.data[1] == '/')
1856
+ {
1857
+ return;
1858
+ }
1859
+
1860
+ if (etag->value.len < 1 || etag->value.data[0] != '"') {
1861
+ r->headers_out.etag->hash = 0;
1862
+ r->headers_out.etag = NULL;
1863
+ return;
1864
+ }
1865
+
1866
+ p = ngx_pnalloc(r->pool, etag->value.len + 2);
1867
+ if (p == NULL) {
1868
+ r->headers_out.etag->hash = 0;
1869
+ r->headers_out.etag = NULL;
1870
+ return;
1871
+ }
1872
+
1873
+ len = ngx_sprintf(p, "W/%V", &etag->value) - p;
1874
+
1875
+ etag->value.data = p;
1876
+ etag->value.len = len;
1877
+ }
1878
+
1879
+
1857
1880
  ngx_int_t
1858
1881
  ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
1859
1882
  ngx_str_t *ct, ngx_http_complex_value_t *cv)
@@ -2010,16 +2033,12 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
2010
2033
 
2011
2034
  } else {
2012
2035
 
2013
- #if (NGX_PCRE)
2014
- ngx_uint_t captures;
2015
-
2016
- captures = alias && clcf->regex;
2036
+ if (alias == NGX_MAX_SIZE_T_VALUE) {
2037
+ reserved += r->add_uri_to_alias ? r->uri.len + 1 : 1;
2017
2038
 
2018
- reserved += captures ? r->add_uri_to_alias ? r->uri.len + 1 : 1
2019
- : r->uri.len - alias + 1;
2020
- #else
2021
- reserved += r->uri.len - alias + 1;
2022
- #endif
2039
+ } else {
2040
+ reserved += r->uri.len - alias + 1;
2041
+ }
2023
2042
 
2024
2043
  if (ngx_http_script_run(r, path, clcf->root_lengths->elts, reserved,
2025
2044
  clcf->root_values->elts)
@@ -2037,8 +2056,7 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
2037
2056
  *root_length = path->len - reserved;
2038
2057
  last = path->data + *root_length;
2039
2058
 
2040
- #if (NGX_PCRE)
2041
- if (captures) {
2059
+ if (alias == NGX_MAX_SIZE_T_VALUE) {
2042
2060
  if (!r->add_uri_to_alias) {
2043
2061
  *last = '\0';
2044
2062
  return last;
@@ -2046,7 +2064,6 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
2046
2064
 
2047
2065
  alias = 0;
2048
2066
  }
2049
- #endif
2050
2067
  }
2051
2068
 
2052
2069
  last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1);
@@ -2328,7 +2345,7 @@ ngx_http_gzip_accept_encoding(ngx_str_t *ae)
2328
2345
  p += 4;
2329
2346
 
2330
2347
  while (p < last) {
2331
- switch(*p++) {
2348
+ switch (*p++) {
2332
2349
  case ',':
2333
2350
  return NGX_OK;
2334
2351
  case ';':
@@ -2345,7 +2362,7 @@ ngx_http_gzip_accept_encoding(ngx_str_t *ae)
2345
2362
  quantity:
2346
2363
 
2347
2364
  while (p < last) {
2348
- switch(*p++) {
2365
+ switch (*p++) {
2349
2366
  case 'q':
2350
2367
  case 'Q':
2351
2368
  goto equal;
@@ -3404,6 +3421,15 @@ ngx_http_core_preconfiguration(ngx_conf_t *cf)
3404
3421
  }
3405
3422
 
3406
3423
 
3424
+ static ngx_int_t
3425
+ ngx_http_core_postconfiguration(ngx_conf_t *cf)
3426
+ {
3427
+ ngx_http_top_request_body_filter = ngx_http_request_body_save_filter;
3428
+
3429
+ return NGX_OK;
3430
+ }
3431
+
3432
+
3407
3433
  static void *
3408
3434
  ngx_http_core_create_main_conf(ngx_conf_t *cf)
3409
3435
  {
@@ -3607,8 +3633,10 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
3607
3633
  clcf->internal = NGX_CONF_UNSET;
3608
3634
  clcf->sendfile = NGX_CONF_UNSET;
3609
3635
  clcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE;
3610
- #if (NGX_HAVE_FILE_AIO)
3611
3636
  clcf->aio = NGX_CONF_UNSET;
3637
+ #if (NGX_THREADS)
3638
+ clcf->thread_pool = NGX_CONF_UNSET_PTR;
3639
+ clcf->thread_pool_value = NGX_CONF_UNSET_PTR;
3612
3640
  #endif
3613
3641
  clcf->read_ahead = NGX_CONF_UNSET_SIZE;
3614
3642
  clcf->directio = NGX_CONF_UNSET;
@@ -3825,8 +3853,13 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
3825
3853
  ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
3826
3854
  ngx_conf_merge_size_value(conf->sendfile_max_chunk,
3827
3855
  prev->sendfile_max_chunk, 0);
3828
- #if (NGX_HAVE_FILE_AIO)
3856
+ #if (NGX_HAVE_FILE_AIO || NGX_THREADS)
3829
3857
  ngx_conf_merge_value(conf->aio, prev->aio, NGX_HTTP_AIO_OFF);
3858
+ #endif
3859
+ #if (NGX_THREADS)
3860
+ ngx_conf_merge_ptr_value(conf->thread_pool, prev->thread_pool, NULL);
3861
+ ngx_conf_merge_ptr_value(conf->thread_pool_value, prev->thread_pool_value,
3862
+ NULL);
3830
3863
  #endif
3831
3864
  ngx_conf_merge_size_value(conf->read_ahead, prev->read_ahead, 0);
3832
3865
  ngx_conf_merge_off_value(conf->directio, prev->directio,
@@ -4480,6 +4513,7 @@ ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
4480
4513
 
4481
4514
  #if (NGX_PCRE)
4482
4515
  if (alias && clcf->regex) {
4516
+ clcf->alias = NGX_MAX_SIZE_T_VALUE;
4483
4517
  n = 1;
4484
4518
  }
4485
4519
  #endif
@@ -4620,6 +4654,116 @@ ngx_http_core_limit_except(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
4620
4654
  }
4621
4655
 
4622
4656
 
4657
+ static char *
4658
+ ngx_http_core_set_aio(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
4659
+ {
4660
+ ngx_http_core_loc_conf_t *clcf = conf;
4661
+
4662
+ ngx_str_t *value;
4663
+
4664
+ if (clcf->aio != NGX_CONF_UNSET) {
4665
+ return "is duplicate";
4666
+ }
4667
+
4668
+ #if (NGX_THREADS)
4669
+ clcf->thread_pool = NULL;
4670
+ clcf->thread_pool_value = NULL;
4671
+ #endif
4672
+
4673
+ value = cf->args->elts;
4674
+
4675
+ if (ngx_strcmp(value[1].data, "off") == 0) {
4676
+ clcf->aio = NGX_HTTP_AIO_OFF;
4677
+ return NGX_CONF_OK;
4678
+ }
4679
+
4680
+ if (ngx_strcmp(value[1].data, "on") == 0) {
4681
+ #if (NGX_HAVE_FILE_AIO)
4682
+ clcf->aio = NGX_HTTP_AIO_ON;
4683
+ return NGX_CONF_OK;
4684
+ #else
4685
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
4686
+ "\"aio on\" "
4687
+ "is unsupported on this platform");
4688
+ return NGX_CONF_ERROR;
4689
+ #endif
4690
+ }
4691
+
4692
+ #if (NGX_HAVE_AIO_SENDFILE)
4693
+
4694
+ if (ngx_strcmp(value[1].data, "sendfile") == 0) {
4695
+ clcf->aio = NGX_HTTP_AIO_ON;
4696
+
4697
+ ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
4698
+ "the \"sendfile\" parameter of "
4699
+ "the \"aio\" directive is deprecated");
4700
+ return NGX_CONF_OK;
4701
+ }
4702
+
4703
+ #endif
4704
+
4705
+ if (ngx_strncmp(value[1].data, "threads", 7) == 0
4706
+ && (value[1].len == 7 || value[1].data[7] == '='))
4707
+ {
4708
+ #if (NGX_THREADS)
4709
+ ngx_str_t name;
4710
+ ngx_thread_pool_t *tp;
4711
+ ngx_http_complex_value_t cv;
4712
+ ngx_http_compile_complex_value_t ccv;
4713
+
4714
+ clcf->aio = NGX_HTTP_AIO_THREADS;
4715
+
4716
+ if (value[1].len >= 8) {
4717
+ name.len = value[1].len - 8;
4718
+ name.data = value[1].data + 8;
4719
+
4720
+ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
4721
+
4722
+ ccv.cf = cf;
4723
+ ccv.value = &name;
4724
+ ccv.complex_value = &cv;
4725
+
4726
+ if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
4727
+ return NGX_CONF_ERROR;
4728
+ }
4729
+
4730
+ if (cv.lengths != NULL) {
4731
+ clcf->thread_pool_value = ngx_palloc(cf->pool,
4732
+ sizeof(ngx_http_complex_value_t));
4733
+ if (clcf->thread_pool_value == NULL) {
4734
+ return NGX_CONF_ERROR;
4735
+ }
4736
+
4737
+ *clcf->thread_pool_value = cv;
4738
+
4739
+ return NGX_CONF_OK;
4740
+ }
4741
+
4742
+ tp = ngx_thread_pool_add(cf, &name);
4743
+
4744
+ } else {
4745
+ tp = ngx_thread_pool_add(cf, NULL);
4746
+ }
4747
+
4748
+ if (tp == NULL) {
4749
+ return NGX_CONF_ERROR;
4750
+ }
4751
+
4752
+ clcf->thread_pool = tp;
4753
+
4754
+ return NGX_CONF_OK;
4755
+ #else
4756
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
4757
+ "\"aio threads\" "
4758
+ "is unsupported on this platform");
4759
+ return NGX_CONF_ERROR;
4760
+ #endif
4761
+ }
4762
+
4763
+ return "invalid value";
4764
+ }
4765
+
4766
+
4623
4767
  static char *
4624
4768
  ngx_http_core_directio(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
4625
4769
  {
@@ -4801,7 +4945,8 @@ ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
4801
4945
  tf[i].name = value[i + 1];
4802
4946
 
4803
4947
  if (tf[i].name.len > 0
4804
- && tf[i].name.data[tf[i].name.len - 1] == '/')
4948
+ && tf[i].name.data[tf[i].name.len - 1] == '/'
4949
+ && i + 2 < cf->args->nelts)
4805
4950
  {
4806
4951
  tf[i].test_dir = 1;
4807
4952
  tf[i].name.len--;