From c9d08be7d0f5756c19c4c31af8b9034b02ebe33e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Aug 2014 12:42:41 +0200 Subject: s3:unix_msg: add close_fd_array() Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam --- source3/lib/unix_msg/unix_msg.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source3/lib/unix_msg/unix_msg.c b/source3/lib/unix_msg/unix_msg.c index 8346bb54c5..dd2107bd42 100644 --- a/source3/lib/unix_msg/unix_msg.c +++ b/source3/lib/unix_msg/unix_msg.c @@ -135,6 +135,20 @@ static int prepare_socket(int sock) return prepare_socket_cloexec(sock); } +static void close_fd_array(int *fds, size_t num_fds) +{ + size_t i; + + for (i = 0; i < num_fds; i++) { + if (fds[i] == -1) { + continue; + } + + close(fds[i]); + fds[i] = -1; + } +} + static int unix_dgram_init(const struct sockaddr_un *addr, size_t max_msg, const struct poll_funcs *ev_funcs, void (*recv_callback)(struct unix_dgram_ctx *ctx, -- cgit