nginxtra 1.4.7.9 → 1.6.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) 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 +286 -19
  6. data/vendor/nginx/CHANGES.ru +296 -22
  7. data/vendor/nginx/auto/cc/clang +4 -3
  8. data/vendor/nginx/auto/cc/conf +23 -0
  9. data/vendor/nginx/auto/cc/msvc +1 -0
  10. data/vendor/nginx/auto/cc/name +1 -1
  11. data/vendor/nginx/auto/cc/owc +4 -4
  12. data/vendor/nginx/auto/cc/sunc +1 -1
  13. data/vendor/nginx/auto/endianness +2 -2
  14. data/vendor/nginx/auto/feature +1 -1
  15. data/vendor/nginx/auto/include +1 -1
  16. data/vendor/nginx/auto/lib/libatomic/make +3 -1
  17. data/vendor/nginx/auto/lib/openssl/conf +4 -0
  18. data/vendor/nginx/auto/lib/openssl/make +1 -1
  19. data/vendor/nginx/auto/lib/pcre/conf +5 -0
  20. data/vendor/nginx/auto/lib/pcre/make +11 -11
  21. data/vendor/nginx/auto/lib/pcre/makefile.bcc +4 -3
  22. data/vendor/nginx/auto/lib/pcre/makefile.msvc +2 -1
  23. data/vendor/nginx/auto/lib/pcre/makefile.owc +2 -1
  24. data/vendor/nginx/auto/lib/perl/make +1 -0
  25. data/vendor/nginx/auto/lib/test +1 -1
  26. data/vendor/nginx/auto/lib/zlib/make +22 -1
  27. data/vendor/nginx/auto/modules +8 -0
  28. data/vendor/nginx/auto/options +3 -0
  29. data/vendor/nginx/auto/os/darwin +1 -1
  30. data/vendor/nginx/auto/os/linux +32 -0
  31. data/vendor/nginx/auto/os/win32 +12 -1
  32. data/vendor/nginx/auto/sources +8 -2
  33. data/vendor/nginx/auto/types/sizeof +1 -1
  34. data/vendor/nginx/auto/types/typedef +1 -1
  35. data/vendor/nginx/auto/types/uintptr_t +1 -1
  36. data/vendor/nginx/auto/unix +13 -1
  37. data/vendor/nginx/conf/mime.types +11 -2
  38. data/vendor/nginx/conf/nginx.conf +3 -4
  39. data/vendor/nginx/contrib/README +6 -0
  40. data/vendor/nginx/contrib/vim/ftdetect/nginx.vim +4 -0
  41. data/vendor/nginx/contrib/vim/indent/nginx.vim +11 -0
  42. data/vendor/nginx/contrib/vim/syntax/nginx.vim +703 -0
  43. data/vendor/nginx/src/core/nginx.c +2 -7
  44. data/vendor/nginx/src/core/nginx.h +2 -2
  45. data/vendor/nginx/src/core/ngx_conf_file.c +8 -88
  46. data/vendor/nginx/src/core/ngx_conf_file.h +3 -3
  47. data/vendor/nginx/src/core/ngx_config.h +2 -2
  48. data/vendor/nginx/src/core/ngx_connection.c +100 -29
  49. data/vendor/nginx/src/core/ngx_connection.h +11 -0
  50. data/vendor/nginx/src/core/ngx_core.h +1 -0
  51. data/vendor/nginx/src/core/ngx_cycle.c +23 -99
  52. data/vendor/nginx/src/core/ngx_cycle.h +2 -0
  53. data/vendor/nginx/src/core/ngx_file.c +100 -8
  54. data/vendor/nginx/src/core/ngx_file.h +3 -0
  55. data/vendor/nginx/src/core/ngx_hash.c +6 -9
  56. data/vendor/nginx/src/core/ngx_inet.c +93 -5
  57. data/vendor/nginx/src/core/ngx_inet.h +4 -2
  58. data/vendor/nginx/src/core/ngx_list.c +1 -9
  59. data/vendor/nginx/src/core/ngx_log.c +132 -30
  60. data/vendor/nginx/src/core/ngx_log.h +5 -2
  61. data/vendor/nginx/src/core/ngx_open_file_cache.c +67 -1
  62. data/vendor/nginx/src/core/ngx_palloc.c +5 -2
  63. data/vendor/nginx/src/core/ngx_proxy_protocol.c +91 -0
  64. data/vendor/nginx/src/core/ngx_proxy_protocol.h +23 -0
  65. data/vendor/nginx/src/core/ngx_resolver.c +1080 -285
  66. data/vendor/nginx/src/core/ngx_resolver.h +33 -3
  67. data/vendor/nginx/src/core/ngx_slab.c +7 -2
  68. data/vendor/nginx/src/core/ngx_slab.h +2 -0
  69. data/vendor/nginx/src/core/ngx_string.c +78 -13
  70. data/vendor/nginx/src/core/ngx_string.h +2 -0
  71. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +2 -2
  72. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +13 -5
  73. data/vendor/nginx/src/event/modules/ngx_select_module.c +1 -1
  74. data/vendor/nginx/src/event/modules/ngx_win32_select_module.c +2 -2
  75. data/vendor/nginx/src/event/ngx_event.c +0 -1
  76. data/vendor/nginx/src/event/ngx_event.h +7 -6
  77. data/vendor/nginx/src/event/ngx_event_accept.c +6 -4
  78. data/vendor/nginx/src/event/ngx_event_connect.c +2 -2
  79. data/vendor/nginx/src/event/ngx_event_openssl.c +304 -13
  80. data/vendor/nginx/src/event/ngx_event_openssl.h +20 -1
  81. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +35 -23
  82. data/vendor/nginx/src/event/ngx_event_pipe.c +15 -30
  83. data/vendor/nginx/src/http/modules/ngx_http_access_module.c +115 -35
  84. data/vendor/nginx/src/http/modules/ngx_http_auth_basic_module.c +1 -1
  85. data/vendor/nginx/src/http/modules/ngx_http_auth_request_module.c +444 -0
  86. data/vendor/nginx/src/http/modules/ngx_http_autoindex_module.c +2 -1
  87. data/vendor/nginx/src/http/modules/ngx_http_charset_filter_module.c +1 -1
  88. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +1 -3
  89. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +251 -36
  90. data/vendor/nginx/src/http/modules/ngx_http_gunzip_filter_module.c +9 -5
  91. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +5 -3
  92. data/vendor/nginx/src/http/modules/ngx_http_gzip_static_module.c +1 -1
  93. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +4 -0
  94. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +8 -2
  95. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +5 -1
  96. data/vendor/nginx/src/http/modules/ngx_http_map_module.c +3 -3
  97. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +21 -10
  98. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +669 -197
  99. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +93 -60
  100. data/vendor/nginx/src/http/modules/ngx_http_range_filter_module.c +13 -6
  101. data/vendor/nginx/src/http/modules/ngx_http_realip_module.c +20 -1
  102. data/vendor/nginx/src/http/modules/ngx_http_referer_module.c +132 -74
  103. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +18 -12
  104. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +22 -20
  105. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +121 -3
  106. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.h +5 -0
  107. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +3 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +123 -91
  109. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +29 -19
  110. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +2 -5
  111. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +215 -19
  112. data/vendor/nginx/src/http/modules/ngx_http_xslt_filter_module.c +32 -6
  113. data/vendor/nginx/src/http/modules/perl/nginx.xs +4 -7
  114. data/vendor/nginx/src/http/modules/perl/ngx_http_perl_module.c +2 -2
  115. data/vendor/nginx/src/http/ngx_http.c +17 -7
  116. data/vendor/nginx/src/http/ngx_http_cache.h +4 -2
  117. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +4 -2
  118. data/vendor/nginx/src/http/ngx_http_core_module.c +63 -50
  119. data/vendor/nginx/src/http/ngx_http_core_module.h +5 -0
  120. data/vendor/nginx/src/http/ngx_http_file_cache.c +115 -3
  121. data/vendor/nginx/src/http/ngx_http_header_filter_module.c +9 -6
  122. data/vendor/nginx/src/http/ngx_http_parse.c +88 -10
  123. data/vendor/nginx/src/http/ngx_http_postpone_filter_module.c +2 -4
  124. data/vendor/nginx/src/http/ngx_http_request.c +116 -8
  125. data/vendor/nginx/src/http/ngx_http_request.h +5 -1
  126. data/vendor/nginx/src/http/ngx_http_request_body.c +7 -7
  127. data/vendor/nginx/src/http/ngx_http_script.c +6 -5
  128. data/vendor/nginx/src/http/ngx_http_spdy.c +889 -271
  129. data/vendor/nginx/src/http/ngx_http_spdy.h +51 -28
  130. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +382 -167
  131. data/vendor/nginx/src/http/ngx_http_spdy_module.c +65 -8
  132. data/vendor/nginx/src/http/ngx_http_spdy_module.h +5 -0
  133. data/vendor/nginx/src/http/ngx_http_special_response.c +1 -1
  134. data/vendor/nginx/src/http/ngx_http_upstream.c +290 -114
  135. data/vendor/nginx/src/http/ngx_http_upstream.h +9 -5
  136. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +32 -24
  137. data/vendor/nginx/src/http/ngx_http_variables.c +40 -6
  138. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +12 -5
  139. data/vendor/nginx/src/mail/ngx_mail.c +4 -2
  140. data/vendor/nginx/src/mail/ngx_mail.h +2 -0
  141. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +0 -1
  142. data/vendor/nginx/src/mail/ngx_mail_core_module.c +2 -1
  143. data/vendor/nginx/src/mail/ngx_mail_handler.c +17 -4
  144. data/vendor/nginx/src/mail/ngx_mail_parse.c +32 -2
  145. data/vendor/nginx/src/mail/ngx_mail_proxy_module.c +54 -7
  146. data/vendor/nginx/src/mail/ngx_mail_smtp_handler.c +50 -78
  147. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +48 -11
  148. data/vendor/nginx/src/mail/ngx_mail_ssl_module.h +3 -0
  149. data/vendor/nginx/src/os/unix/ngx_channel.c +3 -1
  150. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +1 -0
  151. data/vendor/nginx/src/os/unix/ngx_darwin_init.c +1 -1
  152. data/vendor/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +14 -16
  153. data/vendor/nginx/src/os/unix/ngx_errno.h +3 -0
  154. data/vendor/nginx/src/os/unix/ngx_files.h +10 -16
  155. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +6 -0
  156. data/vendor/nginx/src/os/unix/ngx_freebsd_init.c +1 -1
  157. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +1 -1
  158. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +2 -2
  159. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +17 -19
  160. data/vendor/nginx/src/os/unix/ngx_linux_config.h +8 -2
  161. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +20 -22
  162. data/vendor/nginx/src/os/unix/ngx_posix_config.h +1 -0
  163. data/vendor/nginx/src/os/unix/ngx_process.c +5 -0
  164. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +15 -3
  165. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +2 -1
  166. data/vendor/nginx/src/os/unix/ngx_recv.c +4 -1
  167. data/vendor/nginx/src/os/unix/ngx_solaris_config.h +1 -0
  168. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +14 -16
  169. metadata +8 -2
