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
@@ -66,7 +66,9 @@ typedef struct {
66
66
  ngx_http_log_script_t *script;
67
67
  time_t disk_full_time;
68
68
  time_t error_log_time;
69
+ ngx_syslog_peer_t *syslog_peer;
69
70
  ngx_http_log_fmt_t *format;
71
+ ngx_http_complex_value_t *filter;
70
72
  } ngx_http_log_t;
71
73
 
72
74
 
@@ -150,7 +152,7 @@ static ngx_int_t ngx_http_log_init(ngx_conf_t *cf);
150
152
  static ngx_command_t ngx_http_log_commands[] = {
151
153
 
152
154
  { ngx_string("log_format"),
153
- NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE,
155
+ NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE,
154
156
  ngx_http_log_set_format,
155
157
  NGX_HTTP_MAIN_CONF_OFFSET,
156
158
  0,
@@ -239,7 +241,9 @@ static ngx_int_t
239
241
  ngx_http_log_handler(ngx_http_request_t *r)
240
242
  {
241
243
  u_char *line, *p;
242
- size_t len;
244
+ size_t len, size;
245
+ ssize_t n;
246
+ ngx_str_t val;
243
247
  ngx_uint_t i, l;
244
248
  ngx_http_log_t *log;
245
249
  ngx_http_log_op_t *op;
@@ -258,6 +262,16 @@ ngx_http_log_handler(ngx_http_request_t *r)
258
262
  log = lcf->logs->elts;
259
263
  for (l = 0; l < lcf->logs->nelts; l++) {
260
264
 
265
+ if (log[l].filter) {
266
+ if (ngx_http_complex_value(r, log[l].filter, &val) != NGX_OK) {
267
+ return NGX_ERROR;
268
+ }
269
+
270
+ if (val.len == 0 || (val.len == 1 && val.data[0] == '0')) {
271
+ continue;
272
+ }
273
+ }
274
+
261
275
  if (ngx_time() == log[l].disk_full_time) {
262
276
 
263
277
  /*
@@ -282,6 +296,16 @@ ngx_http_log_handler(ngx_http_request_t *r)
282
296
  }
283
297
  }
284
298
 
299
+ if (log[l].syslog_peer) {
300
+
301
+ /* length of syslog's PRI and HEADER message parts */
302
+ len += sizeof("<255>Jan 01 00:00:00 ") - 1
303
+ + ngx_cycle->hostname.len + 1
304
+ + log[l].syslog_peer->tag.len + 2;
305
+
306
+ goto alloc_line;
307
+ }
308
+
285
309
  len += NGX_LINEFEED_SIZE;
286
310
 
287
311
  buffer = log[l].file ? log[l].file->data : NULL;
@@ -320,6 +344,8 @@ ngx_http_log_handler(ngx_http_request_t *r)
320
344
  }
321
345
  }
322
346
 
347
+ alloc_line:
348
+
323
349
  line = ngx_pnalloc(r->pool, len);
324
350
  if (line == NULL) {
325
351
  return NGX_ERROR;
@@ -327,10 +353,33 @@ ngx_http_log_handler(ngx_http_request_t *r)
327
353
 
328
354
  p = line;
329
355
 
356
+ if (log[l].syslog_peer) {
357
+ p = ngx_syslog_add_header(log[l].syslog_peer, line);
358
+ }
359
+
330
360
  for (i = 0; i < log[l].format->ops->nelts; i++) {
331
361
  p = op[i].run(r, p, &op[i]);
332
362
  }
333
363
 
364
+ if (log[l].syslog_peer) {
365
+
366
+ size = p - line;
367
+
368
+ n = ngx_syslog_send(log[l].syslog_peer, line, size);
369
+
370
+ if (n < 0) {
371
+ ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
372
+ "send() to syslog failed");
373
+
374
+ } else if ((size_t) n != size) {
375
+ ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
376
+ "send() to syslog has written only %z of %uz",
377
+ n, size);
378
+ }
379
+
380
+ continue;
381
+ }
382
+
334
383
  ngx_linefeed(p);
335
384
 
336
385
  ngx_http_log_write(r, &log[l], line, p - line);
@@ -695,10 +744,23 @@ ngx_http_log_flush(ngx_open_file_t *file, ngx_log_t *log)
695
744
  static void
696
745
  ngx_http_log_flush_handler(ngx_event_t *ev)
697
746
  {
747
+ ngx_open_file_t *file;
748
+ ngx_http_log_buf_t *buffer;
749
+
698
750
  ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0,
699
751
  "http log buffer flush handler");
700
752
 
701
- ngx_http_log_flush(ev->data, ev->log);
753
+ if (ev->timedout) {
754
+ ngx_http_log_flush(ev->data, ev->log);
755
+ return;
756
+ }
757
+
758
+ /* cancel the flush timer for graceful shutdown */
759
+
760
+ file = ev->data;
761
+ buffer = file->data;
762
+
763
+ buffer->event = NULL;
702
764
  }
