blob: 1bf0f27df6106e6315d2fc98f20249633d7af729 [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
Willy Tarreau8d5d7f22007-01-21 19:16:41 +010024#include <proto/hdr_idx.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020025#include <proto/session.h>
26#include <proto/queue.h>
27
28
29void **pool_session = NULL;
30
31/*
32 * frees the context associated to a session. It must have been removed first.
33 */
34void session_free(struct session *s)
35{
Willy Tarreau0f7562b2007-01-07 15:46:13 +010036 struct http_req *hreq = &s->hreq;
37
Willy Tarreaubaaee002006-06-26 02:48:02 +020038 if (s->pend_pos)
39 pendconn_free(s->pend_pos);
40 if (s->req)
41 pool_free(buffer, s->req);
42 if (s->rep)
43 pool_free(buffer, s->rep);
44
Willy Tarreau0f7562b2007-01-07 15:46:13 +010045 if (hreq->hdr_idx.v != NULL)
46 pool_free_to(s->fe->hdr_idx_pool, hreq->hdr_idx.v);
Willy Tarreau41dff822007-01-01 23:32:30 +010047
Willy Tarreau362b34d2007-01-21 20:49:31 +010048 if (hreq->rsp.cap != NULL) {
Willy Tarreaubaaee002006-06-26 02:48:02 +020049 struct cap_hdr *h;
Willy Tarreau830ff452006-12-17 19:31:23 +010050 for (h = s->fe->fiprm->rsp_cap; h; h = h->next) {
Willy Tarreau362b34d2007-01-21 20:49:31 +010051 if (hreq->rsp.cap[h->index] != NULL)
52 pool_free_to(h->pool, hreq->rsp.cap[h->index]);
Willy Tarreaubaaee002006-06-26 02:48:02 +020053 }
Willy Tarreau362b34d2007-01-21 20:49:31 +010054 pool_free_to(s->fe->fiprm->rsp_cap_pool, hreq->rsp.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +020055 }
Willy Tarreau0f7562b2007-01-07 15:46:13 +010056 if (hreq->req.cap != NULL) {
Willy Tarreaubaaee002006-06-26 02:48:02 +020057 struct cap_hdr *h;
Willy Tarreau830ff452006-12-17 19:31:23 +010058 for (h = s->fe->fiprm->req_cap; h; h = h->next) {
Willy Tarreau0f7562b2007-01-07 15:46:13 +010059 if (hreq->req.cap[h->index] != NULL)
60 pool_free_to(h->pool, hreq->req.cap[h->index]);
Willy Tarreaubaaee002006-06-26 02:48:02 +020061 }
Willy Tarreau0f7562b2007-01-07 15:46:13 +010062 pool_free_to(s->fe->fiprm->req_cap_pool, hreq->req.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +020063 }
64
65 if (s->logs.uri)
66 pool_free(requri, s->logs.uri);
67 if (s->logs.cli_cookie)
68 pool_free(capture, s->logs.cli_cookie);
69 if (s->logs.srv_cookie)
70 pool_free(capture, s->logs.srv_cookie);
71
72 pool_free(session, s);
73}
74
75
76/*
77 * Local variables:
78 * c-indent-level: 8
79 * c-basic-offset: 8
80 * End:
81 */