@@ -17,6 +17,7 @@ typedef struct {
17
17
  ngx_hash_t types;
18
18
 
19
19
  ngx_flag_t once;
20
+ ngx_flag_t last_modified;
20
21
 
21
22
  ngx_array_t *types_keys;
22
23
  } ngx_http_sub_loc_conf_t;
@@ -89,6 +90,13 @@ static ngx_command_t ngx_http_sub_filter_commands[] = {
89
90
  offsetof(ngx_http_sub_loc_conf_t, once),
90
91
  NULL },
91
92
 
93
+ { ngx_string("sub_filter_last_modified"),
94
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
95
+ ngx_conf_set_flag_slot,
96
+ NGX_HTTP_LOC_CONF_OFFSET,
97
+ offsetof(ngx_http_sub_loc_conf_t, last_modified),
98
+ NULL },
99
+
92
100
  ngx_null_command
93
101
  };
94
102
 
@@ -167,8 +175,11 @@ ngx_http_sub_header_filter(ngx_http_request_t *r)
167
175
 
168
176
  if (r == r->main) {
169
177
  ngx_http_clear_content_length(r);
170
- ngx_http_clear_last_modified(r);
171
178
  ngx_http_clear_etag(r);
179
+
180
+ if (!slcf->last_modified) {
181
+ ngx_http_clear_last_modified(r);
182
+ }
172
183
  }
