This is where we'll put some session-wide information.
}
pool_destroy2(pool2_stream);
+ pool_destroy2(pool2_session);
pool_destroy2(pool2_connection);
pool_destroy2(pool2_buffer);
pool_destroy2(pool2_requri);
#include <proto/raw_sock.h>
#include <proto/sample.h>
#include <proto/server.h>
+#include <proto/session.h>
#include <proto/stream.h>
#include <proto/ssl_sock.h>
#include <proto/stream_interface.h>
* Get memory for the request.
*
*/
+ socket->s->sess = pool_alloc2(pool2_session);
+ if (!socket->s->sess) {
+ hlua_pusherror(L, "socket: out of memory");
+ goto out_fail_conf;
+ }
socket->s = pool_alloc2(pool2_stream);
if (!socket->s) {
hlua_pusherror(L, "socket: out of memory");
- goto out_fail_conf;
+ goto out_fail_stream;
}
socket->s->task = task_new();
if (!socket->s->task) {
hlua_pusherror(L, "socket: out of memory");
- goto out_free_session;
+ goto out_fail_task;
}
socket->s->req.buf = pool_alloc2(pool2_buffer);
/* The stream dont have listener. The listener is used with real
* proxies.
*/
- socket->s->sess = NULL;
socket->s->listener = NULL;
/* The flags are initialized to 0. Values are setted later. */
pool_free2(pool2_buffer, socket->s->req.buf);
out_fail_req_buf:
task_free(socket->s->task);
-out_free_session:
+out_fail_task:
pool_free2(pool2_stream, socket->s);
+out_fail_stream:
+ pool_free2(pool2_session, socket->s->sess);
out_fail_conf:
WILL_LJMP(lua_error(L));
return 0;
#include <proto/proto_tcp.h>
#include <proto/proto_http.h>
#include <proto/proxy.h>
+#include <proto/session.h>
#include <proto/stream.h>
#include <proto/signal.h>
#include <proto/stick_table.h>
*/
if ((t = task_new()) == NULL) { /* disable this proxy for a while */
Alert("out of memory in peer_session_create().\n");
- goto out_free_session;
+ goto out_free_stream;
}
ps->reconnect = tick_add(now_ms, MS_TO_TICKS(5000));
s->task = t;
s->listener = l;
- s->sess = NULL;
+ s->sess = pool_alloc2(pool2_session);
+ if (!s->sess) {
+ Alert("out of memory in peer_session_create().\n");
+ goto out_free_task;
+ }
/* Note: initially, the stream's backend points to the frontend.
* This changes later when switching rules are executed or
/* Error unrolling */
out_fail_conn1:
+ pool_free2(pool2_session, s->sess);
+ out_free_task:
task_free(t);
- out_free_session:
+ out_free_stream:
LIST_DEL(&s->list);
pool_free2(pool2_stream, s);
out_close:
#include <proto/listener.h>
#include <proto/log.h>
#include <proto/raw_sock.h>
+#include <proto/session.h>
#include <proto/stream.h>
#include <proto/pipe.h>
#include <proto/proto_http.h>
memset(s->stkctr, 0, sizeof(s->stkctr));
- s->sess = NULL;
+ s->sess = pool_alloc2(pool2_session);
+ if (!s->sess)
+ goto out_free_stream;
+
s->listener = l;
s->fe = p;
out_free_task:
task_free(t);
out_free_session:
+ pool_free2(pool2_session, s->sess);
+ out_free_stream:
p->feconn--;
stream_store_counters(s);
pool_free2(pool2_stream, s);
task_delete(s->task);
task_free(s->task);
+ /* FIXME: for now we have a 1:1 relation between stream and session so
+ * the stream must free the session.
+ */
+ pool_free2(pool2_session, s->sess);
pool_free2(pool2_stream, s);
}
LIST_DEL(&s->list);
si_release_endpoint(&s->si[1]);
si_release_endpoint(&s->si[0]);
+
+ /* FIXME: for now we have a 1:1 relation between stream and session so
+ * the stream must free the session.
+ */
+ pool_free2(pool2_session, s->sess);
pool_free2(pool2_stream, s);
/* We may want to free the maximum amount of pools if the proxy is stopping */
pool_flush2(pool2_requri);
pool_flush2(pool2_capture);
pool_flush2(pool2_stream);
+ pool_flush2(pool2_session);
pool_flush2(pool2_connection);
pool_flush2(pool2_pendconn);
pool_flush2(fe->req_cap_pool);