diff options
Diffstat (limited to 'source4/libcli')
-rw-r--r-- | source4/libcli/nbt/nbtsocket.c | 14 | ||||
-rw-r--r-- | source4/libcli/raw/clisocket.c | 20 | ||||
-rw-r--r-- | source4/libcli/raw/clitransport.c | 2 | ||||
-rw-r--r-- | source4/libcli/resolve/host.c | 4 |
4 files changed, 7 insertions, 33 deletions
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c index 664e6fdce0..d970f8e4e0 100644 --- a/source4/libcli/nbt/nbtsocket.c +++ b/source4/libcli/nbt/nbtsocket.c @@ -29,16 +29,6 @@ #define NBT_MAX_REPLIES 1000 /* - destroy a nbt socket -*/ -static int nbtsock_destructor(void *ptr) -{ - struct nbt_name_socket *nbtsock = talloc_get_type(ptr, struct nbt_name_socket); - event_remove_fd(nbtsock->event_ctx, nbtsock->fde); - return 0; -} - -/* destroy a pending request */ static int nbt_name_request_destructor(void *ptr) @@ -56,7 +46,6 @@ static int nbt_name_request_destructor(void *ptr) req->request->name_trn_id = 0; } if (req->te) { - event_remove_timed(req->nbtsock->event_ctx, req->te); req->te = NULL; } if (req->nbtsock->send_queue == NULL) { @@ -279,7 +268,7 @@ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, fde.private = nbtsock; nbtsock->fde = event_add_fd(nbtsock->event_ctx, &fde); - talloc_set_destructor(nbtsock, nbtsock_destructor); + talloc_steal(nbtsock, nbtsock->fde); return nbtsock; @@ -356,6 +345,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, te.handler = nbt_name_socket_timeout; te.private = req; req->te = event_add_timed(nbtsock->event_ctx, &te); + talloc_steal(req, req->te); talloc_set_destructor(req, nbt_name_request_destructor); diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c index 9249f453e8..847f5c1b0a 100644 --- a/source4/libcli/raw/clisocket.c +++ b/source4/libcli/raw/clisocket.c @@ -37,16 +37,6 @@ struct clisocket_connect { }; -static int smbcli_sock_destructor(void *ptr) -{ - struct smbcli_socket *sock = talloc_get_type(ptr, struct smbcli_socket); - - if (sock->event.fde && sock->event.ctx) { - event_remove_fd(sock->event.ctx, sock->event.fde); - } - return 0; -} - /* create a smbcli_socket context The event_ctx is optional - if not supplied one will be created @@ -71,8 +61,6 @@ struct smbcli_socket *smbcli_sock_init(TALLOC_CTX *mem_ctx, return NULL; } - talloc_set_destructor(sock, smbcli_sock_destructor); - return sock; } @@ -134,11 +122,7 @@ static NTSTATUS smbcli_sock_connect_one(struct smbcli_socket *sock, talloc_free(sock->sock); sock->sock = NULL; } - - if (sock->event.fde) { - event_remove_fd(sock->event.ctx, sock->event.fde); - sock->event.fde = NULL; - } + talloc_free(sock->event.fde); status = socket_create("ip", SOCKET_TYPE_STREAM, &sock->sock, 0); if (!NT_STATUS_IS_OK(status)) { @@ -155,6 +139,8 @@ static NTSTATUS smbcli_sock_connect_one(struct smbcli_socket *sock, fde.private = sock; sock->event.fde = event_add_fd(sock->event.ctx, &fde); + talloc_steal(sock, sock->event.fde); + sock->port = port; set_blocking(fde.fd, False); diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index 918f18fa40..b053b362ca 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -55,7 +55,6 @@ static int transport_destructor(void *ptr) struct smbcli_transport *transport = ptr; smbcli_transport_dead(transport); - event_remove_timed(transport->socket->event.ctx, transport->socket->event.te); return 0; } @@ -323,6 +322,7 @@ void smbcli_transport_idle_handler(struct smbcli_transport *transport, te.handler = idle_handler; te.private = transport; transport->socket->event.te = event_add_timed(transport->socket->event.ctx, &te); + talloc_steal(transport, transport->socket->event.te); } /* diff --git a/source4/libcli/resolve/host.c b/source4/libcli/resolve/host.c index 2cc0c1705f..b9aa1aa272 100644 --- a/source4/libcli/resolve/host.c +++ b/source4/libcli/resolve/host.c @@ -57,9 +57,6 @@ static int host_destructor(void *ptr) if (state->child != (pid_t)-1) { kill(state->child, SIGTERM); } - if (state->fde) { - event_remove_fd(state->event_ctx, state->fde); - } return 0; } @@ -174,6 +171,7 @@ struct smbcli_composite *resolve_name_host_send(struct nbt_name *name, close(fd[1]); goto failed; } + talloc_steal(state, state->fde); /* signal handling in posix really sucks - doing this in a library affects the whole app, but what else to do?? */ |