173
184
 
174
185
  return ngx_http_next_header_filter(r);
@@ -250,66 +261,43 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
250
261
  return rc;
251
262
  }
252
263
 
253
- if (ctx->copy_start != ctx->copy_end) {
264
+ if (ctx->saved.len) {
254
265
 
255
266
  ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
256
267
  "saved: \"%V\"", &ctx->saved);
257
268
 
258
- if (ctx->saved.len) {
269
+ cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
270
+ if (cl == NULL) {
271
+ return NGX_ERROR;
272
+ }
259
273
 
260
- if (ctx->free) {
261
- cl = ctx->free;
262
- ctx->free = ctx->free->next;
263
- b = cl->buf;
264
- ngx_memzero(b, sizeof(ngx_buf_t));
274
+ b = cl->buf;
265
275
 
266
- } else {
267
- b = ngx_calloc_buf(r->pool);
268
- if (b == NULL) {
269
- return NGX_ERROR;
270
- }
276
+ ngx_memzero(b, sizeof(ngx_buf_t));
271
277
 
272
- cl = ngx_alloc_chain_link(r->pool);
273
- if (cl == NULL) {
274
- return NGX_ERROR;
275
- }
278
+ b->pos = ngx_pnalloc(r->pool, ctx->saved.len);
279
+ if (b->pos == NULL) {
280
+ return NGX_ERROR;
281
+ }
276
282
 
277
- cl->buf = b;
278
- }
283
+ ngx_memcpy(b->pos, ctx->saved.data, ctx->saved.len);
284
+ b->last = b->pos + ctx->saved.len;
285
+ b->memory = 1;
279
286
 
280
- b->pos = ngx_pnalloc(r->pool, ctx->saved.len);
281
- if (b->pos == NULL) {
282
- return NGX_ERROR;
283
- }
287
+ *ctx->last_out = cl;
288
+ ctx->last_out = &cl->next;
284
289
 
285
- ngx_memcpy(b->pos, ctx->saved.data, ctx->saved.len);
286
- b->last = b->pos + ctx->saved.len;
287
- b->memory = 1;
290
+ ctx->saved.len = 0;
291
+ }
288
292
 
289
- *ctx->last_out = cl;
290
- ctx->last_out = &cl->next;
293
+ if (ctx->copy_start != ctx->copy_end) {
291
294
 
292
- ctx->saved.len = 0;
295
+ cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
296
+ if (cl == NULL) {
297
+ return NGX_ERROR;
293
298
  }
294
299
 
295
- if (ctx->free) {
296
- cl = ctx->free;
297
- ctx->free = ctx->free->next;
298
- b = cl->buf;
299
-
300
- } else {
301
- b = ngx_alloc_buf(r->pool);
302
- if (b == NULL) {
303
- return NGX_ERROR;
304
- }
305
-
306
- cl = ngx_alloc_chain_link(r->pool);
307
- if (cl == NULL) {
308
- return NGX_ERROR;
309
- }
310
-
311
- cl->buf = b;
312
- }
300
+ b = cl->buf;
313
301
 
314
302
  ngx_memcpy(b, ctx->buf, sizeof(ngx_buf_t));
315
303
 
@@ -324,7 +312,6 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
324
312
  b->file_pos += b->pos - ctx->buf->pos;
325
313
  }
326
314
 
327
- cl->next = NULL;
328
315
  *ctx->last_out = cl;
329
316
  ctx->last_out = &cl->next;
330
317
  }
