2006-06-25 20:48:02 -04:00
|
|
|
/*
|
|
|
|
|
* Server management functions.
|
|
|
|
|
*
|
2007-05-13 13:43:47 -04:00
|
|
|
* Copyright 2000-2007 Willy Tarreau <w@1wt.eu>
|
2006-06-25 20:48:02 -04:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2006-06-29 12:54:54 -04:00
|
|
|
|
|
|
|
|
#include <common/config.h>
|
2006-06-29 11:53:05 -04:00
|
|
|
#include <common/memory.h>
|
2006-06-25 20:48:02 -04:00
|
|
|
|
|
|
|
|
#include <types/backend.h>
|
|
|
|
|
#include <types/capture.h>
|
|
|
|
|
#include <types/log.h>
|
|
|
|
|
#include <types/proxy.h>
|
|
|
|
|
#include <types/server.h>
|
|
|
|
|
|
2007-01-21 13:16:41 -05:00
|
|
|
#include <proto/hdr_idx.h>
|
2006-06-25 20:48:02 -04:00
|
|
|
#include <proto/session.h>
|
|
|
|
|
#include <proto/queue.h>
|
|
|
|
|
|
|
|
|
|
|
2007-05-13 13:43:47 -04:00
|
|
|
struct pool_head *pool2_session;
|
2006-06-25 20:48:02 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* frees the context associated to a session. It must have been removed first.
|
|
|
|
|
*/
|
|
|
|
|
void session_free(struct session *s)
|
|
|
|
|
{
|
2007-03-03 10:23:22 -05:00
|
|
|
struct http_txn *txn = &s->txn;
|
2007-01-07 09:46:13 -05:00
|
|
|
|
2006-06-25 20:48:02 -04:00
|
|
|
if (s->pend_pos)
|
|
|
|
|
pendconn_free(s->pend_pos);
|
|
|
|
|
if (s->req)
|
|
|
|
|
pool_free(buffer, s->req);
|
|
|
|
|
if (s->rep)
|
|
|
|
|
pool_free(buffer, s->rep);
|
|
|
|
|
|
2007-03-03 10:23:22 -05:00
|
|
|
if (txn->hdr_idx.v != NULL)
|
|
|
|
|
pool_free_to(s->fe->hdr_idx_pool, txn->hdr_idx.v);
|
2007-01-01 17:32:30 -05:00
|
|
|
|
2007-03-03 10:23:22 -05:00
|
|
|
if (txn->rsp.cap != NULL) {
|
2006-06-25 20:48:02 -04:00
|
|
|
struct cap_hdr *h;
|
2007-03-31 18:01:37 -04:00
|
|
|
for (h = s->fe->rsp_cap; h; h = h->next) {
|
2007-03-03 10:23:22 -05:00
|
|
|
if (txn->rsp.cap[h->index] != NULL)
|
|
|
|
|
pool_free_to(h->pool, txn->rsp.cap[h->index]);
|
2006-06-25 20:48:02 -04:00
|
|
|
}
|
2007-03-31 18:01:37 -04:00
|
|
|
pool_free_to(s->fe->rsp_cap_pool, txn->rsp.cap);
|
2006-06-25 20:48:02 -04:00
|
|
|
}
|
2007-03-03 10:23:22 -05:00
|
|
|
if (txn->req.cap != NULL) {
|
2006-06-25 20:48:02 -04:00
|
|
|
struct cap_hdr *h;
|
2007-03-31 18:01:37 -04:00
|
|
|
for (h = s->fe->req_cap; h; h = h->next) {
|
2007-03-03 10:23:22 -05:00
|
|
|
if (txn->req.cap[h->index] != NULL)
|
|
|
|
|
pool_free_to(h->pool, txn->req.cap[h->index]);
|
2006-06-25 20:48:02 -04:00
|
|
|
}
|
2007-03-31 18:01:37 -04:00
|
|
|
pool_free_to(s->fe->req_cap_pool, txn->req.cap);
|
2006-06-25 20:48:02 -04:00
|
|
|
}
|
|
|
|
|
|
2007-03-18 12:31:28 -04:00
|
|
|
if (txn->uri)
|
|
|
|
|
pool_free(requri, txn->uri);
|
|
|
|
|
if (txn->cli_cookie)
|
|
|
|
|
pool_free(capture, txn->cli_cookie);
|
|
|
|
|
if (txn->srv_cookie)
|
|
|
|
|
pool_free(capture, txn->srv_cookie);
|
2006-06-25 20:48:02 -04:00
|
|
|
|
2007-05-13 13:43:47 -04:00
|
|
|
pool_free2(pool2_session, s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* perform minimal intializations, report 0 in case of error, 1 if OK. */
|
|
|
|
|
int init_session()
|
|
|
|
|
{
|
|
|
|
|
pool2_session = create_pool("session", sizeof(struct session), MEM_F_SHARED);
|
|
|
|
|
return pool2_session != NULL;
|
2006-06-25 20:48:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Local variables:
|
|
|
|
|
* c-indent-level: 8
|
|
|
|
|
* c-basic-offset: 8
|
|
|
|
|
* End:
|
|
|
|
|
*/
|