From 56571d5879cf734770194ea975416883a5007cc5 Mon Sep 17 00:00:00 2001 From: schmirl Date: Mon, 15 Jan 2007 11:41:46 +0000 Subject: [PATCH] Log throttle for connection failure messages (#183) --- client/socket.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/socket.c b/client/socket.c index d814d9d..40772d6 100644 --- a/client/socket.c +++ b/client/socket.c @@ -1,5 +1,5 @@ /* - * $Id: socket.c,v 1.5 2007/01/15 11:36:37 schmirl Exp $ + * $Id: socket.c,v 1.6 2007/01/15 11:41:46 schmirl Exp $ */ #include @@ -7,6 +7,9 @@ #include #include #include +#include + +#define MINLOGREPEAT 10 //don't log connect failures too often (seconds) #include "client/socket.h" #include "client/setup.h" @@ -111,9 +114,13 @@ bool cClientSocket::CheckConnection(void) { } if (!Connect(StreamdevClientSetup.RemoteIp, StreamdevClientSetup.RemotePort)){ - esyslog("ERROR: Streamdev: Couldn't connect to %s:%d: %s", + static time_t lastTime = 0; + if (time(NULL) - lastTime > MINLOGREPEAT) { + esyslog("ERROR: Streamdev: Couldn't connect to %s:%d: %s", (const char*)StreamdevClientSetup.RemoteIp, StreamdevClientSetup.RemotePort, strerror(errno)); + lastTime = time(NULL); + } return false; }