703
765
 
704
766
 
@@ -1060,15 +1122,13 @@ ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
1060
1122
  return NGX_CONF_ERROR;
1061
1123
  }
1062
1124
 
1125
+ ngx_memzero(log, sizeof(ngx_http_log_t));
1126
+
1063
1127
  log->file = ngx_conf_open_file(cf->cycle, &ngx_http_access_log);
1064
1128
  if (log->file == NULL) {
1065
1129
  return NGX_CONF_ERROR;
1066
1130
  }
1067
1131
 
1068
- log->script = NULL;
1069
- log->disk_full_time = 0;
1070
- log->error_log_time = 0;
1071
-
1072
1132
  lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
1073
1133
  fmt = lmcf->formats.elts;
1074
1134
 
@@ -1085,16 +1145,18 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1085
1145
  {
1086
1146
  ngx_http_log_loc_conf_t *llcf = conf;
1087
1147
 
1088
- ssize_t size;
1089
- ngx_int_t gzip;
1090
- ngx_uint_t i, n;
1091
- ngx_msec_t flush;
1092
- ngx_str_t *value, name, s;
1093
- ngx_http_log_t *log;
1094
- ngx_http_log_buf_t *buffer;
1095
- ngx_http_log_fmt_t *fmt;
1096
- ngx_http_log_main_conf_t *lmcf;
1097
- ngx_http_script_compile_t sc;
1148
+ ssize_t size;
1149
+ ngx_int_t gzip;
1150
+ ngx_uint_t i, n;
1151
+ ngx_msec_t flush;
1152
+ ngx_str_t *value, name, s;
1153
+ ngx_http_log_t *log;
1154
+ ngx_syslog_peer_t *peer;
1155
+ ngx_http_log_buf_t *buffer;
1156
+ ngx_http_log_fmt_t *fmt;
1157
+ ngx_http_log_main_conf_t *lmcf;
1158
+ ngx_http_script_compile_t sc;
1159
+ ngx_http_compile_complex_value_t ccv;
1098
1160
 
1099
1161
  value = cf->args->elts;
1100
1162
 
@@ -1125,6 +1187,23 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1125
1187
 
1126
1188
  ngx_memzero(log, sizeof(ngx_http_log_t));
1127
1189
 
1190
+
1191
+ if (ngx_strncmp(value[1].data, "syslog:", 7) == 0) {
1192
+
1193
+ peer = ngx_pcalloc(cf->pool, sizeof(ngx_syslog_peer_t));
1194
+ if (peer == NULL) {
1195
+ return NGX_CONF_ERROR;
1196
+ }
1197
+
1198
+ if (ngx_syslog_process_conf(cf, peer) != NGX_CONF_OK) {
1199
+ return NGX_CONF_ERROR;
1200
+ }
1201
+
1202
+ log->syslog_peer = peer;
1203
+
1204
+ goto process_formats;
1205
+ }
1206
+
1128
1207
  n = ngx_http_script_variables_count(&value[1]);
1129
1208
 
1130
1209
  if (n == 0) {
@@ -1158,6 +1237,8 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1158
1237
  }
1159
1238
  }
1160
1239
 
1240
+ process_formats:
1241
+
1161
1242
  if (cf->args->nelts >= 3) {
1162
1243
  name = value[2];
1163
1244
 
@@ -1255,6 +1336,29 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1255
1336
  #endif
1256
1337
  }
