]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: session: start to reintroduce struct session
authorWilly Tarreau <w@1wt.eu>
Fri, 3 Apr 2015 11:53:24 +0000 (13:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Apr 2015 09:23:57 +0000 (11:23 +0200)
There is now a pointer to the session in the stream, which is NULL
for now. The session pool is created as well. Some parts will move
from the stream to the session now.

Makefile
include/proto/session.h [new file with mode: 0644]
include/proto/stream.h
include/types/session.h [new file with mode: 0644]
include/types/stream.h
src/haproxy.c
src/hlua.c
src/peers.c
src/session.c [new file with mode: 0644]
src/stream.c

index 2f8c2eb06de62b901f7adea798961bf789457c3c..917f023f6644a29050f56fa65684d5e3f4ff4550 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -704,7 +704,7 @@ OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocol.o \
        src/proto_http.o src/raw_sock.o src/appsession.o src/backend.o \
        src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o src/lb_fas.o \
        src/stream_interface.o src/dumpstats.o src/proto_tcp.o \
-       src/stream.o src/hdr_idx.o src/ev_select.o src/signal.o \
+       src/session.o src/stream.o src/hdr_idx.o src/ev_select.o src/signal.o \
        src/acl.o src/sample.o src/memory.o src/freq_ctr.o src/auth.o \
        src/compression.o src/payload.o src/hash.o src/pattern.o src/map.o \
        src/namespace.o src/mailers.o
diff --git a/include/proto/session.h b/include/proto/session.h
new file mode 100644 (file)
index 0000000..79589d3
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * include/proto/session.h
+ * This file defines everything related to sessions.
+ *
+ * Copyright (C) 2000-2015 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _PROTO_SESSION_H
+#define _PROTO_SESSION_H
+
+#include <common/config.h>
+#include <common/buffer.h>
+#include <common/debug.h>
+#include <common/memory.h>
+
+#include <types/global.h>
+#include <types/session.h>
+
+extern struct pool_head *pool2_session;
+int init_session();
+
+#endif /* _PROTO_SESSION_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
index ba2c94367fad95c8a258d50e6aa7db9ba2a4288c..4d234703a90a15f887dfca96cf0d31c71f6815fe 100644 (file)
@@ -62,6 +62,12 @@ int stream_alloc_work_buffer(struct stream *s);
 void stream_release_buffers(struct stream *s);
 int stream_alloc_recv_buffer(struct channel *chn);
 
+/* returns the session this stream belongs to */
+static inline struct session *strm_sess(const struct stream *strm)
+{
+       return strm->sess;
+}
+
 /* sets the stick counter's entry pointer */
 static inline void stkctr_set_entry(struct stkctr *stkctr, struct stksess *entry)
 {
diff --git a/include/types/session.h b/include/types/session.h
new file mode 100644 (file)
index 0000000..c07b46a
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * include/types/session.h
+ * This file defines everything related to sessions.
+ *
+ * Copyright (C) 2000-2015 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _TYPES_SESSION_H
+#define _TYPES_SESSION_H
+
+
+#include <sys/time.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <common/config.h>
+#include <common/mini-clist.h>
+
+#include <types/obj_type.h>
+#include <types/proxy.h>
+#include <types/stick_table.h>
+
+struct session {
+};
+
+#endif /* _TYPES_SESSION_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
index c8c24454798feaf888ee39a93ef31bcca3038dcb..469edc7e0ec30e8c011e5cad71dd1b341037de9b 100644 (file)
@@ -39,6 +39,7 @@
 #include <types/proxy.h>
 #include <types/queue.h>
 #include <types/server.h>
+#include <types/session.h>
 #include <types/stream_interface.h>
 #include <types/task.h>
 #include <types/stick_table.h>
@@ -119,6 +120,8 @@ struct stream {
        struct proxy *fe;               /* the proxy this stream depends on for the client side */
        struct proxy *be;               /* the proxy this stream depends on for the server side */
 
+       struct session *sess;           /* the session this stream is attached to */
+
        struct listener *listener;      /* the listener by which the request arrived */
        struct server *srv_conn;        /* stream already has a slot on a server and is not in queue */
        struct pendconn *pend_pos;      /* if not NULL, points to the position in the pending queue */
index 11b7810383b61c3e16b2f96f11f7936dd5285309..591bb96e6cdd79952b82b11b02c376e4c0ef690e 100644 (file)
@@ -97,6 +97,7 @@
 #include <proto/proxy.h>
 #include <proto/queue.h>
 #include <proto/server.h>
+#include <proto/session.h>
 #include <proto/stream.h>
 #include <proto/signal.h>
 #include <proto/task.h>
@@ -560,6 +561,7 @@ void init(int argc, char **argv)
                exit(1);
        init_task();
        init_stream();
+       init_session();
        init_connection();
        /* warning, we init buffers later */
        init_pendconn();
index a13b8ce1d50d54841899175cc5620cbddaf303a8..cdbce004303e82ee506a98b30a66955a54468310 100644 (file)
@@ -2127,6 +2127,7 @@ __LJMP static int hlua_socket_new(lua_State *L)
        /* 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. */
index 6df3ce7a63be83cf8cd6fdce5bb4c90d049eab4f..0a66010dc11a7b9208c05585b59a0c5e17027505 100644 (file)
@@ -1144,6 +1144,7 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session
 
        s->task = t;
        s->listener = l;
+       s->sess = NULL;
 
        /* Note: initially, the stream's backend points to the frontend.
         * This changes later when switching rules are executed or
diff --git a/src/session.c b/src/session.c
new file mode 100644 (file)
index 0000000..116816f
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Stream management functions.
+ *
+ * Copyright 2000-2012 Willy Tarreau <w@1wt.eu>
+ *
+ * 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 <common/config.h>
+#include <common/buffer.h>
+#include <common/debug.h>
+#include <common/memory.h>
+
+#include <types/global.h>
+#include <types/session.h>
+
+struct pool_head *pool2_session;
+
+/* 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;
+}
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
index 3bc337ea49cb5396d9890ca36026d7eec55410f6..aaea9c08c8159d8b0b7336e5ec50de936289f2cc 100644 (file)
@@ -116,6 +116,7 @@ int stream_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
 
        memset(s->stkctr, 0, sizeof(s->stkctr));
 
+       s->sess = NULL;
        s->listener = l;
        s->fe  = p;