Code

apcups plugin: Close the socket when `connect' failes.
authorFlorian Forster <octo@huhu.verplant.org>
Wed, 19 Jul 2006 16:41:36 +0000 (18:41 +0200)
committerFlorian Forster <octo@huhu.verplant.org>
Wed, 19 Jul 2006 16:41:36 +0000 (18:41 +0200)
Otherwise people will get `Too many open files' faily soon.

src/apcups.c

index 9117bdaea02f641e12a28d3d0be76c3d1393b4f6..f7486f5fc8977e2a4a8db5e23527ac1b072ce5ef 100644 (file)
@@ -208,6 +208,7 @@ static int net_open (char *host, char *service, int port)
        if (status != 0) /* `connect(2)' failed */
        {
                DBG ("connect failed: %s", strerror (errno));
+               close (sd);
                return (-1);
        }