summaryrefslogtreecommitdiff
path: root/rpcapd/daemon.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-03-31 20:36:01 -0700
committerGuy Harris <guy@alum.mit.edu>2018-03-31 20:36:01 -0700
commite750801220bf0e56852b319b2d5a4b2d342604d5 (patch)
treef3f90334eb1d4c9fec79ddda2b4afa9e579c118b /rpcapd/daemon.c
parentaf6aaa6a4fc7a6beb3b8ae5447eb6d30b1cd25cd (diff)
downloadlibpcap-e750801220bf0e56852b319b2d5a4b2d342604d5.tar.gz
Don't log errors due to the peer dropping the connection.
They may happen because somebody ^C's a tcpdump; that's not worth logging. On UN*X, that might show up as ECONNRESET or EPIPE; on Windows, that might show up as WSAECONNRESET or WSAECONNABORTED.
Diffstat (limited to 'rpcapd/daemon.c')
-rwxr-xr-xrpcapd/daemon.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/rpcapd/daemon.c b/rpcapd/daemon.c
index e2d89d96..54b259b8 100755
--- a/rpcapd/daemon.c
+++ b/rpcapd/daemon.c
@@ -2232,6 +2232,7 @@ daemon_thrdatamain(void *ptr)
size_t sendbufsize; // size for the send buffer
char *sendbuf; // temporary buffer in which data to be sent is buffered
int sendbufidx; // index which keeps the number of bytes currently buffered
+ int status;
session = (struct session *) ptr;
@@ -2329,10 +2330,26 @@ daemon_thrdatamain(void *ptr)
}
// Send the packet
- if (sock_send(session->sockdata, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
+ // If the client dropped the connection, don't report an
+ // error, just quit.
+ status = sock_send(session->sockdata, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE);
+ if (status < 0)
{
- rpcapd_log(LOGPRIO_ERROR,
- "Send of packet to client failed: %s", errbuf);
+ if (status == -1)
+ {
+ //
+ // Error other than "client closed the
+ // connection out from under us"; report
+ // it.
+ //
+ rpcapd_log(LOGPRIO_ERROR,
+ "Send of packet to client failed: %s",
+ errbuf);
+ }
+
+ //
+ // Give up in either case.
+ //
goto error;
}
}