apcups branch: Don't close the socket after each iteration.
authorocto <octo>
Sat, 10 Jun 2006 11:08:15 +0000 (11:08 +0000)
committerocto <octo>
Sat, 10 Jun 2006 11:08:15 +0000 (11:08 +0000)
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

index e2ad70c..f5a0dea 100644 (file)
@@ -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);
 }