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

« back to all changes in this revision

Viewing changes to src/queue.c

  • 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:
33
33
 
34
34
/* returns the effective dynamic maxconn for a server, considering the minconn
35
35
 * and the proxy's usage relative to its dynamic connections limit. It is
36
 
 * expected that 0 < s->minconn <= s->maxconn when this is called.
 
36
 * expected that 0 < s->minconn <= s->maxconn when this is called. If the
 
37
 * server is currently warming up, the slowstart is also applied to the
 
38
 * resulting value, which can be lower than minconn in this case, but never
 
39
 * less than 1.
37
40
 */
38
41
unsigned int srv_dynamic_maxconn(const struct server *s)
39
42
{
 
43
        unsigned int max;
 
44
 
40
45
        if (s->proxy->beconn >= s->proxy->fullconn)
41
46
                /* no fullconn or proxy is full */
42
 
                return s->maxconn;
43
 
 
44
 
        if (s->minconn == s->maxconn)
 
47
                max = s->maxconn;
 
48
        else if (s->minconn == s->maxconn)
45
49
                /* static limit */
46
 
                return s->maxconn;
 
50
                max = s->maxconn;
 
51
        else max = MAX(s->minconn,
 
52
                       s->proxy->beconn * s->maxconn / s->proxy->fullconn);
47
53
 
48
 
        return MAX(s->minconn,
49
 
                   s->proxy->beconn * s->maxconn / s->proxy->fullconn);
 
54
        if ((s->state & SRV_WARMINGUP) &&
 
55
            now.tv_sec < s->last_change + s->slowstart &&
 
56
            now.tv_sec >= s->last_change) {
 
57
                unsigned int ratio;
 
58
                ratio = MAX(1, 100 * (now.tv_sec - s->last_change) / s->slowstart);
 
59
                max = max * ratio / 100;
 
60
        }
 
61
        return max;
50
62
}
51
63
 
52
64