summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-06-09 12:40:54 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-06-09 12:40:54 +0200
commit55e01da2ec3de1b5c6b15e4154235f0eedbb68da (patch)
treefe7b9b9b114c982d1453a363499bad9fa323fd1a /tools
parentcf51333f7617e586ca1d4cf5202e3d42f14c96ea (diff)
downloadrsyslog-55e01da2ec3de1b5c6b15e4154235f0eedbb68da.tar.gz
rsyslog-55e01da2ec3de1b5c6b15e4154235f0eedbb68da.tar.xz
rsyslog-55e01da2ec3de1b5c6b15e4154235f0eedbb68da.zip
somewhat improved plain tcp syslog reliability
...by doing a connection check before sending. Credits to Martin Schuette for providing the idea. Details are available at http://blog.gerhards.net/2008/06/reliable-plain-tcp-syslog-once-again.html
Diffstat (limited to 'tools')
-rw-r--r--tools/omfwd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/omfwd.c b/tools/omfwd.c
index 317bc298..1783ef7d 100644
--- a/tools/omfwd.c
+++ b/tools/omfwd.c
@@ -97,7 +97,8 @@ typedef struct _instanceData {
/* config data */
static uchar *pszTplName = NULL; /* name of the default template to use */
static uchar *pszStrmDrvr = NULL; /* name of the stream driver to use */
-static int iStrmDrvrMode = 0; /* mode for stream driver, driver-dependent (0 mostly means plain tcp) */
+static short iStrmDrvrMode = 0; /* mode for stream driver, driver-dependent (0 mostly means plain tcp) */
+static short bResendLastOnRecon = 0; /* should the last message be re-sent on a successful reconnect? */
static uchar *pszStrmDrvrAuthMode = NULL; /* authentication mode to use */
static permittedPeers_t *pPermPeers = NULL;
@@ -254,6 +255,7 @@ static rsRetVal TCPSendFrame(void *pvData, char *msg, size_t len)
instanceData *pData = (instanceData *) pvData;
lenSend = len;
+ netstrm.CheckConnection(pData->pNetstrm); /* hack for plain tcp syslog - see ptcp driver for details */
CHKiRet(netstrm.Send(pData->pNetstrm, (uchar*)msg, &lenSend));
dbgprintf("TCP sent %ld bytes, requested %ld\n", (long) lenSend, (long) len);
@@ -605,6 +607,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
if(pData->protocol == FORW_TCP) {
/* create our tcpclt */
CHKiRet(tcpclt.Construct(&pData->pTCPClt));
+ CHKiRet(tcpclt.SetResendLastOnRecon(pData->pTCPClt, bResendLastOnRecon));
/* and set callbacks */
CHKiRet(tcpclt.SetSendInit(pData->pTCPClt, TCPSendInit));
CHKiRet(tcpclt.SetSendFrame(pData->pTCPClt, TCPSendFrame));
@@ -679,6 +682,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
/* we now must reset all non-string values */
iStrmDrvrMode = 0;
+ bResendLastOnRecon = 0;
return RS_RET_OK;
}
@@ -697,6 +701,7 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(regCfSysLineHdlr((uchar *)"actionsendstreamdrivermode", 0, eCmdHdlrInt, NULL, &iStrmDrvrMode, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"actionsendstreamdriverauthmode", 0, eCmdHdlrGetWord, NULL, &pszStrmDrvrAuthMode, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"actionsendstreamdriverpermittedpeer", 0, eCmdHdlrGetWord, setPermittedPeer, NULL, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionsendresendlastmsgonreconnect", 0, eCmdHdlrBinary, NULL, &bResendLastOnRecon, NULL));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
ENDmodInit