From 9042060b0b6e610d6770b082346e93a55f88e5f2 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 18 Jul 2019 15:09:57 +0200 Subject: [PATCH] MINOR: stream: add a new target_addr entry in the stream structure The purpose will be to store the target address there and not to allocate a connection just for this anymore. For now it's only placed in the struct, a few fields were moved to plug some holes, and the entry is freed on release (never allocated yet for now). This must have no impact. Note that in order to fit, the store_count which previously was an int was turned into a short, which is way more than enough given that the hard-coded limit is 8. --- include/types/stream.h | 9 +++++---- src/stream.c | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/types/stream.h b/include/types/stream.h index c88934545..eb31f068b 100644 --- a/include/types/stream.h +++ b/include/types/stream.h @@ -148,15 +148,16 @@ struct stream { struct freq_ctr call_rate; /* stream task call rate */ + short store_count; + enum obj_type obj_type; /* object type == OBJ_TYPE_STREAM */ + /* 1 unused bytes here */ + struct { struct stksess *ts; struct stktable *table; } store[8]; /* tracked stickiness values to store */ - int store_count; - - enum obj_type obj_type; /* object type == OBJ_TYPE_STREAM */ - /* 3 unused bytes here */ + struct sockaddr_storage *target_addr; /* the address to join if not null */ struct stkctr stkctr[MAX_SESS_STKCTR]; /* content-aware stick counters */ struct strm_flt strm_flt; /* current state of filters active on this stream */ diff --git a/src/stream.c b/src/stream.c index 0be175725..80120d0ef 100644 --- a/src/stream.c +++ b/src/stream.c @@ -270,6 +270,7 @@ struct stream *stream_new(struct session *sess, enum obj_type *origin) stream_init_srv_conn(s); s->target = sess->listener ? sess->listener->default_target : NULL; + s->target_addr = NULL; s->pend_pos = NULL; s->priority_class = 0; @@ -487,6 +488,7 @@ static void stream_free(struct stream *s) session_free(sess); } + sockaddr_free(&s->target_addr); pool_free(pool_head_stream, s); /* We may want to free the maximum amount of pools if the proxy is stopping */