Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.13.12 ]​[ nginx-1.12.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #ifndef _NGX_STREAM_UPSTREAM_H_INCLUDED_
0009 #define _NGX_STREAM_UPSTREAM_H_INCLUDED_
0010 
0011 
0012 #include <ngx_config.h>
0013 #include <ngx_core.h>
0014 #include <ngx_stream.h>
0015 #include <ngx_event_connect.h>
0016 
0017 
0018 #define NGX_STREAM_UPSTREAM_CREATE        0x0001
0019 #define NGX_STREAM_UPSTREAM_WEIGHT        0x0002
0020 #define NGX_STREAM_UPSTREAM_MAX_FAILS     0x0004
0021 #define NGX_STREAM_UPSTREAM_FAIL_TIMEOUT  0x0008
0022 #define NGX_STREAM_UPSTREAM_DOWN          0x0010
0023 #define NGX_STREAM_UPSTREAM_BACKUP        0x0020
0024 #define NGX_STREAM_UPSTREAM_MAX_CONNS     0x0100
0025 
0026 
0027 #define NGX_STREAM_UPSTREAM_NOTIFY_CONNECT     0x1
0028 
0029 
0030 typedef struct {
0031     ngx_array_t                        upstreams;
0032                                            /* ngx_stream_upstream_srv_conf_t */
0033 } ngx_stream_upstream_main_conf_t;
0034 
0035 
0036 typedef struct ngx_stream_upstream_srv_conf_s  ngx_stream_upstream_srv_conf_t;
0037 
0038 
0039 typedef ngx_int_t (*ngx_stream_upstream_init_pt)(ngx_conf_t *cf,
0040     ngx_stream_upstream_srv_conf_t *us);
0041 typedef ngx_int_t (*ngx_stream_upstream_init_peer_pt)(ngx_stream_session_t *s,
0042     ngx_stream_upstream_srv_conf_t *us);
0043 
0044 
0045 typedef struct {
0046     ngx_stream_upstream_init_pt        init_upstream;
0047     ngx_stream_upstream_init_peer_pt   init;
0048     void                              *data;
0049 } ngx_stream_upstream_peer_t;
0050 
0051 
0052 typedef struct {
0053     ngx_str_t                          name;
0054     ngx_addr_t                        *addrs;
0055     ngx_uint_t                         naddrs;
0056     ngx_uint_t                         weight;
0057     ngx_uint_t                         max_conns;
0058     ngx_uint_t                         max_fails;
0059     time_t                             fail_timeout;
0060     ngx_msec_t                         slow_start;
0061     ngx_uint_t                         down;
0062 
0063     unsigned                           backup:1;
0064 
0065     NGX_COMPAT_BEGIN(4)
0066     NGX_COMPAT_END
0067 } ngx_stream_upstream_server_t;
0068 
0069 
0070 struct ngx_stream_upstream_srv_conf_s {
0071     ngx_stream_upstream_peer_t         peer;
0072     void                             **srv_conf;
0073 
0074     ngx_array_t                       *servers;
0075                                               /* ngx_stream_upstream_server_t */
0076 
0077     ngx_uint_t                         flags;
0078     ngx_str_t                          host;
0079     u_char                            *file_name;
0080     ngx_uint_t                         line;
0081     in_port_t                          port;
0082     ngx_uint_t                         no_port;  /* unsigned no_port:1 */
0083 
0084 #if (NGX_STREAM_UPSTREAM_ZONE)
0085     ngx_shm_zone_t                    *shm_zone;
0086 #endif
0087 };
0088 
0089 
0090 typedef struct {
0091     ngx_msec_t                         response_time;
0092     ngx_msec_t                         connect_time;
0093     ngx_msec_t                         first_byte_time;
0094     off_t                              bytes_sent;
0095     off_t                              bytes_received;
0096 
0097     ngx_str_t                         *peer;
0098 } ngx_stream_upstream_state_t;
0099 
0100 
0101 typedef struct {
0102     ngx_str_t                          host;
0103     in_port_t                          port;
0104     ngx_uint_t                         no_port; /* unsigned no_port:1 */
0105 
0106     ngx_uint_t                         naddrs;
0107     ngx_resolver_addr_t               *addrs;
0108 
0109     struct sockaddr                   *sockaddr;
0110     socklen_t                          socklen;
0111     ngx_str_t                          name;
0112 
0113     ngx_resolver_ctx_t                *ctx;
0114 } ngx_stream_upstream_resolved_t;
0115 
0116 
0117 typedef struct {
0118     ngx_peer_connection_t              peer;
0119 
0120     ngx_buf_t                          downstream_buf;
0121     ngx_buf_t                          upstream_buf;
0122 
0123     ngx_chain_t                       *free;
0124     ngx_chain_t                       *upstream_out;
0125     ngx_chain_t                       *upstream_busy;
0126     ngx_chain_t                       *downstream_out;
0127     ngx_chain_t                       *downstream_busy;
0128 
0129     off_t                              received;
0130     time_t                             start_sec;
0131     ngx_uint_t                         responses;
0132 
0133     ngx_str_t                          ssl_name;
0134 
0135     ngx_stream_upstream_srv_conf_t    *upstream;
0136     ngx_stream_upstream_resolved_t    *resolved;
0137     ngx_stream_upstream_state_t       *state;
0138     unsigned                           connected:1;
0139     unsigned                           proxy_protocol:1;
0140 } ngx_stream_upstream_t;
0141 
0142 
0143 ngx_stream_upstream_srv_conf_t *ngx_stream_upstream_add(ngx_conf_t *cf,
0144     ngx_url_t *u, ngx_uint_t flags);
0145 
0146 
0147 #define ngx_stream_conf_upstream_srv_conf(uscf, module)                       \
0148     uscf->srv_conf[module.ctx_index]
0149 
0150 
0151 extern ngx_module_t  ngx_stream_upstream_module;
0152 
0153 
0154 #endif /* _NGX_STREAM_UPSTREAM_H_INCLUDED_ */