From: Willy Tarreau Date: Sun, 5 Apr 2015 10:03:54 +0000 (+0200) Subject: MEDIUM: frontend: move some stream initialisation to stream_new() X-Git-Tag: v1.6-dev2~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99eb0f13bc08311912cec6e6b0893f634b78664c;p=thirdparty%2Fhaproxy.git MEDIUM: frontend: move some stream initialisation to stream_new() This is mostly what is related to logging, and which is more of a stream initialization than anything frontend-specific. --- diff --git a/src/frontend.c b/src/frontend.c index a4941d3a59..b7f4e194c6 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -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

,

, and later and . - */ - 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, diff --git a/src/stream.c b/src/stream.c index 3e2b5b663a..5a021aac45 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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 */