]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: store the default target into the frontend's configuration
authorWilly Tarreau <w@1wt.eu>
Fri, 13 Mar 2015 14:55:16 +0000 (15:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 Mar 2015 15:23:00 +0000 (16:23 +0100)
Some services such as peers and CLI pre-set the target applet immediately
during accept(), and for this reason they're forced to have a dedicated
accept() function which does not even properly follow everything the regular
one does (eg: sndbuf/rcvbuf/linger/nodelay are not set, etc).

Let's store the default target when known into the frontend's config so that
it's session_accept() which automatically sets it.

include/types/proxy.h
src/dumpstats.c
src/peers.c
src/session.c

index 30409f9f037042233a64ad5f371adba77cffc99a..0cd00eef8618b1bb1fba3a43ee6a0b472b298fc6 100644 (file)
@@ -329,6 +329,7 @@ struct proxy {
        time_t last_change;                     /* last time, when the state was changed */
        int (*accept)(struct session *s);       /* application layer's accept() */
        struct conn_src conn_src;               /* connection source settings */
+       enum obj_type *default_target;          /* default target to use for accepted sessions or NULL */
        struct proxy *next;
 
        unsigned int log_count;                 /* number of logs produced by the frontend */
index 8dd9459ba0da8f0ac33db0b17ed1ef40c5d4a429..50e77ad573f7647cc813920e3e271ff040feb984 100644 (file)
@@ -234,7 +234,6 @@ extern const char *stat_status_codes[];
  */
 static int stats_accept(struct session *s)
 {
-       s->target = &cli_applet.obj_type;
        /* no need to initialize the applet, it will start with st0=st1 = 0 */
 
        tv_zero(&s->logs.tv_request);
@@ -277,6 +276,7 @@ static struct proxy *alloc_stats_fe(const char *name, const char *file, int line
        fe->conf.file = strdup(file);
        fe->conf.line = line;
        fe->accept = stats_accept;
+       fe->default_target = &cli_applet.obj_type;
 
        /* the stats frontend is the only one able to assign ID #0 */
        fe->conf.id.key = fe->uuid = 0;
index 1181aaeacf803647351a633fb5afab570e216a9a..3fc48822c598d463fa47a63310b58f5627f9b349 100644 (file)
@@ -1096,7 +1096,6 @@ static void peer_session_forceshutdown(struct session * session)
  */
 static int peer_accept(struct session *s)
 {
-       s->target = &peer_applet.obj_type;
        /* no need to initialize the applet, it will start with st0=st1 = 0 */
 
        tv_zero(&s->logs.tv_request);
@@ -1126,6 +1125,7 @@ void peers_setup_frontend(struct proxy *fe)
        fe->conn_retries = CONN_RETRIES;
        fe->timeout.client = MS_TO_TICKS(5000);
        fe->accept = peer_accept;
+       fe->default_target = &peer_applet.obj_type;
        fe->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC;
 }
 
index 94fc875b08758e373af6dad4f3c8da13e511c166..7a00b0d5a99b948e16067473d8d6d13b0e53c987 100644 (file)
@@ -481,7 +481,7 @@ int session_complete(struct session *s)
                s->si[1].flags |= SI_FL_INDEP_STR;
 
        session_init_srv_conn(s);
-       s->target = NULL;
+       s->target = p->default_target; /* used by peers and CLI */
        s->pend_pos = NULL;
 
        /* init store persistence */