From: Grigorii Demidov Date: Mon, 22 Oct 2018 08:48:51 +0000 (+0200) Subject: daemon: TCP connection timeouting has changed; connection was closed after peer's... X-Git-Tag: v3.1.0~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84ebe2089561af643e2d6e42a89721a4b7e2b0f8;p=thirdparty%2Fknot-resolver.git daemon: TCP connection timeouting has changed; connection was closed after peer's inactivity before, now it is closed after incativity in both directions (peer->kresd, kresd->peer); prevents connection from closing before answer sent to client --- diff --git a/daemon/io.c b/daemon/io.c index 30d3723ce..9087f64fd 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -169,7 +169,7 @@ void tcp_timeout_trigger(uv_timer_t *timer) const struct engine *engine = worker->engine; const struct network *net = &engine->net; uint64_t idle_in_timeout = net->tcp.in_idle_timeout; - uint64_t last_activity = session_last_input_activity(s); + uint64_t last_activity = session_last_activity(s); uint64_t idle_time = kr_now() - last_activity; if (idle_time < idle_in_timeout) { idle_in_timeout -= idle_time; diff --git a/daemon/session.c b/daemon/session.c index 1756b630d..a869d6db8 100644 --- a/daemon/session.c +++ b/daemon/session.c @@ -45,7 +45,8 @@ struct session { ssize_t wire_buf_size; /**< Buffer size. */ ssize_t wire_buf_start_idx; /**< Data start offset in wire_buf. */ ssize_t wire_buf_end_idx; /**< Data end offset in wire_buf. */ - uint64_t last_input_activity; /**< Either creatoion time or time of peer's last activity */ + uint64_t last_activity; /**< Time of last IO activity (if any occurs). + * Otherwise session creation time. */ }; static void on_session_close(uv_handle_t *handle) @@ -746,10 +747,10 @@ void session_kill_ioreq(struct session *s, struct qr_task *task) /** Update timestamp */ void session_touch(struct session *s) { - s->last_input_activity = kr_now(); + s->last_activity = kr_now(); } -uint64_t session_last_input_activity(struct session *s) +uint64_t session_last_activity(struct session *s) { - return s->last_input_activity; + return s->last_activity; } diff --git a/daemon/session.h b/daemon/session.h index 5855be0a1..a537213e0 100644 --- a/daemon/session.h +++ b/daemon/session.h @@ -143,4 +143,6 @@ int session_discard_packet(struct session *session, const knot_pkt_t *pkt); void session_kill_ioreq(struct session *s, struct qr_task *task); /** Update timestamp */ void session_touch(struct session *s); -uint64_t session_last_input_activity(struct session *s); +/** Returns either creation time or time of last IO activity if any occurs. */ +/* Used for TCP timeout calculation. */ +uint64_t session_last_activity(struct session *s); diff --git a/daemon/worker.c b/daemon/worker.c index 4412305e1..8a885d228 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -655,6 +655,7 @@ static int qr_task_send(struct qr_task *task, struct session *session, } if (ret == 0) { + session_touch(session); if (session_flags(session)->outgoing) { session_tasklist_add(session, task); }