s3:unix_msg: add close_fd_array_cmsg()
authorMichael Adam <obnox@samba.org>
Mon, 29 Sep 2014 11:31:27 +0000 (13:31 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 30 Sep 2014 14:36:10 +0000 (16:36 +0200)
Variant of close_fd_array() operating on fd_array inside msghdr.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/lib/unix_msg/unix_msg.c

index 6d1f3adce40acfc19262fe1b88073e64d90e3e4a..ca7f85dea398b06d451c44780c4462a7f4714420 100644 (file)
@@ -177,6 +177,19 @@ static void close_fd_array(int *fds, size_t num_fds)
        }
 }
 
+static void close_fd_array_cmsg(struct msghdr *msg)
+{
+       int *fds = NULL;
+       size_t num_fds = 0;
+
+       extract_fd_array_from_msghdr(msg, &fds, &num_fds);
+
+       /*
+        * TODO: caveat - side-effect - changing msg ???
+        */
+       close_fd_array(fds, num_fds);
+}
+
 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,