blob: 1b574a00bb9c50c5a2c4af9b0864ff927250f794 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 * Server management functions.
3 *
Willy Tarreauc6ca1a02007-05-13 19:43:47 +02004 * Copyright 2000-2007 Willy Tarreau <w@1wt.eu>
Willy Tarreaubaaee002006-06-26 02:48:02 +02005 *
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 Tarreau7341d942007-05-13 19:56:02 +020024#include <proto/buffers.h>
Willy Tarreau8d5d7f22007-01-21 19:16:41 +010025#include <proto/hdr_idx.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020026#include <proto/session.h>
27#include <proto/queue.h>
28
29
Willy Tarreauc6ca1a02007-05-13 19:43:47 +020030struct pool_head *pool2_session;
Willy Tarreaubaaee002006-06-26 02:48:02 +020031
32/*
33 * frees the context associated to a session. It must have been removed first.
34 */
35void session_free(struct session *s)
36{
Willy Tarreau4dbc4a22007-03-03 16:23:22 +010037 struct http_txn *txn = &s->txn;
Willy Tarreau0f7562b2007-01-07 15:46:13 +010038
Willy Tarreaubaaee002006-06-26 02:48:02 +020039 if (s->pend_pos)
40 pendconn_free(s->pend_pos);
41 if (s->req)
Willy Tarreau7341d942007-05-13 19:56:02 +020042 pool_free2(pool2_buffer, s->req);
Willy Tarreaubaaee002006-06-26 02:48:02 +020043 if (s->rep)
Willy Tarreau7341d942007-05-13 19:56:02 +020044 pool_free2(pool2_buffer, s->rep);
Willy Tarreaubaaee002006-06-26 02:48:02 +020045
Willy Tarreau4dbc4a22007-03-03 16:23:22 +010046 if (txn->hdr_idx.v != NULL)
47 pool_free_to(s->fe->hdr_idx_pool, txn->hdr_idx.v);
Willy Tarreau41dff822007-01-01 23:32:30 +010048
Willy Tarreau4dbc4a22007-03-03 16:23:22 +010049 if (txn->rsp.cap != NULL) {
Willy Tarreaubaaee002006-06-26 02:48:02 +020050 struct cap_hdr *h;
Willy Tarreaue2e27a52007-04-01 00:01:37 +020051 for (h = s->fe->rsp_cap; h; h = h->next) {
Willy Tarreau4dbc4a22007-03-03 16:23:22 +010052 if (txn->rsp.cap[h->index] != NULL)
53 pool_free_to(h->pool, txn->rsp.cap[h->index]);
Willy Tarreaubaaee002006-06-26 02:48:02 +020054 }
Willy Tarreaue2e27a52007-04-01 00:01:37 +020055 pool_free_to(s->fe->rsp_cap_pool, txn->rsp.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +020056 }
Willy Tarreau4dbc4a22007-03-03 16:23:22 +010057 if (txn->req.cap != NULL) {
Willy Tarreaubaaee002006-06-26 02:48:02 +020058 struct cap_hdr *h;
Willy Tarreaue2e27a52007-04-01 00:01:37 +020059 for (h = s->fe->req_cap; h; h = h->next) {
Willy Tarreau4dbc4a22007-03-03 16:23:22 +010060 if (txn->req.cap[h->index] != NULL)
61 pool_free_to(h->pool, txn->req.cap[h->index]);
Willy Tarreaubaaee002006-06-26 02:48:02 +020062 }
Willy Tarreaue2e27a52007-04-01 00:01:37 +020063 pool_free_to(s->fe->req_cap_pool, txn->req.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +020064 }
65
Willy Tarreau3bac9ff2007-03-18 17:31:28 +010066 if (txn->uri)
67 pool_free(requri, txn->uri);
68 if (txn->cli_cookie)
69 pool_free(capture, txn->cli_cookie);
70 if (txn->srv_cookie)
71 pool_free(capture, txn->srv_cookie);
Willy Tarreaubaaee002006-06-26 02:48:02 +020072
Willy Tarreauc6ca1a02007-05-13 19:43:47 +020073 pool_free2(pool2_session, s);
74}
75
76
77/* perform minimal intializations, report 0 in case of error, 1 if OK. */
78int init_session()
79{
80 pool2_session = create_pool("session", sizeof(struct session), MEM_F_SHARED);
81 return pool2_session != NULL;
Willy Tarreaubaaee002006-06-26 02:48:02 +020082}
83
84
85/*
86 * Local variables:
87 * c-indent-level: 8
88 * c-basic-offset: 8
89 * End:
90 */