mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MINOR: session: start to reintroduce struct session
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.
This commit is contained in:
parent
e7dff02dd4
commit
b1ec8c4a59
2
Makefile
2
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
|
||||
|
43
include/proto/session.h
Normal file
43
include/proto/session.h
Normal file
@ -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:
|
||||
*/
|
@ -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)
|
||||
{
|
||||
|
48
include/types/session.h
Normal file
48
include/types/session.h
Normal file
@ -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:
|
||||
*/
|
@ -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 */
|
||||
|
@ -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();
|
||||
|
@ -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. */
|
||||
|
@ -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
|
||||
|
35
src/session.c
Normal file
35
src/session.c
Normal file
@ -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:
|
||||
*/
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user