diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-04-04 11:58:07 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-04-04 11:58:07 +0200 |
commit | 2d65e3d5bded0bbe36b98caa2469abd23a9d2de0 (patch) | |
tree | 97be8c83730e867f80d7b2b1c5728bbf26a9bb43 /tools/omfwd.c | |
parent | d4cc262156a899805323b0273e48246769201db4 (diff) | |
download | rsyslog-2d65e3d5bded0bbe36b98caa2469abd23a9d2de0.tar.gz rsyslog-2d65e3d5bded0bbe36b98caa2469abd23a9d2de0.tar.xz rsyslog-2d65e3d5bded0bbe36b98caa2469abd23a9d2de0.zip |
omfwd: made send function handling incomplete sends correctly
Diffstat (limited to 'tools/omfwd.c')
-rw-r--r-- | tools/omfwd.c | 19 |
1 files changed, 7 insertions, 12 deletions
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: |