blob: 5372b7dbc5e2b1accf4baf764349fe4ba994f70f [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 * Server management functions.
3 *
4 * Copyright 2000-2006 Willy Tarreau <w@1wt.eu>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#include <stdlib.h>
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020014
15#include <common/config.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020016#include <common/memory.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020017
18#include <types/backend.h>
19#include <types/capture.h>
20#include <types/log.h>
21#include <types/proxy.h>
22#include <types/server.h>
23
24#include <proto/session.h>
25#include <proto/queue.h>
26
27
28void **pool_session = NULL;
29
30/*
31 * frees the context associated to a session. It must have been removed first.
32 */
33void session_free(struct session *s)
34{
Willy Tarreau0f7562b2007-01-07 15:46:13 +010035 struct http_req *hreq = &s->hreq;
36
Willy Tarreaubaaee002006-06-26 02:48:02 +020037 if (s->pend_pos)
38 pendconn_free(s->pend_pos);
39 if (s->req)
40 pool_free(buffer, s->req);
41 if (s->rep)
42 pool_free(buffer, s->rep);
43
Willy Tarreau0f7562b2007-01-07 15:46:13 +010044 if (hreq->hdr_idx.v != NULL)
45 pool_free_to(s->fe->hdr_idx_pool, hreq->hdr_idx.v);
Willy Tarreau41dff822007-01-01 23:32:30 +010046
Willy Tarreaubaaee002006-06-26 02:48:02 +020047 if (s->rsp_cap != NULL) {
48 struct cap_hdr *h;
Willy Tarreau830ff452006-12-17 19:31:23 +010049 for (h = s->fe->fiprm->rsp_cap; h; h = h->next) {
Willy Tarreaubaaee002006-06-26 02:48:02 +020050 if (s->rsp_cap[h->index] != NULL)
51 pool_free_to(h->pool, s->rsp_cap[h->index]);
52 }
Willy Tarreau830ff452006-12-17 19:31:23 +010053 pool_free_to(s->fe->fiprm->rsp_cap_pool, s->rsp_cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +020054 }
Willy Tarreau0f7562b2007-01-07 15:46:13 +010055 if (hreq->req.cap != NULL) {
Willy Tarreaubaaee002006-06-26 02:48:02 +020056 struct cap_hdr *h;
Willy Tarreau830ff452006-12-17 19:31:23 +010057 for (h = s->fe->fiprm->req_cap; h; h = h->next) {
Willy Tarreau0f7562b2007-01-07 15:46:13 +010058 if (hreq->req.cap[h->index] != NULL)
59 pool_free_to(h->pool, hreq->req.cap[h->index]);
Willy Tarreaubaaee002006-06-26 02:48:02 +020060 }
Willy Tarreau0f7562b2007-01-07 15:46:13 +010061 pool_free_to(s->fe->fiprm->req_cap_pool, hreq->req.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +020062 }
63
64 if (s->logs.uri)
65 pool_free(requri, s->logs.uri);
66 if (s->logs.cli_cookie)
67 pool_free(capture, s->logs.cli_cookie);
68 if (s->logs.srv_cookie)
69 pool_free(capture, s->logs.srv_cookie);
70
71 pool_free(session, s);
72}
73
74
75/*
76 * Local variables:
77 * c-indent-level: 8
78 * c-basic-offset: 8
79 * End:
80 */