1257
1338
 
1339
+ if (ngx_strncmp(value[i].data, "if=", 3) == 0) {
1340
+ s.len = value[i].len - 3;
1341
+ s.data = value[i].data + 3;
1342
+
1343
+ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
1344
+
1345
+ ccv.cf = cf;
1346
+ ccv.value = &s;
1347
+ ccv.complex_value = ngx_palloc(cf->pool,
1348
+ sizeof(ngx_http_complex_value_t));
1349
+ if (ccv.complex_value == NULL) {
1350
+ return NGX_CONF_ERROR;
1351
+ }
1352
+
1353
+ if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
1354
+ return NGX_CONF_ERROR;
1355
+ }
1356
+
1357
+ log->filter = ccv.complex_value;
1358
+
1359
+ continue;
1360
+ }
1361
+
1258
1362
  ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1259
1363
  "invalid parameter \"%V\"", &value[i]);
1260
1364
  return NGX_CONF_ERROR;
@@ -1275,6 +1379,12 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1275
1379
  return NGX_CONF_ERROR;
1276
1380
  }
1277
1381
 
1382
+ if (log->syslog_peer) {
1383
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1384
+ "logs to syslog cannot be buffered");
1385
+ return NGX_CONF_ERROR;
1386
+ }
1387
+
1278
1388
  if (log->file->data) {
1279
1389
  buffer = log->file->data;
1280
1390
 
@@ -1314,6 +1424,7 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1314
1424
  buffer->event->data = log->file;
1315
1425
  buffer->event->handler = ngx_http_log_flush_handler;
1316
1426
  buffer->event->log = &cf->cycle->new_log;
1427
+ buffer->event->cancelable = 1;
1317
1428
 
1318
1429
  buffer->flush = flush;
1319
1430
  }
@@ -1337,12 +1448,6 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1337
1448
  ngx_uint_t i;
1338
1449
  ngx_http_log_fmt_t *fmt;
1339
1450
 
1340
- if (cf->cmd_type != NGX_HTTP_MAIN_CONF) {
1341
- ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
1342
- "the \"log_format\" directive may be used "
1343
- "only on \"http\" level");
1344
- }
1345
-
1346
1451
  value = cf->args->elts;
1347
1452
 
1348
1453
  fmt = lmcf->formats.elts;
@@ -102,6 +102,20 @@ static ngx_command_t ngx_http_memcached_commands[] = {
102
102
  offsetof(ngx_http_memcached_loc_conf_t, upstream.next_upstream),
103
103
  &ngx_http_memcached_next_upstream_masks },
104
104
 
105
+ { ngx_string("memcached_next_upstream_tries"),
106
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
107
+ ngx_conf_set_num_slot,
108
+ NGX_HTTP_LOC_CONF_OFFSET,
109
+ offsetof(ngx_http_memcached_loc_conf_t, upstream.next_upstream_tries),
110
+ NULL },
111
+
112
+ { ngx_string("memcached_next_upstream_timeout"),
113
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
114
+ ngx_conf_set_msec_slot,
115
+ NGX_HTTP_LOC_CONF_OFFSET,
116
+ offsetof(ngx_http_memcached_loc_conf_t, upstream.next_upstream_timeout),
117
+ NULL },
118
+
105
119
  { ngx_string("memcached_gzip_flag"),
106
120
  NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
107
121
  ngx_conf_set_num_slot,
@@ -380,11 +394,8 @@ found:
380
394
  }
381
395
 
382
396
  h->hash = 1;
383
- h->key.len = sizeof("Content-Encoding") - 1;
384
- h->key.data = (u_char *) "Content-Encoding";
385
- h->value.len = sizeof("gzip") - 1;
386
- h->value.data = (u_char *) "gzip";
387
-
397
+ ngx_str_set(&h->key, "Content-Encoding");
398
+ ngx_str_set(&h->value, "gzip");
388
399
  r->headers_out.content_encoding = h;
389
400
  }
390
401
 
@@ -394,7 +405,7 @@ found:
394
405
  p = line.data + line.len;
395
406
 
396
407
  u->headers_in.content_length_n = ngx_atoof(start, p - start);