@@ -338,6 +325,11 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
338
325
  ctx->copy_end = NULL;
339
326
  }
340
327
 
328
+ if (ctx->looked.len > (size_t) (ctx->pos - ctx->buf->pos)) {
329
+ ctx->saved.len = ctx->looked.len - (ctx->pos - ctx->buf->pos);
330
+ ngx_memcpy(ctx->saved.data, ctx->looked.data, ctx->saved.len);
331
+ }
332
+
341
333
  if (rc == NGX_AGAIN) {
342
334
  continue;
343
335
  }
@@ -345,16 +337,15 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
345
337
 
346
338
  /* rc == NGX_OK */
347
339
 
348
- b = ngx_calloc_buf(r->pool);
349
- if (b == NULL) {
350
- return NGX_ERROR;
351
- }
352
-
353
- cl = ngx_alloc_chain_link(r->pool);
340
+ cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
354
341
  if (cl == NULL) {
355
342
  return NGX_ERROR;
356
343
  }
357
344
 
345
+ b = cl->buf;
346
+
347
+ ngx_memzero(b, sizeof(ngx_buf_t));
348
+
358
349
  slcf = ngx_http_get_module_loc_conf(r, ngx_http_sub_filter_module);
359
350
 
360
351
  if (ctx->sub.data == NULL) {
@@ -375,8 +366,6 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
375
366
  b->sync = 1;
376
367
  }
