From b2bf8331fb3b278a8804611d47751d76e8afae1b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 4 Apr 2015 15:58:58 +0200 Subject: [PATCH] MINOR: session: add stick counters to the struct session The stick counters in the session will be used for everything not related to contents, hence the connections / concurrent sessions / etc. They will be usable by "tcp-request connection" rules even without a stream. For now they're just allocated and initialized. --- include/types/session.h | 1 + include/types/stream.h | 2 +- src/hlua.c | 2 ++ src/peers.c | 1 + src/stream.c | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/types/session.h b/include/types/session.h index e4e393b101..45d2df1fbb 100644 --- a/include/types/session.h +++ b/include/types/session.h @@ -41,6 +41,7 @@ struct session { enum obj_type *origin; /* the connection / applet which initiated this session */ struct timeval accept_date; /* date of the session's accept() in user date */ struct timeval tv_accept; /* date of the session's accept() in internal date (monotonic) */ + struct stkctr stkctr[MAX_SESS_STKCTR]; /* stick counters for tcp-connection */ }; #endif /* _TYPES_SESSION_H */ diff --git a/include/types/stream.h b/include/types/stream.h index b83f65588c..be285683d6 100644 --- a/include/types/stream.h +++ b/include/types/stream.h @@ -139,7 +139,7 @@ struct stream { int store_count; /* 4 unused bytes here */ - struct stkctr stkctr[MAX_SESS_STKCTR]; /* stick counters */ + struct stkctr stkctr[MAX_SESS_STKCTR]; /* content-aware stick counters */ char **req_cap; /* array of captures from the request (may be NULL) */ char **res_cap; /* array of captures from the response (may be NULL) */ diff --git a/src/hlua.c b/src/hlua.c index 7df8778eb7..cbc0fdedd6 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -2035,6 +2035,8 @@ __LJMP static int hlua_socket_new(lua_State *L) sess->accept_date = date; /* user-visible date for logging */ sess->tv_accept = now; /* corrected date for internal use */ + memset(sess->stkctr, 0, sizeof(sess->stkctr)); + socket->s = pool_alloc2(pool2_stream); if (!socket->s) { hlua_pusherror(L, "socket: out of memory"); diff --git a/src/peers.c b/src/peers.c index df4ecf8893..57954d74a0 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1127,6 +1127,7 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session sess->fe = p; sess->accept_date = date; /* user-visible date for logging */ sess->tv_accept = now; /* corrected date for internal use */ + memset(sess->stkctr, 0, sizeof(sess->stkctr)); if ((s = pool_alloc2(pool2_stream)) == NULL) { /* disable this proxy for a while */ Alert("out of memory in peer_session_create().\n"); diff --git a/src/stream.c b/src/stream.c index 6730ad47de..e21a2a5834 100644 --- a/src/stream.c +++ b/src/stream.c @@ -107,6 +107,7 @@ int stream_accept(struct listener *l, int cfd, struct sockaddr_storage *addr) sess->origin = &cli_conn->obj_type; sess->accept_date = date; /* user-visible date for logging */ sess->tv_accept = now; /* corrected date for internal use */ + memset(sess->stkctr, 0, sizeof(sess->stkctr)); if (unlikely((s = pool_alloc2(pool2_stream)) == NULL)) goto out_free_sess; -- 2.47.3