From 86294767df94d8d6a982556257052836a93641bd Mon Sep 17 00:00:00 2001 From: octo Date: Sat, 10 Jun 2006 11:08:15 +0000 Subject: [PATCH] apcups branch: Don't close the socket after each iteration. The apcups daemon can handle it and it's nicer to the system to just leave the socket open, so that's what we're doing. The socket is still closed if `APCMAIN' is defined. --- src/apcups.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/apcups.c b/src/apcups.c index e2ad70cb..f5a0deac 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -218,6 +218,7 @@ static int write_nbytes (int *fd, void *buf, int buflen) return (buflen); } +#if APCMAIN /* Close the network connection */ static void net_close (int *fd) { @@ -233,6 +234,7 @@ static void net_close (int *fd) close (*fd); *fd = -1; } +#endif /* APCMAIN */ /* * Open a TCP connection to the UPS network server @@ -458,11 +460,13 @@ static int apc_query_server (char *host, int port, syslog (LOG_WARNING, "apcups plugin: Error reading from socket"); return (-1); } +#if APCMAIN else { /* close the opened socket */ net_close (&sockfd); } +#endif /* APCMAIN */ return (0); } -- 2.11.0