s4-dns-ex: use autoclose on the dns child pipe
authorAndrew Tridgell <tridge@samba.org>
Thu, 4 Mar 2010 23:43:34 +0000 (10:43 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 5 Mar 2010 00:54:36 +0000 (11:54 +1100)
I'm hoping this will fix an occasional segfault I've noticed where
epoll still calls events on a closed fde

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/libcli/resolve/dns_ex.c

index 79ed78340c4b471c6baeae24d7efd38ab9ad1172..423668d4b6cbd1e21b05cec6f2f850926a6051a6 100644 (file)
@@ -67,7 +67,6 @@ static int dns_ex_destructor(struct dns_ex_state *state)
        int status;
 
        kill(state->child, SIGTERM);
-       close(state->child_fd);
        if (waitpid(state->child, &status, WNOHANG) == 0) {
                kill(state->child, SIGKILL);
                waitpid(state->child, &status, 0);
@@ -369,7 +368,6 @@ static void pipe_handler(struct tevent_context *ev, struct tevent_fd *fde,
        } else {
                ret = -1;
        }
-       close(state->child_fd);
        if (waitpid(state->child, &status, WNOHANG) == 0) {
                kill(state->child, SIGKILL);
                waitpid(state->child, &status, 0);
@@ -498,6 +496,7 @@ struct composite_context *resolve_name_dns_ex_send(TALLOC_CTX *mem_ctx,
                close(fd[1]);
                return c;
        }
+       tevent_fd_set_auto_close(state->fde);
 
        state->child = fork();
        if (state->child == (pid_t)-1) {