代码拉取完成,页面将自动刷新
From 9ac56b28614f1bdbe147181471a6688f4f418e9f Mon Sep 17 00:00:00 2001
From: Rainer Gerhards <rgerhards@adiscon.com>
Date: Sun, 15 Sep 2024 15:24:28 +0200
Subject: [PATCH] network subsystem: improve connection failure error message
If we try to connect via TCP and the connections fails, we now
tell inside the error message how long the connection attempt
took. This is useful to find out if targets connect very
slowly.
---
runtime/nsd_ptcp.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/runtime/nsd_ptcp.c b/runtime/nsd_ptcp.c
index e1c1de957..8549d5aaa 100644
--- a/runtime/nsd_ptcp.c
+++ b/runtime/nsd_ptcp.c
@@ -37,6 +37,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <netinet/tcp.h>
+#include <sys/time.h>
#include "rsyslog.h"
#include "syslogd-types.h"
@@ -73,6 +74,7 @@ DEFobjCurrIf(prop)
static void
sockClose(int *pSock)
{
+ fprintf(stderr, "nsd_ptcp: closing socket %d\n", *pSock);
if(*pSock >= 0) {
close(*pSock);
*pSock = -1;
@@ -956,9 +958,15 @@ Connect(nsd_t *pNsd, int family, uchar *port, uchar *host, char *device)
}
}
+ struct timeval start, end;
+ long seconds, useconds;
+ gettimeofday(&start, NULL);
if(connect(pThis->sock, res->ai_addr, res->ai_addrlen) != 0) {
- LogError(errno, RS_RET_IO_ERROR, "cannot connect to %s:%s",
- host, port);
+ gettimeofday(&end, NULL);
+ seconds = end.tv_sec - start.tv_sec;
+ useconds = end.tv_usec - start.tv_usec;
+ LogError(errno, RS_RET_IO_ERROR, "cannot connect to %s:%s (took %ld.%ld seconds)",
+ host, port, seconds, useconds / 10000);
ABORT_FINALIZE(RS_RET_IO_ERROR);
}
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。