Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
| 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 Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 14 | |
| 15 | #include <common/config.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 16 | #include <common/memory.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 17 | |
| 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 | |
| 28 | void **pool_session = NULL; |
| 29 | |
| 30 | /* |
| 31 | * frees the context associated to a session. It must have been removed first. |
| 32 | */ |
| 33 | void session_free(struct session *s) |
| 34 | { |
| 35 | if (s->pend_pos) |
| 36 | pendconn_free(s->pend_pos); |
| 37 | if (s->req) |
| 38 | pool_free(buffer, s->req); |
| 39 | if (s->rep) |
| 40 | pool_free(buffer, s->rep); |
| 41 | |
Willy Tarreau | 41dff82 | 2007-01-01 23:32:30 +0100 | [diff] [blame^] | 42 | if (s->hreq.hdr_idx.v != NULL) |
| 43 | pool_free_to(s->fe->hdr_idx_pool, s->hreq.hdr_idx.v); |
| 44 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 45 | if (s->rsp_cap != NULL) { |
| 46 | struct cap_hdr *h; |
Willy Tarreau | 830ff45 | 2006-12-17 19:31:23 +0100 | [diff] [blame] | 47 | for (h = s->fe->fiprm->rsp_cap; h; h = h->next) { |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 48 | if (s->rsp_cap[h->index] != NULL) |
| 49 | pool_free_to(h->pool, s->rsp_cap[h->index]); |
| 50 | } |
Willy Tarreau | 830ff45 | 2006-12-17 19:31:23 +0100 | [diff] [blame] | 51 | pool_free_to(s->fe->fiprm->rsp_cap_pool, s->rsp_cap); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 52 | } |
Willy Tarreau | 45e73e3 | 2006-12-17 00:05:15 +0100 | [diff] [blame] | 53 | if (s->hreq.cap != NULL) { |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 54 | struct cap_hdr *h; |
Willy Tarreau | 830ff45 | 2006-12-17 19:31:23 +0100 | [diff] [blame] | 55 | for (h = s->fe->fiprm->req_cap; h; h = h->next) { |
Willy Tarreau | 45e73e3 | 2006-12-17 00:05:15 +0100 | [diff] [blame] | 56 | if (s->hreq.cap[h->index] != NULL) |
| 57 | pool_free_to(h->pool, s->hreq.cap[h->index]); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 58 | } |
Willy Tarreau | 830ff45 | 2006-12-17 19:31:23 +0100 | [diff] [blame] | 59 | pool_free_to(s->fe->fiprm->req_cap_pool, s->hreq.cap); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | if (s->logs.uri) |
| 63 | pool_free(requri, s->logs.uri); |
| 64 | if (s->logs.cli_cookie) |
| 65 | pool_free(capture, s->logs.cli_cookie); |
| 66 | if (s->logs.srv_cookie) |
| 67 | pool_free(capture, s->logs.srv_cookie); |
| 68 | |
| 69 | pool_free(session, s); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | /* |
| 74 | * Local variables: |
| 75 | * c-indent-level: 8 |
| 76 | * c-basic-offset: 8 |
| 77 | * End: |
| 78 | */ |