]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: frontend: move some stream initialisation to stream_new()
authorWilly Tarreau <w@1wt.eu>
Sun, 5 Apr 2015 10:03:54 +0000 (12:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Apr 2015 09:37:35 +0000 (11:37 +0200)
This is mostly what is related to logging, and which is more of
a stream initialization than anything frontend-specific.

src/frontend.c
src/stream.c

index a4941d3a59ddc504e654a9c3409bdf775b15eaf2..b7f4e194c630568ca4b528c0770c45821ed5b95a 100644 (file)
@@ -60,23 +60,6 @@ int frontend_accept(struct stream *s)
 
        int cfd = conn->t.sock.fd;
 
-       tv_zero(&s->logs.tv_request);
-       s->logs.t_queue = -1;
-       s->logs.t_connect = -1;
-       s->logs.t_data = -1;
-       s->logs.t_close = 0;
-       s->logs.bytes_in = s->logs.bytes_out = 0;
-       s->logs.prx_queue_size = 0;  /* we get the number of pending conns before us */
-       s->logs.srv_queue_size = 0; /* we will get this number soon */
-
-       /* FIXME: the logs are horribly complicated now, because they are
-        * defined in <p>, <p>, and later <be> and <be>.
-        */
-       s->do_log = strm_log;
-
-       /* default error reporting function, may be changed by analysers */
-       s->srv_error = default_srv_error;
-
        /* Adjust some socket options */
        if (l->addr.ss_family == AF_INET || l->addr.ss_family == AF_INET6) {
                if (setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY,
index 3e2b5b663aa27a16b4d444104514d3ea038c913f..5a021aac4540840162e09aceb62af8b9b90f7ef7 100644 (file)
@@ -83,6 +83,22 @@ struct stream *stream_new(struct session *sess, struct task *t)
        s->flags = 0;
        s->logs.logwait = p->to_log;
        s->logs.level = 0;
+       s->logs.accept_date = sess->accept_date; /* user-visible date for logging */
+       s->logs.tv_accept = sess->tv_accept;   /* corrected date for internal use */
+       tv_zero(&s->logs.tv_request);
+       s->logs.t_queue = -1;
+       s->logs.t_connect = -1;
+       s->logs.t_data = -1;
+       s->logs.t_close = 0;
+       s->logs.bytes_in = s->logs.bytes_out = 0;
+       s->logs.prx_queue_size = 0;  /* we get the number of pending conns before us */
+       s->logs.srv_queue_size = 0; /* we will get this number soon */
+
+       /* default logging function */
+       s->do_log = strm_log;
+
+       /* default error reporting function, may be changed by analysers */
+       s->srv_error = default_srv_error;
 
        /* Initialise the current rule list pointer to NULL. We are sure that
         * any rulelist match the NULL pointer.
@@ -95,8 +111,6 @@ struct stream *stream_new(struct session *sess, struct task *t)
        s->si[0].flags = SI_FL_NONE;
        s->si[1].flags = SI_FL_ISBACK;
 
-       s->logs.accept_date = sess->accept_date; /* user-visible date for logging */
-       s->logs.tv_accept = sess->tv_accept;   /* corrected date for internal use */
        s->uniq_id = global.req_count++;
 
        /* OK, we're keeping the stream, so let's properly initialize the stream */