diff src/http/ngx_http_upstream.h @ 464:c8cfb6c462ef NGINX_0_7_44

nginx 0.7.44 *) Feature: the ngx_http_proxy_module preliminary cache support. *) Feature: the --with-pcre option in the configure. *) Feature: the "try_files" directive is now allowed on the server block level. *) Bugfix: the "try_files" directive handled incorrectly a query string in a fallback parameter. *) Bugfix: the "try_files" directive might test incorrectly directories. *) Bugfix: if there is the single server for given address:port pair, then captures in regular expressions in a "server_name" directive did not work.
author Igor Sysoev <http://sysoev.ru>
date Mon, 23 Mar 2009 00:00:00 +0300
parents 49a0eb7ce20c
children 392c16f2d858
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -39,21 +39,21 @@
 
 
 typedef struct {
-    ngx_msec_t                      bl_time;
-    ngx_uint_t                      bl_state;
+    ngx_msec_t                       bl_time;
+    ngx_uint_t                       bl_state;
 
-    ngx_uint_t                      status;
-    time_t                          response_sec;
-    ngx_uint_t                      response_msec;
+    ngx_uint_t                       status;
+    time_t                           response_sec;
+    ngx_uint_t                       response_msec;
     off_t                           response_length;
 
-    ngx_str_t                      *peer;
+    ngx_str_t                       *peer;
 } ngx_http_upstream_state_t;
 
 
 typedef struct {
-    ngx_hash_t                      headers_in_hash;
-    ngx_array_t                     upstreams;
+    ngx_hash_t                       headers_in_hash;
+    ngx_array_t                      upstreams;
                                              /* ngx_http_upstream_srv_conf_t */
 } ngx_http_upstream_main_conf_t;
 