377
368
 
378
- cl->buf = b;
379
- cl->next = NULL;
380
369
  *ctx->last_out = cl;
381
370
  ctx->last_out = &cl->next;
382
371
 
@@ -385,36 +374,47 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
385
374
  continue;
386
375
  }
387
376
 
388
- if (ctx->buf->last_buf || ngx_buf_in_memory(ctx->buf)) {
377
+ if (ctx->buf->last_buf && ctx->looked.len) {
378
+ cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
379
+ if (cl == NULL) {
380
+ return NGX_ERROR;
381
+ }
382
+
383
+ b = cl->buf;
384
+
385
+ ngx_memzero(b, sizeof(ngx_buf_t));
386
+
387
+ b->pos = ctx->looked.data;
388
+ b->last = b->pos + ctx->looked.len;
389
+ b->memory = 1;
390
+
391
+ *ctx->last_out = cl;
392
+ ctx->last_out = &cl->next;
393
+
394
+ ctx->looked.len = 0;
395
+ }
396
+
397
+ if (ctx->buf->last_buf || ctx->buf->flush
398
+ || ngx_buf_in_memory(ctx->buf))
399
+ {
389
400
  if (b == NULL) {
390
- if (ctx->free) {
391
- cl = ctx->free;
392
- ctx->free = ctx->free->next;
393
- b = cl->buf;
394
- ngx_memzero(b, sizeof(ngx_buf_t));
395
-
396
- } else {
397
- b = ngx_calloc_buf(r->pool);
398
- if (b == NULL) {
399
- return NGX_ERROR;
400
- }
401
-
402
- cl = ngx_alloc_chain_link(r->pool);
403
- if (cl == NULL) {
404
- return NGX_ERROR;
405
- }
406
-
407
- cl->buf = b;
401
+ cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
402
+ if (cl == NULL) {
403
+ return NGX_ERROR;
408
404
  }
409
405
 
406
+ b = cl->buf;
407
+
408
+ ngx_memzero(b, sizeof(ngx_buf_t));
409
+
410
410
  b->sync = 1;
411
411
 
412
- cl->next = NULL;
413
412
  *ctx->last_out = cl;
414
413
  ctx->last_out = &cl->next;
415
414
  }
416
415
 
417
416
  b->last_buf = ctx->buf->last_buf;
417
+ b->flush = ctx->buf->flush;
418
418
  b->shadow = ctx->buf;
419
419
 
420
420
  b->recycled = ctx->buf->recycled;
@@ -507,7 +507,7 @@ static ngx_int_t
507
507
  ngx_http_sub_parse(ngx_http_request_t *r, ngx_http_sub_ctx_t *ctx)
508
508
  {
509
509
  u_char *p, *last, *copy_end, ch, match;
510
- size_t looked;
510
+ size_t looked, i;
511
511
  ngx_http_sub_state_e state;
512
512
 
513
513
  if (ctx->once) {
@@ -578,13 +578,11 @@ ngx_http_sub_parse(ngx_http_request_t *r, ngx_http_sub_ctx_t *ctx)
578
578
  looked++;
579
579
 
580
580
  if (looked == ctx->match.len) {
581
- if ((size_t) (p - ctx->pos) < looked) {
582
- ctx->saved.len = 0;
583
- }
584
581
 
585
582
  ctx->state = sub_start_state;
586
583
  ctx->pos = p + 1;
587
584
  ctx->looked.len = 0;
585
+ ctx->saved.len = 0;
588
586
  ctx->copy_end = copy_end;
589
587
 
590
588
  if (ctx->copy_start == NULL && copy_end) {
@@ -594,18 +592,53 @@ ngx_http_sub_parse(ngx_http_request_t *r, ngx_http_sub_ctx_t *ctx)
594
592
  return NGX_OK;
595
593
  }
596
594
 
597
- } else if (ch == ctx->match.data[0]) {
598
- copy_end = p;
599
- ctx->looked.data[0] = *p;
600
- looked = 1;
601
-
602
595
  } else {
603
- copy_end = p;
604
- looked = 0;
605
- state = sub_start_state;
596
+ /*
597
+ * check if there is another partial match in previously
598
+ * matched substring to catch cases like "aab" in "aaab"
599
+ */
600
+
601
+ ctx->looked.data[looked] = *p;
602
+ looked++;
603
+
604
+ for (i = 1; i < looked; i++) {
605
+ if (ngx_strncasecmp(ctx->looked.data + i,
606
+ ctx->match.data, looked - i)
607
+ == 0)
608
+ {
609
+ break;
610
+ }
611
+ }
612
+
613
+ if (i < looked) {
614
+ if (ctx->saved.len > i) {
615
+ ctx->saved.len = i;
616
+ }
617
+
618
+ if ((size_t) (p + 1 - ctx->buf->pos) >= looked - i) {
619
+ copy_end = p + 1 - (looked - i);
620
+ }
621
+
622
+ ngx_memmove(ctx->looked.data, ctx->looked.data + i, looked - i);
623
+ looked = looked - i;
624
+
625
+ } else {
626
+ copy_end = p;
627
+ looked = 0;
628
+ state = sub_start_state;
629
+ }
630
+
631
+ if (ctx->saved.len) {
632
+ p++;
633
+ goto out;
634
+ }
606
635
  }
607
636
  }
608
637
 
638
+ ctx->saved.len = 0;
639
+
640
+ out:
641
+
609
642
  ctx->state = state;
610
643
  ctx->pos = p;
611
644
  ctx->looked.len = looked;
@@ -666,14 +699,12 @@ ngx_http_sub_create_conf(ngx_conf_t *cf)
666
699
  * set by ngx_pcalloc():
667
700
  *
668
701
  * conf->match = { 0, NULL };
669
- * conf->sub = { 0, NULL };
670
- * conf->sub_lengths = NULL;
671
- * conf->sub_values = NULL;
672
702
  * conf->types = { NULL };
673
703
  * conf->types_keys = NULL;
674
704
  */
675
705
 
676
706
  slcf->once = NGX_CONF_UNSET;
707
+ slcf->last_modified = NGX_CONF_UNSET;
677
708
 
678
709
  return slcf;
679
710
  }
@@ -687,6 +718,7 @@ ngx_http_sub_merge_conf(ngx_conf_t *cf, void *parent, void *child)
687
718
 
688
719
  ngx_conf_merge_value(conf->once, prev->once, 1);
689
720
  ngx_conf_merge_str_value(conf->match, prev->match, "");
721
+ ngx_conf_merge_value(conf->last_modified, prev->last_modified, 0);
690
722
 
691
723
  if (conf->value.value.data == NULL) {
692
724
  conf->value = prev->value;
@@ -174,7 +174,7 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
174
174
 
175
175
  for ( ;; ) {
176
176
 
177
- for (i = 0; i < iphp->addrlen; i++) {
177
+ for (i = 0; i < (ngx_uint_t) iphp->addrlen; i++) {
178
178
  hash = (hash * 113 + iphp->addr[i]) % 6271;
179
179
  }
180
180
 
@@ -197,33 +197,39 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
197
197
  n = p / (8 * sizeof(uintptr_t));
198
198
  m = (uintptr_t) 1 << p % (8 * sizeof(uintptr_t));
199
199
 
200
- if (!(iphp->rrp.tried[n] & m)) {
200
+ if (iphp->rrp.tried[n] & m) {
201
+ goto next;
202
+ }
201
203
 
202
- ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
203
- "get ip hash peer, hash: %ui %04XA", p, m);
204
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
205
+ "get ip hash peer, hash: %ui %04XA", p, m);
204
206
 
205
- peer = &iphp->rrp.peers->peer[p];
207
+ peer = &iphp->rrp.peers->peer[p];
206
208
 
207
- /* ngx_lock_mutex(iphp->rrp.peers->mutex); */
209
+ /* ngx_lock_mutex(iphp->rrp.peers->mutex); */
208
210
 
209
- if (!peer->down) {
211
+ if (peer->down) {
212
+ goto next_try;
213
+ }
210
214
 
211
- if (peer->max_fails == 0 || peer->fails < peer->max_fails) {
212
- break;
213
- }
215
+ if (peer->max_fails
216
+ && peer->fails >= peer->max_fails
217
+ && now - peer->checked <= peer->fail_timeout)
218
+ {
219
+ goto next_try;
220
+ }
214
221
 
215
- if (now - peer->checked > peer->fail_timeout) {
216
- peer->checked = now;
217
- break;
218
- }
219
- }
222
+ break;
220
223
 
221
- iphp->rrp.tried[n] |= m;
224
+ next_try:
222
225
 
223
- /* ngx_unlock_mutex(iphp->rrp.peers->mutex); */
226
+ iphp->rrp.tried[n] |= m;
224
227
 
225
- pc->tries--;
226
- }
228
+ /* ngx_unlock_mutex(iphp->rrp.peers->mutex); */
229
+
230
+ pc->tries--;
231
+
232
+ next:
227
233
 
228
234
  if (++iphp->tries >= 20) {
229
235
  return iphp->get_rr_peer(pc, &iphp->rrp);
@@ -236,6 +242,10 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
236
242
  pc->socklen = peer->socklen;
237
243
  pc->name = &peer->name;
238
244
 
245
+ if (now - peer->checked > peer->fail_timeout) {
246
+ peer->checked = now;
247
+ }
248
+
239
249
  /* ngx_unlock_mutex(iphp->rrp.peers->mutex); */
240
250
 
241
251
  iphp->rrp.tried[n] |= m;
@@ -81,7 +81,7 @@ static ngx_command_t ngx_http_upstream_keepalive_commands[] = {
81
81
  { ngx_string("keepalive"),
82
82
  NGX_HTTP_UPS_CONF|NGX_CONF_TAKE12,
83
83
  ngx_http_upstream_keepalive,
84
- 0,
84
+ NGX_HTTP_SRV_CONF_OFFSET,
85
85
  0,
86
86
  NULL },
87
87
 
@@ -481,7 +481,7 @@ static char *
481
481
  ngx_http_upstream_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
482
482
  {
483
483
  ngx_http_upstream_srv_conf_t *uscf;
484
- ngx_http_upstream_keepalive_srv_conf_t *kcf;
484
+ ngx_http_upstream_keepalive_srv_conf_t *kcf = conf;
485
485
 
486
486
  ngx_int_t n;
487
487
  ngx_str_t *value;
@@ -489,9 +489,6 @@ ngx_http_upstream_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
489
489
 
490
490
  uscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_upstream_module);
491
491
 
492
- kcf = ngx_http_conf_upstream_srv_conf(uscf,
493
- ngx_http_upstream_keepalive_module);
494
-
495
492
  if (kcf->original_init_upstream) {
496
493
  return "is duplicate";
497
494
  }