397
- if (u->headers_in.content_length_n == -1) {
408
+ if (u->headers_in.content_length_n == NGX_ERROR) {
398
409
  ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
399
410
  "memcached sent invalid length in response \"%V\" "
400
411
  "for key \"%V\"",
@@ -586,9 +597,11 @@ ngx_http_memcached_create_loc_conf(ngx_conf_t *cf)
586
597
  */
587
598
 
588
599
  conf->upstream.local = NGX_CONF_UNSET_PTR;
600
+ conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;
589
601
  conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC;
590
602
  conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC;
591
603
  conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC;
604
+ conf->upstream.next_upstream_timeout = NGX_CONF_UNSET_MSEC;
592
605
 
593
606
  conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE;
594
607
 
@@ -622,6 +635,9 @@ ngx_http_memcached_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
622
635
  ngx_conf_merge_ptr_value(conf->upstream.local,
623
636
  prev->upstream.local, NULL);
624
637
 
638
+ ngx_conf_merge_uint_value(conf->upstream.next_upstream_tries,
639
+ prev->upstream.next_upstream_tries, 0);
640
+
625
641
  ngx_conf_merge_msec_value(conf->upstream.connect_timeout,
626
642
  prev->upstream.connect_timeout, 60000);
627
643
 
@@ -631,6 +647,9 @@ ngx_http_memcached_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
631
647
  ngx_conf_merge_msec_value(conf->upstream.read_timeout,
632
648
  prev->upstream.read_timeout, 60000);
633
649
 
650
+ ngx_conf_merge_msec_value(conf->upstream.next_upstream_timeout,
651
+ prev->upstream.next_upstream_timeout, 0);
652
+
634
653
  ngx_conf_merge_size_value(conf->upstream.buffer_size,
635
654
  prev->upstream.buffer_size,
636
655
  (size_t) ngx_pagesize);
@@ -1840,7 +1840,7 @@ ngx_http_mp4_read_smhd_atom(ngx_http_mp4_file_t *mp4, uint64_t atom_data_size)
1840
1840
  atom->pos = atom_header;
1841
1841
  atom->last = atom_header + atom_size;
1842
1842
 
1843
- trak->vmhd_size += atom_size;
1843
+ trak->smhd_size += atom_size;
1844
1844
  trak->out[NGX_HTTP_MP4_SMHD_ATOM].buf = atom;
1845
1845
 
1846
1846
  ngx_mp4_atom_next(mp4, atom_data_size);
@@ -13,7 +13,7 @@
13
13
  static ngx_uint_t ngx_http_test_if_unmodified(ngx_http_request_t *r);
14
14
  static ngx_uint_t ngx_http_test_if_modified(ngx_http_request_t *r);
15
15
  static ngx_uint_t ngx_http_test_if_match(ngx_http_request_t *r,
16
- ngx_table_elt_t *header);
16
+ ngx_table_elt_t *header, ngx_uint_t weak);
17
17
  static ngx_int_t ngx_http_not_modified_filter_init(ngx_conf_t *cf);
18
18
 
19
19
 
@@ -56,7 +56,7 @@ ngx_http_not_modified_header_filter(ngx_http_request_t *r)
56
56
  {
57
57
  if (r->headers_out.status != NGX_HTTP_OK
58
58
  || r != r->main
59
- || r->headers_out.last_modified_time == -1)
59
+ || r->disable_not_modified)
60
60
  {
61
61
  return ngx_http_next_header_filter(r);
62
62
  }
@@ -69,7 +69,7 @@ ngx_http_not_modified_header_filter(ngx_http_request_t *r)
69
69
  }
70
70
 
71
71
  if (r->headers_in.if_match
72
- && !ngx_http_test_if_match(r, r->headers_in.if_match))
72
+ && !ngx_http_test_if_match(r, r->headers_in.if_match, 0))
73
73
  {
74
74
  return ngx_http_filter_finalize_request(r, NULL,
75
75
  NGX_HTTP_PRECONDITION_FAILED);
@@ -84,7 +84,7 @@ ngx_http_not_modified_header_filter(ngx_http_request_t *r)
84
84
  }
85
85
 