@@ -66,21 +66,21 @@ typedef ngx_int_t (*ngx_http_upstream_in
 
 
 typedef struct {
-    ngx_http_upstream_init_pt       init_upstream;
-    ngx_http_upstream_init_peer_pt  init;
-    void                           *data;
+    ngx_http_upstream_init_pt        init_upstream;
+    ngx_http_upstream_init_peer_pt   init;
+    void                            *data;
 } ngx_http_upstream_peer_t;
 
 
 typedef struct {
-    ngx_peer_addr_t                *addrs;
-    ngx_uint_t                      naddrs;
-    ngx_uint_t                      weight;
-    ngx_uint_t                      max_fails;
-    time_t                          fail_timeout;
+    ngx_peer_addr_t                 *addrs;
+    ngx_uint_t                       naddrs;
+    ngx_uint_t                       weight;
+    ngx_uint_t                       max_fails;
+    time_t                           fail_timeout;
 
-    unsigned                        down:1;
-    unsigned                        backup:1;
+    unsigned                         down:1;
+    unsigned                         backup:1;
 } ngx_http_upstream_server_t;
 
 
@@ -93,67 +93,75 @@ typedef struct {
 
 
 struct ngx_http_upstream_srv_conf_s {
-    ngx_http_upstream_peer_t        peer;
-    void                          **srv_conf;
+    ngx_http_upstream_peer_t         peer;
+    void                           **srv_conf;
 
-    ngx_array_t                    *servers;   /* ngx_http_upstream_server_t */
+    ngx_array_t                     *servers;  /* ngx_http_upstream_server_t */
 
-    ngx_uint_t                      flags;
-    ngx_str_t                       host;
-    u_char                         *file_name;
-    ngx_uint_t                      line;
-    in_port_t                       port;
-    in_port_t                       default_port;
+    ngx_uint_t                       flags;
+    ngx_str_t                        host;
+    u_char                          *file_name;
+    ngx_uint_t                       line;
+    in_port_t                        port;
+    in_port_t                        default_port;
 };
 
 
 typedef struct {
-    ngx_http_upstream_srv_conf_t   *upstream;
+    ngx_http_upstream_srv_conf_t    *upstream;
 
-    ngx_msec_t                      connect_timeout;
-    ngx_msec_t                      send_timeout;
-    ngx_msec_t                      read_timeout;
-    ngx_msec_t                      timeout;
+    ngx_msec_t                       connect_timeout;
+    ngx_msec_t                       send_timeout;
+    ngx_msec_t                       read_timeout;
+    ngx_msec_t                       timeout;
 
-    size_t                          send_lowat;
-    size_t                          buffer_size;
+    size_t                           send_lowat;
+    size_t                           buffer_size;
 
-    size_t                          busy_buffers_size;
-    size_t                          max_temp_file_size;
-    size_t                          temp_file_write_size;
+    size_t                           busy_buffers_size;
+    size_t                           max_temp_file_size;
+    size_t                           temp_file_write_size;
+
+    size_t                           busy_buffers_size_conf;
+    size_t                           max_temp_file_size_conf;
+    size_t                           temp_file_write_size_conf;
 
-    size_t                          busy_buffers_size_conf;
-    size_t                          max_temp_file_size_conf;
-    size_t                          temp_file_write_size_conf;
+    ngx_bufs_t                       bufs;
 
-    ngx_uint_t                      next_upstream;
-    ngx_uint_t                      store_access;
+    ngx_uint_t                       next_upstream;
+    ngx_uint_t                       store_access;
+    ngx_flag_t                       buffering;
+    ngx_flag_t                       pass_request_headers;
+    ngx_flag_t                       pass_request_body;
 
-    ngx_bufs_t                      bufs;
+    ngx_flag_t                       ignore_client_abort;
+    ngx_flag_t                       intercept_errors;
+    ngx_flag_t                       cyclic_temp_file;
+
+    ngx_path_t                      *temp_path;
 
-    ngx_flag_t                      buffering;
-    ngx_flag_t                      pass_request_headers;
-    ngx_flag_t                      pass_request_body;
+    ngx_hash_t                       hide_headers_hash;
+    ngx_array_t                     *hide_headers;
+    ngx_array_t                     *pass_headers;
 
-    ngx_flag_t                      ignore_client_abort;
-    ngx_flag_t                      intercept_errors;
-    ngx_flag_t                      cyclic_temp_file;
+#if (NGX_HTTP_CACHE)
+    ngx_shm_zone_t                  *cache;
 
-    ngx_path_t                     *temp_path;
+    ngx_uint_t                       cache_min_uses;
+    ngx_uint_t                       cache_use_stale;
 
-    ngx_hash_t                      hide_headers_hash;
-    ngx_array_t                    *hide_headers;
-    ngx_array_t                    *pass_headers;
+    ngx_array_t                     *cache_valid;
+#endif
 
-    ngx_array_t                    *store_lengths;
-    ngx_array_t                    *store_values;
+    ngx_array_t                     *store_lengths;
+    ngx_array_t                     *store_values;
 
-    signed                          store:2;
-    unsigned                        intercept_404:1;
-    unsigned                        change_buffering:1;
+    signed                           store:2;
+    unsigned                         intercept_404:1;
+    unsigned                         change_buffering:1;
 
 #if (NGX_HTTP_SSL)
-    ngx_ssl_t                      *ssl;
+    ngx_ssl_t                       *ssl;
     ngx_flag_t                      ssl_session_reuse;
 #endif
 
@@ -161,62 +169,62 @@ typedef struct {
 
 
 typedef struct {
-    ngx_str_t                       name;
-    ngx_http_header_handler_pt      handler;
-    ngx_uint_t                      offset;
-    ngx_http_header_handler_pt      copy_handler;
-    ngx_uint_t                      conf;
-    ngx_uint_t                      redirect;  /* unsigned   redirect:1; */
+    ngx_str_t                        name;
+    ngx_http_header_handler_pt       handler;
+    ngx_uint_t                       offset;
+    ngx_http_header_handler_pt       copy_handler;
+    ngx_uint_t                       conf;
+    ngx_uint_t                       redirect;  /* unsigned   redirect:1; */
 } ngx_http_upstream_header_t;
 
 
 typedef struct {
-    ngx_list_t                      headers;
+    ngx_list_t                       headers;
 
-    ngx_uint_t                      status_n;
-    ngx_str_t                       status_line;
+    ngx_uint_t                       status_n;
+    ngx_str_t                        status_line;
 
-    ngx_table_elt_t                *status;
-    ngx_table_elt_t                *date;
-    ngx_table_elt_t                *server;
-    ngx_table_elt_t                *connection;
+    ngx_table_elt_t                 *status;
+    ngx_table_elt_t                 *date;
+    ngx_table_elt_t                 *server;
+    ngx_table_elt_t                 *connection;
 
-    ngx_table_elt_t                *expires;
-    ngx_table_elt_t                *etag;
-    ngx_table_elt_t                *x_accel_expires;
-    ngx_table_elt_t                *x_accel_redirect;
-    ngx_table_elt_t                *x_accel_limit_rate;
+    ngx_table_elt_t                 *expires;
+    ngx_table_elt_t                 *etag;
+    ngx_table_elt_t                 *x_accel_expires;
+    ngx_table_elt_t                 *x_accel_redirect;
+    ngx_table_elt_t                 *x_accel_limit_rate;
 
-    ngx_table_elt_t                *content_type;
-    ngx_table_elt_t                *content_length;
+    ngx_table_elt_t                 *content_type;
+    ngx_table_elt_t                 *content_length;
 
-    ngx_table_elt_t                *last_modified;
-    ngx_table_elt_t                *location;
-    ngx_table_elt_t                *accept_ranges;
-    ngx_table_elt_t                *www_authenticate;
+    ngx_table_elt_t                 *last_modified;
+    ngx_table_elt_t                 *location;
+    ngx_table_elt_t                 *accept_ranges;
+    ngx_table_elt_t                 *www_authenticate;
 
 #if (NGX_HTTP_GZIP)
-    ngx_table_elt_t                *content_encoding;
+    ngx_table_elt_t                 *content_encoding;
 #endif
 
-    off_t                           content_length_n;
+    off_t                            content_length_n;
 
-    ngx_array_t                     cache_control;
+    ngx_array_t                      cache_control;
 } ngx_http_upstream_headers_in_t;
 
 
 typedef struct {
-    ngx_str_t                       host;
-    in_port_t                       port;
-    ngx_uint_t                      no_port; /* unsigned  no_port:1 */
+    ngx_str_t                        host;
+    in_port_t                        port;
+    ngx_uint_t                       no_port; /* unsigned no_port:1 */
 
-    ngx_uint_t                      naddrs;
-    in_addr_t                      *addrs;
+    ngx_uint_t                       naddrs;
+    in_addr_t                       *addrs;
 
-    struct sockaddr                *sockaddr;
-    socklen_t                       socklen;
+    struct sockaddr                 *sockaddr;
+    socklen_t                        socklen;
 
-    ngx_resolver_ctx_t             *ctx;
+    ngx_resolver_ctx_t              *ctx;
 } ngx_http_upstream_resolved_t;
 
 
@@ -225,63 +233,69 @@ typedef void (*ngx_http_upstream_handler
 
 
 struct ngx_http_upstream_s {
-    ngx_http_upstream_handler_pt    read_event_handler;
-    ngx_http_upstream_handler_pt    write_event_handler;
+    ngx_http_upstream_handler_pt     read_event_handler;
+    ngx_http_upstream_handler_pt     write_event_handler;
 
-    ngx_peer_connection_t           peer;
+    ngx_peer_connection_t            peer;
 
-    ngx_event_pipe_t               *pipe;
+    ngx_event_pipe_t                *pipe;
 
-    ngx_chain_t                    *request_bufs;
+    ngx_chain_t                     *request_bufs;
 
-    ngx_output_chain_ctx_t          output;
-    ngx_chain_writer_ctx_t          writer;
+    ngx_output_chain_ctx_t           output;
+    ngx_chain_writer_ctx_t           writer;
 
-    ngx_http_upstream_conf_t       *conf;
+    ngx_http_upstream_conf_t        *conf;
 
-    ngx_http_upstream_headers_in_t  headers_in;
+    ngx_http_upstream_headers_in_t   headers_in;
 
-    ngx_http_upstream_resolved_t   *resolved;
+    ngx_http_upstream_resolved_t    *resolved;
 
-    ngx_buf_t                       buffer;
-    size_t                          length;
+    ngx_buf_t                        buffer;
+    size_t                           length;
 
-    ngx_chain_t                    *out_bufs;
-    ngx_chain_t                    *busy_bufs;
-    ngx_chain_t                    *free_bufs;
+    ngx_chain_t                     *out_bufs;
+    ngx_chain_t                     *busy_bufs;
+    ngx_chain_t                     *free_bufs;
 
-    ngx_int_t                     (*input_filter_init)(void *data);
-    ngx_int_t                     (*input_filter)(void *data, ssize_t bytes);
-    void                           *input_filter_ctx;
+    ngx_int_t                      (*input_filter_init)(void *data);
+    ngx_int_t                      (*input_filter)(void *data, ssize_t bytes);
+    void                            *input_filter_ctx;
 
-    ngx_int_t                     (*create_request)(ngx_http_request_t *r);
-    ngx_int_t                     (*reinit_request)(ngx_http_request_t *r);
-    ngx_int_t                     (*process_header)(ngx_http_request_t *r);
-    void                          (*abort_request)(ngx_http_request_t *r);
-    void                          (*finalize_request)(ngx_http_request_t *r,
-                                        ngx_int_t rc);
-    ngx_int_t                     (*rewrite_redirect)(ngx_http_request_t *r,
-                                        ngx_table_elt_t *h, size_t prefix);
+#if (NGX_HTTP_CACHE)
+    ngx_int_t                      (*create_key)(ngx_http_request_t *r);
+#endif
+    ngx_int_t                      (*create_request)(ngx_http_request_t *r);
+    ngx_int_t                      (*reinit_request)(ngx_http_request_t *r);
+    ngx_int_t                      (*process_header)(ngx_http_request_t *r);
+    void                           (*abort_request)(ngx_http_request_t *r);
+    void                           (*finalize_request)(ngx_http_request_t *r,
+                                         ngx_int_t rc);
+    ngx_int_t                      (*rewrite_redirect)(ngx_http_request_t *r,
+                                         ngx_table_elt_t *h, size_t prefix);
 
-    ngx_msec_t                      timeout;
+    ngx_msec_t                       timeout;
 
-    ngx_http_upstream_state_t      *state;
+    ngx_http_upstream_state_t       *state;
 
-    ngx_str_t                       method;
-    ngx_str_t                       schema;
-    ngx_str_t                       uri;
+    ngx_str_t                        method;
+    ngx_str_t                        schema;
+    ngx_str_t                        uri;
 
-    ngx_http_cleanup_pt            *cleanup;
+    ngx_http_cleanup_pt             *cleanup;
 
-    unsigned                        store:1;
-    unsigned                        cacheable:1;
-    unsigned                        accel:1;
-    unsigned                        ssl:1;
+    unsigned                         store:1;
+    unsigned                         cacheable:1;
+    unsigned                         accel:1;
+    unsigned                         ssl:1;
+#if (NGX_HTTP_CACHE)
+    unsigned                         stale_cache:1;
+#endif
 
-    unsigned                        buffering:1;
+    unsigned                         buffering:1;
 
-    unsigned                        request_sent:1;
-    unsigned                        header_sent:1;
+    unsigned                         request_sent:1;
+    unsigned                         header_sent:1;
 };