~ubuntu-branches/ubuntu/vivid/haproxy/vivid

« back to all changes in this revision

Viewing changes to include/proto/backend.h

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Cornet
  • Date: 2008-06-20 00:38:50 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080620003850-hvvx94g2xz2l2xbg
Tags: 1.3.15.1-1
* New Upstream Version
* Upgrade standards version to 3.8.0 (no change needed).
* Build with TARGET=linux26 on linux, TARGET=generic on other systems.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
int be_downtime(struct proxy *px);
44
44
void init_server_map(struct proxy *p);
45
45
void fwrr_init_server_groups(struct proxy *p);
 
46
void fwlc_init_server_tree(struct proxy *p);
46
47
 
47
48
/*
48
49
 * This function tries to find a running server with free connection slots for
50
51
 * If any server is found, it will be returned and px->lbprm.map.rr_idx will be updated
51
52
 * to point to the next server. If no valid server is found, NULL is returned.
52
53
 */
53
 
static inline struct server *get_server_rr_with_conns(struct proxy *px)
 
54
static inline struct server *get_server_rr_with_conns(struct proxy *px, struct server *srvtoavoid)
54
55
{
55
 
        int newidx;
56
 
        struct server *srv;
 
56
        int newidx, avoididx;
 
57
        struct server *srv, *avoided;
57
58
 
58
59
        if (px->lbprm.tot_weight == 0)
59
60
                return NULL;
65
66
                px->lbprm.map.rr_idx = 0;
66
67
        newidx = px->lbprm.map.rr_idx;
67
68
 
 
69
        avoided = NULL;
 
70
        avoididx = 0; /* shut a gcc warning */
68
71
        do {
69
72
                srv = px->lbprm.map.srv[newidx++];
70
73
                if (!srv->maxconn || srv->cur_sess < srv_dynamic_maxconn(srv)) {
71
 
                        px->lbprm.map.rr_idx = newidx;
72
 
                        return srv;
 
74
                        /* make sure it is not the server we are try to exclude... */
 
75
                        if (srv != srvtoavoid) {
 
76
                                px->lbprm.map.rr_idx = newidx;
 
77
                                return srv;
 
78
                        }
 
79
 
 
80
                        avoided = srv;  /* ...but remember that is was selected yet avoided */
 
81
                        avoididx = newidx;
73
82
                }
74
83
                if (newidx == px->lbprm.tot_weight)
75
84
                        newidx = 0;
76
85
        } while (newidx != px->lbprm.map.rr_idx);
77
86
 
78
 
        return NULL;
 
87
        if (avoided)
 
88
                px->lbprm.map.rr_idx = avoididx;
 
89
 
 
90
        /* return NULL or srvtoavoid if found */
 
91
        return avoided;
79
92
}
80
93
 
81
94