~ubuntu-branches/ubuntu/intrepid/haproxy/intrepid

« back to all changes in this revision

Viewing changes to include/types/server.h

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Cornet
  • Date: 2008-03-09 21:30:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080309213029-8oupnrc607mg5uqw
Tags: 1.3.14.3-1
* New Upstream Version
* Add status argument support to init-script to conform to LSB.
* Cleanup pidfile after stop in init script. Init script return code fixups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
  include/types/server.h
3
3
  This file defines everything related to servers.
4
4
 
5
 
  Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu
 
5
  Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu
6
6
  
7
7
  This library is free software; you can redistribute it and/or
8
8
  modify it under the terms of the GNU Lesser General Public
26
26
#include <arpa/inet.h>
27
27
 
28
28
#include <common/config.h>
 
29
#include <common/eb32tree.h>
29
30
#include <common/mini-clist.h>
30
31
 
31
32
#include <types/buffers.h>
40
41
#define SRV_MAPPORTS    0x0004  /* this server uses mapped ports */
41
42
#define SRV_BIND_SRC    0x0008  /* this server uses a specific source address */
42
43
#define SRV_CHECKED     0x0010  /* this server needs to be checked */
43
 
 
44
 
#define SRV_TPROXY_ADDR 0x0020  /* bind to this non-local address to reach this server */
45
 
#define SRV_TPROXY_CIP  0x0040  /* bind to the client's IP address to reach this server */
46
 
#define SRV_TPROXY_CLI  0x0060  /* bind to the client's IP+port to reach this server */
47
 
#define SRV_TPROXY_MASK 0x0060  /* bind to a non-local address to reach this server */
 
44
#define SRV_GOINGDOWN   0x0020  /* this server says that it's going down (404) */
 
45
#define SRV_WARMINGUP   0x0040  /* this server is warming up after a failure */
 
46
/* unused: 0x0080 */
 
47
#define SRV_TPROXY_ADDR 0x0100  /* bind to this non-local address to reach this server */
 
48
#define SRV_TPROXY_CIP  0x0200  /* bind to the client's IP address to reach this server */
 
49
#define SRV_TPROXY_CLI  0x0300  /* bind to the client's IP+port to reach this server */
 
50
#define SRV_TPROXY_MASK 0x0300  /* bind to a non-local address to reach this server */
48
51
 
49
52
/* function which act on servers need to return various errors */
50
53
#define SRV_STATUS_OK       0   /* everything is OK. */
53
56
#define SRV_STATUS_FULL     3   /* the/all server(s) are saturated */
54
57
#define SRV_STATUS_QUEUED   4   /* the/all server(s) are saturated but the connection was queued */
55
58
 
 
59
/* bits for s->result used for health-checks */
 
60
#define SRV_CHK_UNKNOWN 0x0000   /* initialized to this by default */
 
61
#define SRV_CHK_ERROR   0x0001   /* error encountered during the check; has precedence */
 
62
#define SRV_CHK_RUNNING 0x0002   /* server seen as running */
 
63
#define SRV_CHK_DISABLE 0x0004   /* server returned a "disable" code */
 
64
 
 
65
/* various constants */
 
66
#define SRV_UWGHT_RANGE 256
 
67
#define SRV_UWGHT_MAX   (SRV_UWGHT_RANGE - 1)
 
68
#define SRV_EWGHT_RANGE (SRV_UWGHT_RANGE * BE_WEIGHT_SCALE)
 
69
#define SRV_EWGHT_MAX   (SRV_UWGHT_MAX   * BE_WEIGHT_SCALE)
56
70
 
57
71
struct server {
58
72
        struct server *next;
59
73
        int state;                              /* server state (SRV_*) */
 
74
        int prev_state;                         /* server state before last change (SRV_*) */
60
75
        int  cklen;                             /* the len of the cookie, to speed up checks */
61
76
        char *cookie;                           /* the id set in the cookie */
62
77
 
64
79
        int cur_sess, cur_sess_max;             /* number of currently active sessions (including syn_sent) */
65
80
        unsigned maxconn, minconn;              /* max # of active sessions (0 = unlimited), min# for dynamic limit. */
66
81
        int nbpend, nbpend_max;                 /* number of pending connections */
 
82
        int maxqueue;                           /* maximum number of pending connections allowed */
67
83
        struct list pendconns;                  /* pending connections */
68
84
        struct task *queue_mgt;                 /* the task associated to the queue processing */
69
85
 
78
94
        int health;                             /* 0->rise-1 = bad; rise->rise+fall-1 = good */
79
95
        int rise, fall;                         /* time in iterations */
80
96
        int inter;                              /* time in milliseconds */
81
 
        int result;                             /* 0 = connect OK, -1 = connect KO */
 
97
        int slowstart;                          /* slowstart time in seconds (ms in the conf) */
 
98
        int result;                             /* health-check result : SRV_CHK_* */
82
99
        int curfd;                              /* file desc used for current test, or -1 if not in test */
83
100
 
84
101
        char *id;                               /* just for identification */
85
102
        unsigned uweight, eweight;              /* user-specified weight, and effective weight */
86
103
        unsigned wscore;                        /* weight score, used during srv map computation */
 
104
        unsigned prev_eweight;                  /* eweight before last change */
 
105
        unsigned rweight;                       /* remainer of weight in the current LB tree */
 
106
        unsigned npos, lpos;                    /* next and last positions in the LB tree */
 
107
        struct eb32_node lb_node;               /* node used for tree-based load balancing */
 
108
        struct eb_root *lb_tree;                /* we want to know in what tree the server is */
 
109
        struct server *next_full;               /* next server in the temporary full list */
87
110
 
88
111
        unsigned failed_checks, down_trans;     /* failed checks and up-down transitions */
 
112
        unsigned down_time;                     /* total time the server was down */
 
113
        time_t last_change;                     /* last time, when the state was changed */
 
114
 
89
115
        unsigned failed_conns, failed_resp;     /* failed connect() and responses */
 
116
        unsigned retries;                       /* retried connections */
90
117
        unsigned failed_secu;                   /* blocked responses because of security concerns */
91
118
        unsigned cum_sess;                      /* cumulated number of sessions really sent to this server */
 
119
        unsigned cum_lbconn;                    /* cumulated number of sessions directed by load balancing */
 
120
 
92
121
        long long bytes_in;                     /* number of bytes transferred from the client to the server */
93
122
        long long bytes_out;                    /* number of bytes transferred from the server to the client */
 
123
        int puid;                               /* proxy-unique server ID, used for SNMP */
94
124
};
95
125
 
96
126