Mercurial > hg > nginx
annotate src/http/ngx_http_upstream.h @ 2162:429269167fab
ngx_next_time()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 11 Aug 2008 15:28:15 +0000 |
parents | 68b426b43c31 |
children | 274c0f3ea600 |
rev | line source |
---|---|
479 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #ifndef _NGX_HTTP_UPSTREAM_H_INCLUDED_ | |
8 #define _NGX_HTTP_UPSTREAM_H_INCLUDED_ | |
9 | |
10 | |
11 #include <ngx_config.h> | |
12 #include <ngx_core.h> | |
13 #include <ngx_event.h> | |
14 #include <ngx_event_connect.h> | |
15 #include <ngx_event_pipe.h> | |
16 #include <ngx_http.h> | |
17 | |
18 | |
665 | 19 #define NGX_HTTP_UPSTREAM_FT_ERROR 0x00000002 |
20 #define NGX_HTTP_UPSTREAM_FT_TIMEOUT 0x00000004 | |
21 #define NGX_HTTP_UPSTREAM_FT_INVALID_HEADER 0x00000008 | |
22 #define NGX_HTTP_UPSTREAM_FT_HTTP_500 0x00000010 | |
23 #define NGX_HTTP_UPSTREAM_FT_HTTP_503 0x00000020 | |
24 #define NGX_HTTP_UPSTREAM_FT_HTTP_404 0x00000040 | |
25 #define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK 0x00000080 | |
26 #define NGX_HTTP_UPSTREAM_FT_MAX_WAITING 0x00000100 | |
1378 | 27 #define NGX_HTTP_UPSTREAM_FT_NOLIVE 0x40000000 |
665 | 28 #define NGX_HTTP_UPSTREAM_FT_OFF 0x80000000 |
479 | 29 |
30 | |
31 #define NGX_HTTP_UPSTREAM_INVALID_HEADER 40 | |
32 | |
33 | |
34 typedef struct { | |
563 | 35 ngx_msec_t bl_time; |
509 | 36 ngx_uint_t bl_state; |
479 | 37 |
509 | 38 ngx_uint_t status; |
889
a9a7e4b1a72b
the previous fix does not actually fix overflow
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
39 time_t response_sec; |
a9a7e4b1a72b
the previous fix does not actually fix overflow
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
40 ngx_uint_t response_msec; |
563 | 41 |
509 | 42 ngx_str_t *peer; |
479 | 43 } ngx_http_upstream_state_t; |
44 | |
45 | |
46 typedef struct { | |
649 | 47 ngx_hash_t headers_in_hash; |
651 | 48 ngx_array_t upstreams; |
884 | 49 /* ngx_http_upstream_srv_conf_t */ |
509 | 50 } ngx_http_upstream_main_conf_t; |
51 | |
884 | 52 typedef struct ngx_http_upstream_srv_conf_s ngx_http_upstream_srv_conf_t; |
53 | |
54 typedef ngx_int_t (*ngx_http_upstream_init_pt)(ngx_conf_t *cf, | |
55 ngx_http_upstream_srv_conf_t *us); | |
56 typedef ngx_int_t (*ngx_http_upstream_init_peer_pt)(ngx_http_request_t *r, | |
57 ngx_http_upstream_srv_conf_t *us); | |
58 | |
59 | |
60 typedef struct { | |
61 ngx_http_upstream_init_pt init_upstream; | |
62 ngx_http_upstream_init_peer_pt init; | |
63 void *data; | |
64 } ngx_http_upstream_peer_t; | |
65 | |
509 | 66 |
67 typedef struct { | |
884 | 68 ngx_peer_addr_t *addrs; |
69 ngx_uint_t naddrs; | |
70 ngx_uint_t weight; | |
71 ngx_uint_t max_fails; | |
72 time_t fail_timeout; | |
73 | |
74 unsigned down:1; | |
75 unsigned backup:1; | |
76 } ngx_http_upstream_server_t; | |
77 | |
651 | 78 |
884 | 79 #define NGX_HTTP_UPSTREAM_CREATE 0x0001 |
80 #define NGX_HTTP_UPSTREAM_WEIGHT 0x0002 | |
81 #define NGX_HTTP_UPSTREAM_MAX_FAILS 0x0004 | |
82 #define NGX_HTTP_UPSTREAM_FAIL_TIMEOUT 0x0008 | |
83 #define NGX_HTTP_UPSTREAM_DOWN 0x0010 | |
84 #define NGX_HTTP_UPSTREAM_BACKUP 0x0020 | |
85 | |
651 | 86 |
884 | 87 struct ngx_http_upstream_srv_conf_s { |
88 ngx_http_upstream_peer_t peer; | |
89 void **srv_conf; | |
90 | |
91 ngx_array_t *servers; /* ngx_http_upstream_server_t */ | |
92 | |
93 ngx_uint_t flags; | |
651 | 94 ngx_str_t host; |
1489
56f1ea5baabb
u_char* is enough to keep file name
Igor Sysoev <igor@sysoev.ru>
parents:
1378
diff
changeset
|
95 u_char *file_name; |
651 | 96 ngx_uint_t line; |
97 in_port_t port; | |
906 | 98 in_port_t default_port; |
884 | 99 }; |
651 | 100 |
101 | |
102 typedef struct { | |
884 | 103 ngx_http_upstream_srv_conf_t *upstream; |
104 | |
509 | 105 ngx_msec_t connect_timeout; |
106 ngx_msec_t send_timeout; | |
107 ngx_msec_t read_timeout; | |
527 | 108 ngx_msec_t timeout; |
479 | 109 |
509 | 110 size_t send_lowat; |
581 | 111 size_t buffer_size; |
529 | 112 |
509 | 113 size_t busy_buffers_size; |
114 size_t max_temp_file_size; | |
115 size_t temp_file_write_size; | |
116 | |
529 | 117 size_t busy_buffers_size_conf; |
118 size_t max_temp_file_size_conf; | |
119 size_t temp_file_write_size_conf; | |
120 | |
509 | 121 ngx_uint_t next_upstream; |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
122 ngx_uint_t store_access; |
479 | 123 |
509 | 124 ngx_bufs_t bufs; |
479 | 125 |
581 | 126 ngx_flag_t buffering; |
509 | 127 ngx_flag_t pass_request_headers; |
128 ngx_flag_t pass_request_body; | |
129 | |
629 | 130 ngx_flag_t ignore_client_abort; |
657 | 131 ngx_flag_t intercept_errors; |
509 | 132 ngx_flag_t cyclic_temp_file; |
479 | 133 |
649 | 134 ngx_path_t *temp_path; |
479 | 135 |
649 | 136 ngx_hash_t hide_headers_hash; |
137 ngx_array_t *hide_headers; | |
138 ngx_array_t *pass_headers; | |
509 | 139 |
140 ngx_str_t schema; | |
577 | 141 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
142 ngx_array_t *store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
143 ngx_array_t *store_values; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
144 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
145 signed store:2; |
675 | 146 unsigned intercept_404:1; |
649 | 147 unsigned change_buffering:1; |
581 | 148 |
577 | 149 #if (NGX_HTTP_SSL) |
150 ngx_ssl_t *ssl; | |
151 #endif | |
152 | |
479 | 153 } ngx_http_upstream_conf_t; |
154 | |
155 | |
509 | 156 typedef struct { |
157 ngx_str_t name; | |
158 ngx_http_header_handler_pt handler; | |
159 ngx_uint_t offset; | |
160 ngx_http_header_handler_pt copy_handler; | |
161 ngx_uint_t conf; | |
515 | 162 ngx_uint_t redirect; /* unsigned redirect:1; */ |
509 | 163 } ngx_http_upstream_header_t; |
164 | |
165 | |
166 typedef struct { | |
167 ngx_list_t headers; | |
168 | |
529 | 169 ngx_uint_t status_n; |
170 ngx_str_t status_line; | |
171 | |
509 | 172 ngx_table_elt_t *status; |
173 ngx_table_elt_t *date; | |
174 ngx_table_elt_t *server; | |
175 ngx_table_elt_t *connection; | |
176 | |
177 ngx_table_elt_t *expires; | |
178 ngx_table_elt_t *etag; | |
179 ngx_table_elt_t *x_accel_expires; | |
515 | 180 ngx_table_elt_t *x_accel_redirect; |
527 | 181 ngx_table_elt_t *x_accel_limit_rate; |
509 | 182 |
183 ngx_table_elt_t *content_type; | |
184 ngx_table_elt_t *content_length; | |
185 | |
186 ngx_table_elt_t *last_modified; | |
187 ngx_table_elt_t *location; | |
188 ngx_table_elt_t *accept_ranges; | |
529 | 189 ngx_table_elt_t *www_authenticate; |
509 | 190 |
191 #if (NGX_HTTP_GZIP) | |
192 ngx_table_elt_t *content_encoding; | |
193 #endif | |
194 | |
1885
e5897822515f
test response length in proxy/fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1701
diff
changeset
|
195 off_t content_length_n; |
e5897822515f
test response length in proxy/fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1701
diff
changeset
|
196 |
509 | 197 ngx_array_t cache_control; |
198 } ngx_http_upstream_headers_in_t; | |
199 | |
479 | 200 |
1658 | 201 typedef struct { |
202 ngx_str_t host; | |
203 in_port_t port; | |
1912 | 204 ngx_uint_t default_port; /* unsigned default_port:1 */ |
1658 | 205 ngx_uint_t naddrs; |
206 in_addr_t *addrs; | |
207 ngx_resolver_ctx_t *ctx; | |
208 } ngx_http_upstream_resolved_t; | |
209 | |
210 | |
479 | 211 struct ngx_http_upstream_s { |
509 | 212 ngx_peer_connection_t peer; |
479 | 213 |
581 | 214 ngx_event_pipe_t *pipe; |
479 | 215 |
509 | 216 ngx_chain_t *request_bufs; |
479 | 217 |
509 | 218 ngx_output_chain_ctx_t output; |
219 ngx_chain_writer_ctx_t writer; | |
479 | 220 |
509 | 221 ngx_http_upstream_conf_t *conf; |
479 | 222 |
509 | 223 ngx_http_upstream_headers_in_t headers_in; |
224 | |
1658 | 225 ngx_http_upstream_resolved_t *resolved; |
226 | |
581 | 227 ngx_buf_t buffer; |
228 size_t length; | |
229 | |
230 ngx_chain_t *out_bufs; | |
231 ngx_chain_t *busy_bufs; | |
232 ngx_chain_t *free_bufs; | |
233 | |
234 ngx_int_t (*input_filter_init)(void *data); | |
235 ngx_int_t (*input_filter)(void *data, ssize_t bytes); | |
236 void *input_filter_ctx; | |
479 | 237 |
509 | 238 ngx_int_t (*create_request)(ngx_http_request_t *r); |
239 ngx_int_t (*reinit_request)(ngx_http_request_t *r); | |
240 ngx_int_t (*process_header)(ngx_http_request_t *r); | |
241 void (*abort_request)(ngx_http_request_t *r); | |
242 void (*finalize_request)(ngx_http_request_t *r, | |
243 ngx_int_t rc); | |
244 ngx_int_t (*rewrite_redirect)(ngx_http_request_t *r, | |
245 ngx_table_elt_t *h, size_t prefix); | |
479 | 246 |
527 | 247 ngx_msec_t timeout; |
248 | |
509 | 249 ngx_http_upstream_state_t *state; |
479 | 250 |
1658 | 251 ngx_str_t method; |
252 ngx_str_t schema; | |
555 | 253 ngx_str_t uri; |
254 | |
569 | 255 ngx_http_cleanup_pt *cleanup; |
256 | |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1168
diff
changeset
|
257 unsigned store:1; |
1565 | 258 unsigned cacheable:1; |
509 | 259 unsigned accel:1; |
1658 | 260 unsigned ssl:1; |
479 | 261 |
649 | 262 unsigned buffering:1; |
263 | |
509 | 264 unsigned request_sent:1; |
265 unsigned header_sent:1; | |
479 | 266 }; |
267 | |
268 | |
1162 | 269 ngx_int_t ngx_http_upstream_header_variable(ngx_http_request_t *r, |
270 ngx_http_variable_value_t *v, uintptr_t data); | |
271 | |
479 | 272 void ngx_http_upstream_init(ngx_http_request_t *r); |
651 | 273 ngx_http_upstream_srv_conf_t *ngx_http_upstream_add(ngx_conf_t *cf, |
884 | 274 ngx_url_t *u, ngx_uint_t flags); |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1658
diff
changeset
|
275 ngx_int_t ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf, |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1658
diff
changeset
|
276 ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev, |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1658
diff
changeset
|
277 ngx_str_t *default_hide_headers, ngx_hash_init_t *hash); |
884 | 278 |
279 | |
280 #define ngx_http_conf_upstream_srv_conf(uscf, module) \ | |
281 uscf->srv_conf[module.ctx_index] | |
509 | 282 |
479 | 283 |
509 | 284 extern ngx_module_t ngx_http_upstream_module; |
479 | 285 |
286 | |
287 #endif /* _NGX_HTTP_UPSTREAM_H_INCLUDED_ */ |