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
@@ -50,6 +50,7 @@
50
50
  #define NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE 0x00000040
51
51
  #define NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING 0x00000080
52
52
  #define NGX_HTTP_UPSTREAM_IGN_XA_CHARSET 0x00000100
53
+ #define NGX_HTTP_UPSTREAM_IGN_VARY 0x00000200
53
54
 
54
55
 
55
56
  typedef struct {
@@ -59,6 +60,8 @@ typedef struct {
59
60
  ngx_uint_t status;
60
61
  time_t response_sec;
61
62
  ngx_uint_t response_msec;
63
+ time_t header_sec;
64
+ ngx_uint_t header_msec;
62
65
  off_t response_length;
63
66
 
64
67
  ngx_str_t *peer;
@@ -87,6 +90,7 @@ typedef struct {
87
90
 
88
91
 
89
92
  typedef struct {
93
+ ngx_str_t name;
90
94
  ngx_addr_t *addrs;
91
95
  ngx_uint_t naddrs;
92
96
  ngx_uint_t weight;
@@ -135,9 +139,11 @@ typedef struct {
135
139
  ngx_msec_t send_timeout;
136
140
  ngx_msec_t read_timeout;
137
141
  ngx_msec_t timeout;
142
+ ngx_msec_t next_upstream_timeout;
138
143
 
139
144
  size_t send_lowat;
140
145
  size_t buffer_size;
146
+ size_t limit_rate;
141
147
 
142
148
  size_t busy_buffers_size;
143
149
  size_t max_temp_file_size;
@@ -152,13 +158,16 @@ typedef struct {
152
158
  ngx_uint_t ignore_headers;
153
159
  ngx_uint_t next_upstream;
154
160
  ngx_uint_t store_access;
161
+ ngx_uint_t next_upstream_tries;
155
162
  ngx_flag_t buffering;
163
+ ngx_flag_t request_buffering;
156
164
  ngx_flag_t pass_request_headers;
157
165
  ngx_flag_t pass_request_body;
158
166
 
159
167
  ngx_flag_t ignore_client_abort;
160
168
  ngx_flag_t intercept_errors;
161
169
  ngx_flag_t cyclic_temp_file;
170
+ ngx_flag_t force_ranges;
162
171
 
163
172
  ngx_path_t *temp_path;
164
173
 
@@ -169,7 +178,8 @@ typedef struct {
169
178
  ngx_http_upstream_local_t *local;
170
179
 
171
180
  #if (NGX_HTTP_CACHE)
172
- ngx_shm_zone_t *cache;
181
+ ngx_shm_zone_t *cache_zone;
182
+ ngx_http_complex_value_t *cache_value;
173
183
 
174
184
  ngx_uint_t cache_min_uses;
175
185
  ngx_uint_t cache_use_stale;
@@ -177,6 +187,7 @@ typedef struct {
177
187
 
178
188
  ngx_flag_t cache_lock;
179
189
  ngx_msec_t cache_lock_timeout;
190
+ ngx_msec_t cache_lock_age;
180
191
 
181
192
  ngx_flag_t cache_revalidate;
182
193
 
@@ -188,6 +199,9 @@ typedef struct {
188
199
  ngx_array_t *store_lengths;
189
200
  ngx_array_t *store_values;
190
201
 
202
+ #if (NGX_HTTP_CACHE)
203
+ signed cache:2;
204
+ #endif
191
205
  signed store:2;
192
206
  unsigned intercept_404:1;
193
207
  unsigned change_buffering:1;
@@ -195,6 +209,10 @@ typedef struct {
195
209
  #if (NGX_HTTP_SSL)
196
210
  ngx_ssl_t *ssl;
197
211
  ngx_flag_t ssl_session_reuse;
212
+
213
+ ngx_http_complex_value_t *ssl_name;
214
+ ngx_flag_t ssl_server_name;
215
+ ngx_flag_t ssl_verify;
198
216
  #endif
199
217
 
200
218
  ngx_str_t module;
@@ -236,14 +254,17 @@ typedef struct {
236
254
  ngx_table_elt_t *accept_ranges;
237
255
  ngx_table_elt_t *www_authenticate;
238
256
  ngx_table_elt_t *transfer_encoding;
257
+ ngx_table_elt_t *vary;
239
258
 
240
259
  #if (NGX_HTTP_GZIP)
241
260
  ngx_table_elt_t *content_encoding;
242
261
  #endif
243
262
 
244
- off_t content_length_n;
245
-
246
263
  ngx_array_t cache_control;
264
+ ngx_array_t cookies;
265
+
266
+ off_t content_length_n;
267
+ time_t last_modified_time;
247
268
 
248
269
  unsigned connection_close:1;
249
270
  unsigned chunked:1;
@@ -283,6 +304,9 @@ struct ngx_http_upstream_s {
283
304
  ngx_chain_writer_ctx_t writer;
284
305
 
285
306
  ngx_http_upstream_conf_t *conf;
307
+ #if (NGX_HTTP_CACHE)
308
+ ngx_array_t *caches;
309
+ #endif
286
310
 
287
311
  ngx_http_upstream_headers_in_t headers_in;
288
312
 
@@ -323,6 +347,10 @@ struct ngx_http_upstream_s {
323
347
  ngx_str_t schema;
324
348
  ngx_str_t uri;
325
349
 
350
+ #if (NGX_HTTP_SSL)
351
+ ngx_str_t ssl_name;
352
+ #endif
353
+
326
354
  ngx_http_cleanup_pt *cleanup;
327
355
 
328
356
  unsigned store:1;
@@ -355,6 +383,8 @@ typedef struct {
355
383
  } ngx_http_upstream_param_t;
356
384
 
357
385
 
386
+ ngx_int_t ngx_http_upstream_cookie_variable(ngx_http_request_t *r,
387
+ ngx_http_variable_value_t *v, uintptr_t data);
358
388
  ngx_int_t ngx_http_upstream_header_variable(ngx_http_request_t *r,
359
389
  ngx_http_variable_value_t *v, uintptr_t data);
360
390
 
@@ -10,6 +10,10 @@
10
10
  #include <ngx_http.h>
11
11
 
12
12
 
13
+ #define ngx_http_upstream_tries(p) ((p)->number \
14
+ + ((p)->next ? (p)->next->number : 0))
15
+
16
+
13
17
  static ngx_http_upstream_rr_peer_t *ngx_http_upstream_get_peer(
14
18
  ngx_http_upstream_rr_peer_data_t *rrp);
15
19
 
@@ -30,6 +34,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
30
34
  ngx_url_t u;
31
35
  ngx_uint_t i, j, n, w;
32
36
  ngx_http_upstream_server_t *server;
37
+ ngx_http_upstream_rr_peer_t *peer;
33
38
  ngx_http_upstream_rr_peers_t *peers, *backup;
34
39
 
35
40
  us->peer.init = ngx_http_upstream_init_round_robin_peer;
@@ -69,6 +74,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
69
74
  peers->name = &us->host;
70
75
 
71
76
  n = 0;
77
+ peer = peers->peer;
72
78
 
73
79
  for (i = 0; i < us->servers->nelts; i++) {
74
80
  if (server[i].backup) {
@@ -76,15 +82,16 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
76
82
  }
77
83
 
78
84
  for (j = 0; j < server[i].naddrs; j++) {
79
- peers->peer[n].sockaddr = server[i].addrs[j].sockaddr;
80
- peers->peer[n].socklen = server[i].addrs[j].socklen;
81
- peers->peer[n].name = server[i].addrs[j].name;
82
- peers->peer[n].weight = server[i].weight;
83
- peers->peer[n].effective_weight = server[i].weight;
84
- peers->peer[n].current_weight = 0;
85
- peers->peer[n].max_fails = server[i].max_fails;
86
- peers->peer[n].fail_timeout = server[i].fail_timeout;
87
- peers->peer[n].down = server[i].down;
85
+ peer[n].sockaddr = server[i].addrs[j].sockaddr;
86
+ peer[n].socklen = server[i].addrs[j].socklen;
87
+ peer[n].name = server[i].addrs[j].name;
88
+ peer[n].weight = server[i].weight;
89
+ peer[n].effective_weight = server[i].weight;
90
+ peer[n].current_weight = 0;
91
+ peer[n].max_fails = server[i].max_fails;
92
+ peer[n].fail_timeout = server[i].fail_timeout;
93
+ peer[n].down = server[i].down;
94
+ peer[n].server = server[i].name;
88
95
  n++;
89
96
  }
90
97
  }
@@ -123,6 +130,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
123
130
  backup->name = &us->host;
124
131
 
125
132
  n = 0;
133
+ peer = backup->peer;
126
134
 
127
135
  for (i = 0; i < us->servers->nelts; i++) {
128
136
  if (!server[i].backup) {
@@ -130,15 +138,16 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
130
138
  }
131
139
 
132
140
  for (j = 0; j < server[i].naddrs; j++) {
133
- backup->peer[n].sockaddr = server[i].addrs[j].sockaddr;
134
- backup->peer[n].socklen = server[i].addrs[j].socklen;
135
- backup->peer[n].name = server[i].addrs[j].name;
136
- backup->peer[n].weight = server[i].weight;
137
- backup->peer[n].effective_weight = server[i].weight;
138
- backup->peer[n].current_weight = 0;
139
- backup->peer[n].max_fails = server[i].max_fails;
140
- backup->peer[n].fail_timeout = server[i].fail_timeout;
141
- backup->peer[n].down = server[i].down;
141
+ peer[n].sockaddr = server[i].addrs[j].sockaddr;
142
+ peer[n].socklen = server[i].addrs[j].socklen;
143
+ peer[n].name = server[i].addrs[j].name;
144
+ peer[n].weight = server[i].weight;
145
+ peer[n].effective_weight = server[i].weight;
146
+ peer[n].current_weight = 0;
147
+ peer[n].max_fails = server[i].max_fails;
148
+ peer[n].fail_timeout = server[i].fail_timeout;
149
+ peer[n].down = server[i].down;
150
+ peer[n].server = server[i].name;
142
151
  n++;
143
152
  }
144
153
  }
@@ -187,15 +196,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
187
196
  peers->total_weight = n;
188
197
  peers->name = &us->host;
189
198
 
199
+ peer = peers->peer;
200
+
190
201
  for (i = 0; i < u.naddrs; i++) {
191
- peers->peer[i].sockaddr = u.addrs[i].sockaddr;
192
- peers->peer[i].socklen = u.addrs[i].socklen;
193
- peers->peer[i].name = u.addrs[i].name;
194
- peers->peer[i].weight = 1;
195
- peers->peer[i].effective_weight = 1;
196
- peers->peer[i].current_weight = 0;
197
- peers->peer[i].max_fails = 1;
198
- peers->peer[i].fail_timeout = 10;
202
+ peer[i].sockaddr = u.addrs[i].sockaddr;
203
+ peer[i].socklen = u.addrs[i].socklen;
204
+ peer[i].name = u.addrs[i].name;
205
+ peer[i].weight = 1;
206
+ peer[i].effective_weight = 1;
207
+ peer[i].current_weight = 0;
208
+ peer[i].max_fails = 1;
209
+ peer[i].fail_timeout = 10;
199
210
  }
200
211
 
201
212
  us->peer.data = peers;
@@ -248,7 +259,7 @@ ngx_http_upstream_init_round_robin_peer(ngx_http_request_t *r,
248
259
 
249
260
  r->upstream->peer.get = ngx_http_upstream_get_round_robin_peer;
250
261
  r->upstream->peer.free = ngx_http_upstream_free_round_robin_peer;
251
- r->upstream->peer.tries = rrp->peers->number;
262
+ r->upstream->peer.tries = ngx_http_upstream_tries(rrp->peers);
252
263
  #if (NGX_HTTP_SSL)
253
264
  r->upstream->peer.set_session =
254
265
  ngx_http_upstream_set_round_robin_peer_session;
@@ -269,6 +280,7 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
269
280
  socklen_t socklen;
270
281
  ngx_uint_t i, n;
271
282
  struct sockaddr *sockaddr;
283
+ ngx_http_upstream_rr_peer_t *peer;
272
284
  ngx_http_upstream_rr_peers_t *peers;
273
285
  ngx_http_upstream_rr_peer_data_t *rrp;
274
286
 
@@ -293,15 +305,17 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
293
305
  peers->number = ur->naddrs;
294
306
  peers->name = &ur->host;
295
307
 
308
+ peer = peers->peer;
309
+
296
310
  if (ur->sockaddr) {
297
- peers->peer[0].sockaddr = ur->sockaddr;
298
- peers->peer[0].socklen = ur->socklen;
299
- peers->peer[0].name = ur->host;
300
- peers->peer[0].weight = 1;
301
- peers->peer[0].effective_weight = 1;
302
- peers->peer[0].current_weight = 0;
303
- peers->peer[0].max_fails = 1;
304
- peers->peer[0].fail_timeout = 10;
311
+ peer[0].sockaddr = ur->sockaddr;
312
+ peer[0].socklen = ur->socklen;
313
+ peer[0].name = ur->host;
314
+ peer[0].weight = 1;
315
+ peer[0].effective_weight = 1;
316
+ peer[0].current_weight = 0;
317
+ peer[0].max_fails = 1;
318
+ peer[0].fail_timeout = 10;
305
319
 
306
320
  } else {
307
321
 
@@ -333,15 +347,15 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
333
347
 
334
348
  len = ngx_sock_ntop(sockaddr, socklen, p, NGX_SOCKADDR_STRLEN, 1);
335
349
 
336
- peers->peer[i].sockaddr = sockaddr;
337
- peers->peer[i].socklen = socklen;
338
- peers->peer[i].name.len = len;
339
- peers->peer[i].name.data = p;
340
- peers->peer[i].weight = 1;
341
- peers->peer[i].effective_weight = 1;
342
- peers->peer[i].current_weight = 0;
343
- peers->peer[i].max_fails = 1;
344
- peers->peer[i].fail_timeout = 10;
350
+ peer[i].sockaddr = sockaddr;
351
+ peer[i].socklen = socklen;
352
+ peer[i].name.len = len;
353
+ peer[i].name.data = p;
354
+ peer[i].weight = 1;
355
+ peer[i].effective_weight = 1;
356
+ peer[i].current_weight = 0;
357
+ peer[i].max_fails = 1;
358
+ peer[i].fail_timeout = 10;
345
359
  }
346
360
  }
347
361
 
@@ -364,7 +378,7 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
364
378
 
365
379
  r->upstream->peer.get = ngx_http_upstream_get_round_robin_peer;
366
380
  r->upstream->peer.free = ngx_http_upstream_free_round_robin_peer;
367
- r->upstream->peer.tries = rrp->peers->number;
381
+ r->upstream->peer.tries = ngx_http_upstream_tries(rrp->peers);
368
382
  #if (NGX_HTTP_SSL)
369
383
  r->upstream->peer.set_session = ngx_http_upstream_empty_set_session;
370
384
  r->upstream->peer.save_session = ngx_http_upstream_empty_save_session;
@@ -387,13 +401,15 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
387
401
  ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
388
402
  "get rr peer, try: %ui", pc->tries);
389
403
 
390
- /* ngx_lock_mutex(rrp->peers->mutex); */
391
-
392
404
  pc->cached = 0;
393
405
  pc->connection = NULL;
394
406
 
395
- if (rrp->peers->single) {
396
- peer = &rrp->peers->peer[0];
407
+ peers = rrp->peers;
408
+
409
+ /* ngx_lock_mutex(peers->mutex); */
410
+
411
+ if (peers->single) {
412
+ peer = &peers->peer[0];
397
413
 
398
414
  if (peer->down) {
399
415
  goto failed;
@@ -418,18 +434,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
418
434
  pc->socklen = peer->socklen;
419
435
  pc->name = &peer->name;
420
436
 
421
- /* ngx_unlock_mutex(rrp->peers->mutex); */
422
-
423
- if (pc->tries == 1 && rrp->peers->next) {
424
- pc->tries += rrp->peers->next->number;
425
- }
437
+ /* ngx_unlock_mutex(peers->mutex); */
426
438
 
427
439
  return NGX_OK;
428
440
 
429
441
  failed:
430
442
 
431
- peers = rrp->peers;
432
-
433
443
  if (peers->next) {
434
444
 
435
445
  /* ngx_unlock_mutex(peers->mutex); */
@@ -437,7 +447,6 @@ failed:
437
447
  ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pc->log, 0, "backup servers");
438
448
 
439
449
  rrp->peers = peers->next;
440
- pc->tries = rrp->peers->number;
441
450
 
442
451
  n = (rrp->peers->number + (8 * sizeof(uintptr_t) - 1))
443
452
  / (8 * sizeof(uintptr_t));
@@ -622,9 +631,8 @@ ngx_http_upstream_set_round_robin_peer_session(ngx_peer_connection_t *pc,
622
631
 
623
632
  rc = ngx_ssl_set_session(pc->connection, ssl_session);
624
633
 
625
- ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
626
- "set session: %p:%d",
627
- ssl_session, ssl_session ? ssl_session->references : 0);
634
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
635
+ "set session: %p", ssl_session);
628
636
 
629
637
  /* ngx_unlock_mutex(rrp->peers->mutex); */
630
638
 
@@ -647,8 +655,8 @@ ngx_http_upstream_save_round_robin_peer_session(ngx_peer_connection_t *pc,
647
655
  return;
648
656
  }
649
657
 
650
- ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
651
- "save session: %p:%d", ssl_session, ssl_session->references);
658
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
659
+ "save session: %p", ssl_session);
652
660
 
653
661
  peer = &rrp->peers->peer[rrp->current];
654
662
 
@@ -662,9 +670,8 @@ ngx_http_upstream_save_round_robin_peer_session(ngx_peer_connection_t *pc,
662
670
 
663
671
  if (old_ssl_session) {
664
672
 
665
- ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
666
- "old session: %p:%d",
667
- old_ssl_session, old_ssl_session->references);
673
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
674
+ "old session: %p", old_ssl_session);
668
675
 
669
676
  /* TODO: may block */
670
677
 
@@ -18,6 +18,7 @@ typedef struct {
18
18
  struct sockaddr *sockaddr;
19
19
  socklen_t socklen;
20
20
  ngx_str_t name;
21
+ ngx_str_t server;
21
22
 
22
23
  ngx_int_t current_weight;
23
24
  ngx_int_t effective_weight;
@@ -43,8 +44,6 @@ typedef struct ngx_http_upstream_rr_peers_s ngx_http_upstream_rr_peers_t;
43
44
  struct ngx_http_upstream_rr_peers_s {
44
45
  ngx_uint_t number;
45
46
 
46
- /* ngx_mutex_t *mutex; */
47
-
48
47
  ngx_uint_t total_weight;
49
48
 
50
49
  unsigned single:1;
@@ -13,8 +13,10 @@
13
13
 
14
14
  static ngx_int_t ngx_http_variable_request(ngx_http_request_t *r,
15
15
  ngx_http_variable_value_t *v, uintptr_t data);
16
+ #if 0
16
17
  static void ngx_http_variable_request_set(ngx_http_request_t *r,
17
18
  ngx_http_variable_value_t *v, uintptr_t data);
19
+ #endif
18
20
  static ngx_int_t ngx_http_variable_request_get_size(ngx_http_request_t *r,
19
21
  ngx_http_variable_value_t *v, uintptr_t data);
20
22
  static void ngx_http_variable_request_set_size(ngx_http_request_t *r,
@@ -64,6 +66,8 @@ static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r,
64
66
  ngx_http_variable_value_t *v, uintptr_t data);
65
67
  static ngx_int_t ngx_http_variable_https(ngx_http_request_t *r,
66
68
  ngx_http_variable_value_t *v, uintptr_t data);
69
+ static void ngx_http_variable_set_args(ngx_http_request_t *r,
70
+ ngx_http_variable_value_t *v, uintptr_t data);
67
71
  static ngx_int_t ngx_http_variable_is_args(ngx_http_request_t *r,
68
72
  ngx_http_variable_value_t *v, uintptr_t data);
69
73
  static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r,
@@ -223,7 +227,7 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
223
227
  NGX_HTTP_VAR_NOCACHEABLE, 0 },
224
228
 
225
229
  { ngx_string("args"),
226
- ngx_http_variable_request_set,
230
+ ngx_http_variable_set_args,
227
231
  ngx_http_variable_request,
228
232
  offsetof(ngx_http_request_t, args),
229
233
  NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
@@ -613,6 +617,17 @@ ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name, ngx_uint_t key)
613
617
  return NULL;
614
618
  }
615
619
 
620
+ if (ngx_strncmp(name->data, "upstream_cookie_", 16) == 0) {
621
+
622
+ if (ngx_http_upstream_cookie_variable(r, vv, (uintptr_t) name)
623
+ == NGX_OK)
624
+ {
625
+ return vv;
626
+ }
627
+
628
+ return NULL;
629
+ }
630
+
616
631
  if (ngx_strncmp(name->data, "arg_", 4) == 0) {
617
632
 
618
633
  if (ngx_http_variable_argument(r, vv, (uintptr_t) name) == NGX_OK) {
@@ -651,6 +666,8 @@ ngx_http_variable_request(ngx_http_request_t *r, ngx_http_variable_value_t *v,
651
666
  }
652
667
 
653
668
 
669
+ #if 0
670
+
654
671
  static void
655
672
  ngx_http_variable_request_set(ngx_http_request_t *r,
656
673
  ngx_http_variable_value_t *v, uintptr_t data)
@@ -663,6 +680,8 @@ ngx_http_variable_request_set(ngx_http_request_t *r,
663
680
  s->data = v->data;
664
681
  }
665
682
 
683
+ #endif
684
+
666
685
 
667
686
  static ngx_int_t
668
687
  ngx_http_variable_request_get_size(ngx_http_request_t *r,
@@ -1062,6 +1081,10 @@ ngx_http_variable_content_length(ngx_http_request_t *r,
1062
1081
  v->no_cacheable = 0;
1063
1082
  v->not_found = 0;
1064
1083
 
1084
+ } else if (r->reading_body) {
1085
+ v->not_found = 1;
1086
+ v->no_cacheable = 1;
1087
+
1065
1088
  } else if (r->headers_in.content_length_n >= 0) {
1066
1089
  p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN);
1067
1090
  if (p == NULL) {
@@ -1360,6 +1383,16 @@ ngx_http_variable_https(ngx_http_request_t *r,
1360
1383
  }
1361
1384
 
1362
1385
 
1386
+ static void
1387
+ ngx_http_variable_set_args(ngx_http_request_t *r,
1388
+ ngx_http_variable_value_t *v, uintptr_t data)
1389
+ {
1390
+ r->args.len = v->len;
1391
+ r->args.data = v->data;
1392
+ r->valid_unparsed_uri = 0;
1393
+ }
1394
+
1395
+
1363
1396
  static ngx_int_t
1364
1397
  ngx_http_variable_is_args(ngx_http_request_t *r,
1365
1398
  ngx_http_variable_value_t *v, uintptr_t data)
@@ -2482,8 +2515,7 @@ ngx_http_variables_init_vars(ngx_conf_t *cf)
2482
2515
 
2483
2516
  av = key[n].value;
2484
2517
 
2485
- if (av->get_handler
2486
- && v[i].name.len == key[n].key.len
2518
+ if (v[i].name.len == key[n].key.len
2487
2519
  && ngx_strncmp(v[i].name.data, key[n].key.data, v[i].name.len)
2488
2520
  == 0)
2489
2521
  {
@@ -2495,6 +2527,10 @@ ngx_http_variables_init_vars(ngx_conf_t *cf)
2495
2527
 
2496
2528
  av->index = i;
2497
2529
 
2530
+ if (av->get_handler == NULL) {
2531
+ break;
2532
+ }
2533
+
2498
2534
  goto next;
2499
2535
  }
2500
2536
  }
@@ -2528,6 +2564,14 @@ ngx_http_variables_init_vars(ngx_conf_t *cf)
2528
2564
  continue;
2529
2565
  }
2530
2566
 
2567
+ if (ngx_strncmp(v[i].name.data, "upstream_cookie_", 16) == 0) {
2568
+ v[i].get_handler = ngx_http_upstream_cookie_variable;
2569
+ v[i].data = (uintptr_t) &v[i].name;
2570
+ v[i].flags = NGX_HTTP_VAR_NOCACHEABLE;
2571
+
2572
+ continue;
2573
+ }
2574
+
2531
2575
  if (ngx_strncmp(v[i].name.data, "arg_", 4) == 0) {
2532
2576
  v[i].get_handler = ngx_http_variable_argument;
2533
2577
  v[i].data = (uintptr_t) &v[i].name;