From e18f3fd003ca170f41407df12cd72484272b9df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 20 Oct 2020 20:57:19 +0200 Subject: [PATCH] Explicitly stop reading before closing the nmtcpsocket When closing the socket that is actively reading from the stream, the read_cb() could be called between uv_close() and close callback when the server socket has been already detached hence using sock->statichandle after it has been already freed. (cherry picked from commit 97b33e5bde296feb82c1d8bb703e56c1b224e129) --- lib/isc/netmgr/tcp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index 7aea161a9f..c416deb5d7 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -1115,6 +1115,9 @@ tcp_close_direct(isc_nmsocket_t *sock) { if (sock->quota != NULL) { isc_quota_detach(&sock->quota); } + + uv_read_stop((uv_stream_t *)&sock->uv_handle.handle); + if (sock->timer_initialized) { sock->timer_initialized = false; uv_timer_stop(&sock->timer);