86
86
  if (r->headers_in.if_none_match
87
- && !ngx_http_test_if_match(r, r->headers_in.if_none_match))
87
+ && !ngx_http_test_if_match(r, r->headers_in.if_none_match, 1))
88
88
  {
89
89
  return ngx_http_next_header_filter(r);
90
90
  }
@@ -114,11 +114,15 @@ ngx_http_test_if_unmodified(ngx_http_request_t *r)
114
114
  {
115
115
  time_t iums;
116
116
 
117
+ if (r->headers_out.last_modified_time == (time_t) -1) {
118
+ return 0;
119
+ }
120
+
117
121
  iums = ngx_http_parse_time(r->headers_in.if_unmodified_since->value.data,
118
122
  r->headers_in.if_unmodified_since->value.len);
119
123
 
120
124
  ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
121
- "http iums:%d lm:%d", iums, r->headers_out.last_modified_time);
125
+ "http iums:%T lm:%T", iums, r->headers_out.last_modified_time);
122
126
 
123
127
  if (iums >= r->headers_out.last_modified_time) {
124
128
  return 1;
@@ -134,6 +138,10 @@ ngx_http_test_if_modified(ngx_http_request_t *r)
134
138
  time_t ims;
135
139
  ngx_http_core_loc_conf_t *clcf;
136
140
 
141
+ if (r->headers_out.last_modified_time == (time_t) -1) {
142
+ return 1;
143
+ }
144
+
137
145
  clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
138
146
 
139
147
  if (clcf->if_modified_since == NGX_HTTP_IMS_OFF) {
@@ -144,7 +152,7 @@ ngx_http_test_if_modified(ngx_http_request_t *r)
144
152
  r->headers_in.if_modified_since->value.len);
145
153
 
146
154
  ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
147
- "http ims:%d lm:%d", ims, r->headers_out.last_modified_time);
155
+ "http ims:%T lm:%T", ims, r->headers_out.last_modified_time);
148
156
 
149
157
  if (ims == r->headers_out.last_modified_time) {
150
158
  return 0;
@@ -161,10 +169,11 @@ ngx_http_test_if_modified(ngx_http_request_t *r)
161
169
 
162
170
 
163
171
  static ngx_uint_t
164
- ngx_http_test_if_match(ngx_http_request_t *r, ngx_table_elt_t *header)
172
+ ngx_http_test_if_match(ngx_http_request_t *r, ngx_table_elt_t *header,
173
+ ngx_uint_t weak)
165
174
  {
166
175
  u_char *start, *end, ch;
167
- ngx_str_t *etag, *list;
176
+ ngx_str_t etag, *list;
168
177
 
169
178
  list = &header->value;
170
179
 
@@ -176,25 +185,42 @@ ngx_http_test_if_match(ngx_http_request_t *r, ngx_table_elt_t *header)
176
185
  return 0;
177
186
  }
178
187
 
179
- etag = &r->headers_out.etag->value;
188
+ etag = r->headers_out.etag->value;
180
189
 
181
190
  ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
182
- "http im:\"%V\" etag:%V", list, etag);
191
+ "http im:\"%V\" etag:%V", list, &etag);
192
+
193
+ if (weak
194
+ && etag.len > 2
195
+ && etag.data[0] == 'W'
196
+ && etag.data[1] == '/')
197
+ {
198
+ etag.len -= 2;
199
+ etag.data += 2;
200
+ }
183
201
 
184
202
  start = list->data;
185
203
  end = list->data + list->len;
186
204
 
187
205
  while (start < end) {
188
206
 
189
- if (etag->len > (size_t) (end - start)) {
207
+ if (weak
208
+ && end - start > 2
209
+ && start[0] == 'W'
210
+ && start[1] == '/')
211
+ {
212
+ start += 2;
213
+ }
214
+
215
+ if (etag.len > (size_t) (end - start)) {
190
216
  return 0;
191
217
  }
192
218
 
193
- if (ngx_strncmp(start, etag->data, etag->len) != 0) {
219
+ if (ngx_strncmp(start, etag.data, etag.len) != 0) {
194
220
  goto skip;
195
221
  }
196
222
 
197
- start += etag->len;
223
+ start += etag.len;
198
224
 
199
225
  while (start < end) {
200
226
  ch = *start;