]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: add a new target_addr entry in the stream structure
authorWilly Tarreau <w@1wt.eu>
Thu, 18 Jul 2019 13:09:57 +0000 (15:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 19 Jul 2019 11:50:09 +0000 (13:50 +0200)
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
src/stream.c

index c8893454570b1f21dcd38b26180e571dadc2a247..eb31f068bf7633854ab3fe99599990f10f5ed546 100644 (file)
@@ -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 */
index 0be17572514e9fec79581add974943f33c59f2e8..80120d0ef1195bf1e9de245aad84d3392535730a 100644 (file)
@@ -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 */