Ai
9 Star 1 Fork 41

src-openEuler/rsyslog
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
backport-network-subsystem-improve-connection-failure-error-m.patch 1.60 KB
一键复制 编辑 原始数据 按行查看 历史
Qiumiao Zhang 提交于 2024-12-21 16:24 +08:00 . backport some patches from upstream
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/rsyslog.git
git@gitee.com:src-openeuler/rsyslog.git
src-openeuler
rsyslog
rsyslog
master

搜索帮助