ctdb-server: fix a possible fd leak in ctdb_tcp_listen_automatic()
authorMichael Adam <obnox@samba.org>
Tue, 8 Sep 2015 08:01:31 +0000 (10:01 +0200)
committerMartin Schwenke <martins@samba.org>
Wed, 9 Sep 2015 08:12:21 +0000 (10:12 +0200)
sockets are created in a loop until an unused address is found.
But the unused socket fds were not closed.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tcp/tcp_connect.c

index b106f22c86fa51dae72428e03696f3a8881fd29c..277eb375ba9c61df586915ace9e7c926a7680b64 100644 (file)
@@ -338,6 +338,8 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
                        DEBUG(DEBUG_ERR,(__location__ " Failed to bind() to socket. %s(%d)\n",
                                        strerror(errno), errno));
                }
+
+               close(ctcp->listen_fd);
        }
 
        if (i == ctdb->num_nodes) {