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

« back to all changes in this revision

Viewing changes to src/session.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:
36
36
void session_free(struct session *s)
37
37
{
38
38
        struct http_txn *txn = &s->txn;
 
39
        struct proxy *fe = s->fe;
39
40
 
40
41
        if (s->pend_pos)
41
42
                pendconn_free(s->pend_pos);
44
45
        if (s->rep)
45
46
                pool_free2(pool2_buffer, s->rep);
46
47
 
47
 
        if (txn->hdr_idx.v != NULL)
48
 
                pool_free2(s->fe->hdr_idx_pool, txn->hdr_idx.v);
49
 
 
50
 
        if (txn->rsp.cap != NULL) {
51
 
                struct cap_hdr *h;
52
 
                for (h = s->fe->rsp_cap; h; h = h->next) {
53
 
                        if (txn->rsp.cap[h->index] != NULL)
54
 
                                pool_free2(h->pool, txn->rsp.cap[h->index]);
55
 
                }
56
 
                pool_free2(s->fe->rsp_cap_pool, txn->rsp.cap);
57
 
        }
58
 
        if (txn->req.cap != NULL) {
59
 
                struct cap_hdr *h;
60
 
                for (h = s->fe->req_cap; h; h = h->next) {
61
 
                        if (txn->req.cap[h->index] != NULL)
62
 
                                pool_free2(h->pool, txn->req.cap[h->index]);
63
 
                }
64
 
                pool_free2(s->fe->req_cap_pool, txn->req.cap);
65
 
        }
66
 
 
 
48
        if (fe) {
 
49
                if (txn->hdr_idx.v != NULL)
 
50
                        pool_free2(fe->hdr_idx_pool, txn->hdr_idx.v);
 
51
 
 
52
                if (txn->rsp.cap != NULL) {
 
53
                        struct cap_hdr *h;
 
54
                        for (h = fe->rsp_cap; h; h = h->next) {
 
55
                                if (txn->rsp.cap[h->index] != NULL)
 
56
                                        pool_free2(h->pool, txn->rsp.cap[h->index]);
 
57
                        }
 
58
                        pool_free2(fe->rsp_cap_pool, txn->rsp.cap);
 
59
                }
 
60
                if (txn->req.cap != NULL) {
 
61
                        struct cap_hdr *h;
 
62
                        for (h = fe->req_cap; h; h = h->next) {
 
63
                                if (txn->req.cap[h->index] != NULL)
 
64
                                        pool_free2(h->pool, txn->req.cap[h->index]);
 
65
                        }
 
66
                        pool_free2(fe->req_cap_pool, txn->req.cap);
 
67
                }
 
68
        }
67
69
        if (txn->uri)
68
70
                pool_free2(pool2_requri, txn->uri);
69
71
        if (txn->cli_cookie)
72
74
                pool_free2(pool2_capture, txn->srv_cookie);
73
75
 
74
76
        pool_free2(pool2_session, s);
 
77
 
 
78
        /* We may want to free the maximum amount of pools if the proxy is stopping */
 
79
        if (fe && unlikely(fe->state == PR_STSTOPPED)) {
 
80
                if (pool2_buffer)
 
81
                        pool_flush2(pool2_buffer);
 
82
                if (fe->hdr_idx_pool)
 
83
                        pool_flush2(fe->hdr_idx_pool);
 
84
                if (pool2_requri)
 
85
                        pool_flush2(pool2_requri);
 
86
                if (pool2_capture)
 
87
                        pool_flush2(pool2_capture);
 
88
                if (pool2_session)
 
89
                        pool_flush2(pool2_session);
 
90
                if (fe->req_cap_pool)
 
91
                        pool_flush2(fe->req_cap_pool);
 
92
                if (fe->rsp_cap_pool)
 
93
                        pool_flush2(fe->rsp_cap_pool);
 
94
        }
75
95
}
76
96
 
77
97
 
82
102
        return pool2_session != NULL;
83
103
}
84
104
 
 
105
void session_process_counters(struct session *s)
 
106
{
 
107
        unsigned long long bytes;
 
108
 
 
109
        if (s->req) {
 
110
                bytes = s->req->total - s->logs.bytes_in;
 
111
                s->logs.bytes_in = s->req->total;
 
112
                if (bytes) {
 
113
                        s->fe->bytes_in          += bytes;
 
114
 
 
115
                        if (s->be != s->fe)
 
116
                                s->be->bytes_in  += bytes;
 
117
 
 
118
                        if (s->srv)
 
119
                                s->srv->bytes_in += bytes;
 
120
                }
 
121
        }
 
122
 
 
123
        if (s->rep) {
 
124
                bytes = s->rep->total - s->logs.bytes_out;
 
125
                s->logs.bytes_out = s->rep->total;
 
126
                if (bytes) {
 
127
                        s->fe->bytes_out          += bytes;
 
128
 
 
129
                        if (s->be != s->fe)
 
130
                                s->be->bytes_out  += bytes;
 
131
 
 
132
                        if (s->srv)
 
133
                                s->srv->bytes_out += bytes;
 
134
                }
 
135
        }
 
136
}
85
137
 
86
138
/*
87
139
 * Local variables: