diff options
author | Vladimír Čunát <vladimir.cunat@nic.cz> | 2021-06-01 16:26:04 +0200 |
---|---|---|
committer | Tomas Krizek <tomas.krizek@nic.cz> | 2021-06-18 10:33:14 +0200 |
commit | 5b2ba2d21dd844771586f96d496335ec037dbf1c (patch) | |
tree | 0608f57aa0da2891629f8dd330428bae0c7c9728 /daemon/worker.c | |
parent | Merge branch 'ci-centos8' into 'master' (diff) | |
download | knot-resolver-5b2ba2d21dd844771586f96d496335ec037dbf1c.tar.xz knot-resolver-5b2ba2d21dd844771586f96d496335ec037dbf1c.zip |
daemon/worker: fix a memory leak
Discovered case: TCP write towards upstream fails due to ECONNRESET,
and on this place of code we "forget" the whole qr_task and thus its
corresponding kr_request, so it remains unanswered and using memory.
Diffstat (limited to '')
-rw-r--r-- | daemon/worker.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/daemon/worker.c b/daemon/worker.c index f1ade4d2..b97a66c2 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -633,8 +633,22 @@ int qr_task_on_send(struct qr_task *task, const uv_handle_t *handle, int status) } if (handle->type == UV_TCP) { - if (status != 0) - session_tasklist_del(s, task); + if (status != 0) { // session probably not usable anymore; typically: ECONNRESET + if (VERBOSE_STATUS) { + const char *peer_str = NULL; + if (!session_flags(s)->outgoing) { + peer_str = "hidden"; // avoid logging downstream IPs + } else if (task->transport) { + peer_str = kr_straddr(&task->transport->address.ip); + } + if (!peer_str) + peer_str = "unknown"; // probably shouldn't happen + kr_log_verbose( "[wrkr]=> disconnected from '%s': %s\n", + peer_str, uv_strerror(status)); + } + worker_end_tcp(s); + return status; + } if (session_flags(s)->outgoing || session_flags(s)->closing) return status; |