src/http/ngx_http_upstream_round_robin.h - nginx-1.7.10

Data types defined

Macros defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #ifndef _NGX_HTTP_UPSTREAM_ROUND_ROBIN_H_INCLUDED_
  6. #define _NGX_HTTP_UPSTREAM_ROUND_ROBIN_H_INCLUDED_


  7. #include <ngx_config.h>
  8. #include <ngx_core.h>
  9. #include <ngx_http.h>


  10. typedef struct {
  11.     struct sockaddr                *sockaddr;
  12.     socklen_t                       socklen;
  13.     ngx_str_t                       name;
  14.     ngx_str_t                       server;

  15.     ngx_int_t                       current_weight;
  16.     ngx_int_t                       effective_weight;
  17.     ngx_int_t                       weight;

  18.     ngx_uint_t                      fails;
  19.     time_t                          accessed;
  20.     time_t                          checked;

  21.     ngx_uint_t                      max_fails;
  22.     time_t                          fail_timeout;

  23.     ngx_uint_t                      down;          /* unsigned  down:1; */

  24. #if (NGX_HTTP_SSL)
  25.     ngx_ssl_session_t              *ssl_session;   /* local to a process */
  26. #endif
  27. } ngx_http_upstream_rr_peer_t;


  28. typedef struct ngx_http_upstream_rr_peers_s  ngx_http_upstream_rr_peers_t;

  29. struct ngx_http_upstream_rr_peers_s {
  30.     ngx_uint_t                      number;

  31. /* ngx_mutex_t                    *mutex; */

  32.     ngx_uint_t                      total_weight;

  33.     unsigned                        single:1;
  34.     unsigned                        weighted:1;

  35.     ngx_str_t                      *name;

  36.     ngx_http_upstream_rr_peers_t   *next;

  37.     ngx_http_upstream_rr_peer_t     peer[1];
  38. };


  39. typedef struct {
  40.     ngx_http_upstream_rr_peers_t   *peers;
  41.     ngx_uint_t                      current;
  42.     uintptr_t                      *tried;
  43.     uintptr_t                       data;
  44. } ngx_http_upstream_rr_peer_data_t;


  45. ngx_int_t ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
  46.     ngx_http_upstream_srv_conf_t *us);
  47. ngx_int_t ngx_http_upstream_init_round_robin_peer(ngx_http_request_t *r,
  48.     ngx_http_upstream_srv_conf_t *us);
  49. ngx_int_t ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
  50.     ngx_http_upstream_resolved_t *ur);
  51. ngx_int_t ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc,
  52.     void *data);
  53. void ngx_http_upstream_free_round_robin_peer(ngx_peer_connection_t *pc,
  54.     void *data, ngx_uint_t state);

  55. #if (NGX_HTTP_SSL)
  56. ngx_int_t
  57.     ngx_http_upstream_set_round_robin_peer_session(ngx_peer_connection_t *pc,
  58.     void *data);
  59. void ngx_http_upstream_save_round_robin_peer_session(ngx_peer_connection_t *pc,
  60.     void *data);
  61. #endif


  62. #endif /* _NGX_HTTP_UPSTREAM_ROUND_ROBIN_H_INCLUDED_ */