From 2d65e3d5bded0bbe36b98caa2469abd23a9d2de0 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 4 Apr 2011 11:58:07 +0200 Subject: omfwd: made send function handling incomplete sends correctly --- tools/omfwd.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'tools/omfwd.c') diff --git a/tools/omfwd.c b/tools/omfwd.c index 0957c77d..be13bf75 100644 --- a/tools/omfwd.c +++ b/tools/omfwd.c @@ -306,22 +306,17 @@ static rsRetVal TCPSendBuf(instanceData *pData, uchar *buf, unsigned len) { DEFiRet; + unsigned alreadySent; ssize_t lenSend; - lenSend = len; + alreadySent = 0; dbgprintf("omfwd: XXXX: pData %p, pNetStrm %p\n", pData, pData->pNetstrm); netstrm.CheckConnection(pData->pNetstrm); /* hack for plain tcp syslog - see ptcp driver for details */ - CHKiRet(netstrm.Send(pData->pNetstrm, buf, &lenSend)); - DBGPRINTF("omfwd: TCP sent %ld bytes, requested %u\n", (long) lenSend, len); - - if(lenSend != len) { - /* no real error, could "just" not send everything... - * For the time being, we ignore this... - * rgerhards, 2005-10-25 - */ - dbgprintf("message not completely (tcp)send, ignoring %ld\n", (long) lenSend); - usleep(1000); /* experimental - might be benefitial in this situation */ - /* TODO: we need to revisit this code -- rgerhards, 2007-12-28 */ + while(alreadySent != len) { + lenSend = len - alreadySent; + CHKiRet(netstrm.Send(pData->pNetstrm, buf+alreadySent, &lenSend)); + DBGPRINTF("omfwd: TCP sent %ld bytes, requested %u\n", (long) lenSend, len - alreadySent); + alreadySent += lenSend; } finalize_it: -- cgit