From eb8992a750d9b9d9ff4dd4e66835d01972fc2999 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 19 Sep 2019 12:08:45 +0200 Subject: [PATCH] epicsSocketCountUnsentBytes returns -1 on failure --- src/libCom/log/logClient.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libCom/log/logClient.c b/src/libCom/log/logClient.c index 4e647bd83..476634c5f 100644 --- a/src/libCom/log/logClient.c +++ b/src/libCom/log/logClient.c @@ -226,7 +226,7 @@ static int epicsSocketCountUnsentBytes(SOCKET sock) { if (ioctl(sock, TIOCOUTQ, &unsent) == 0) return unsent; #endif - return 0; + return -1; } /* @@ -292,8 +292,11 @@ void epicsShareAPI logClientFlush ( logClientId id ) logClientClose ( pClient ); } else if ( nSent > 0 && pClient->nextMsgIndex > 0 ) { - pClient->backlog = epicsSocketCountUnsentBytes ( pClient->sock ); - nSent -= pClient->backlog; + int backlog = epicsSocketCountUnsentBytes ( pClient->sock ); + if (backlog >= 0) { + pClient->backlog = backlog; + nSent -= backlog; + } pClient->nextMsgIndex -= nSent; if ( nSent > 0 && pClient->nextMsgIndex > 0 ) { memmove ( pClient->msgBuf, & pClient->msgBuf[nSent],