Commit 84ebe208 authored by Grigorii Demidov's avatar Grigorii Demidov

daemon: TCP connection timeouting has changed; connection was closed after...

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
parent b6a4f0d9
Pipeline #41485 passed with stages
in 95 minutes
......@@ -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;
......
......@@ -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;
}
......@@ -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);
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment