From c4ad0466d64dceae38e000d9fca7f4acd23f1370 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Thu, 21 Nov 2019 18:38:04 -0800 Subject: [PATCH] netmgr: log TCP connection errors --- lib/isc/include/isc/log.h | 3 ++- lib/isc/log.c | 1 + lib/isc/netmgr/tcp.c | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/isc/include/isc/log.h b/lib/isc/include/isc/log.h index d2d2886161..2251a42837 100644 --- a/lib/isc/include/isc/log.h +++ b/lib/isc/include/isc/log.h @@ -177,7 +177,8 @@ LIBISC_EXTERNAL_DATA extern isc_logmodule_t isc_modules[]; #define ISC_LOGMODULE_INTERFACE (&isc_modules[2]) #define ISC_LOGMODULE_TIMER (&isc_modules[3]) #define ISC_LOGMODULE_FILE (&isc_modules[4]) -#define ISC_LOGMODULE_OTHER (&isc_modules[5]) +#define ISC_LOGMODULE_NETMGR (&isc_modules[5]) +#define ISC_LOGMODULE_OTHER (&isc_modules[6]) ISC_LANG_BEGINDECLS diff --git a/lib/isc/log.c b/lib/isc/log.c index 0af599f8c2..3d60ca2fad 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -192,6 +192,7 @@ LIBISC_EXTERNAL_DATA isc_logmodule_t isc_modules[] = { { "interface", 0 }, { "timer", 0 }, { "file", 0 }, + { "netmgr", 0 }, { "other", 0 }, { NULL, 0 } }; diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index c400866db7..56e8600f57 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -500,15 +501,19 @@ accept_connection(isc_nmsocket_t *ssock) { static void tcp_connection_cb(uv_stream_t *server, int status) { isc_nmsocket_t *ssock = server->data; - isc_result_t result = accept_connection(ssock); + isc_result_t result; UNUSED(status); + result = accept_connection(ssock); if (result != ISC_R_SUCCESS) { if (result == ISC_R_QUOTA || result == ISC_R_SOFTQUOTA) { ssock->overquota = true; } - /* TODO: Log the error. */ + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR, + "TCP connection failed: %s", + isc_result_totext(result)); } }