[PATCH] ctdb: fix possible fd leak

Michael Adam obnox at samba.org
Tue Sep 8 09:20:12 UTC 2015


Review appreciated!

Thanks - Michael
-------------- next part --------------
From bd0d53854f4d2058e7e4c2375e568e74aedad46f Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 8 Sep 2015 10:01:31 +0200
Subject: [PATCH] ctdb:server: fix a possible fd leak in
 ctdb_tcp_listen_automatic()

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 at samba.org>
---
 ctdb/tcp/tcp_connect.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c
index a4a0147..64ffce8 100644
--- a/ctdb/tcp/tcp_connect.c
+++ b/ctdb/tcp/tcp_connect.c
@@ -343,6 +343,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) {
-- 
2.4.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150908/c1229f23/attachment.sig>


More information about the samba-technical mailing list