diff options
-rw-r--r-- | source4/lib/events.c | 18 | ||||
-rw-r--r-- | source4/lib/messaging/messaging.c | 15 | ||||
-rw-r--r-- | source4/libcli/nbt/nbtsocket.c | 7 | ||||
-rw-r--r-- | source4/libcli/raw/clisocket.c | 3 | ||||
-rw-r--r-- | source4/libcli/raw/clitransport.c | 4 | ||||
-rw-r--r-- | source4/libcli/resolve/host.c | 3 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_sock.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_wait.c | 3 | ||||
-rw-r--r-- | source4/rpc_server/echo/rpc_echo.c | 3 | ||||
-rw-r--r-- | source4/smbd/service.c | 12 |
10 files changed, 33 insertions, 37 deletions
diff --git a/source4/lib/events.c b/source4/lib/events.c index 6f0bdb4fdd..a484295d8b 100644 --- a/source4/lib/events.c +++ b/source4/lib/events.c @@ -157,7 +157,8 @@ static int event_fd_destructor(void *ptr) add a fd based event return NULL on failure (memory allocation error) */ -struct fd_event *event_add_fd(struct event_context *ev, struct fd_event *e0) +struct fd_event *event_add_fd(struct event_context *ev, struct fd_event *e0, + TALLOC_CTX *mem_ctx) { struct fd_event *e = talloc(ev->events, struct fd_event); if (!e) return NULL; @@ -168,6 +169,9 @@ struct fd_event *event_add_fd(struct event_context *ev, struct fd_event *e0) ev->maxfd = e->fd; } talloc_set_destructor(e, event_fd_destructor); + if (mem_ctx) { + talloc_steal(mem_ctx, e); + } return e; } @@ -226,7 +230,8 @@ static int event_timed_destructor(void *ptr) add a timed event return NULL on failure (memory allocation error) */ -struct timed_event *event_add_timed(struct event_context *ev, struct timed_event *e0) +struct timed_event *event_add_timed(struct event_context *ev, struct timed_event *e0, + TALLOC_CTX *mem_ctx) { struct timed_event *e = talloc(ev->events, struct timed_event); if (!e) return NULL; @@ -234,6 +239,9 @@ struct timed_event *event_add_timed(struct event_context *ev, struct timed_event e->event_ctx = ev; DLIST_ADD(ev->timed_events, e); talloc_set_destructor(e, event_timed_destructor); + if (mem_ctx) { + talloc_steal(mem_ctx, e); + } return e; } @@ -259,7 +267,8 @@ static int event_loop_destructor(void *ptr) add a loop event return NULL on failure (memory allocation error) */ -struct loop_event *event_add_loop(struct event_context *ev, struct loop_event *e0) +struct loop_event *event_add_loop(struct event_context *ev, struct loop_event *e0, + TALLOC_CTX *mem_ctx) { struct loop_event *e = talloc(ev->events, struct loop_event); if (!e) return NULL; @@ -267,6 +276,9 @@ struct loop_event *event_add_loop(struct event_context *ev, struct loop_event *e e->event_ctx = ev; DLIST_ADD(ev->loop_events, e); talloc_set_destructor(e, event_loop_destructor); + if (mem_ctx) { + talloc_steal(mem_ctx, e); + } return e; } diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index beceb342c9..ca7682f5d2 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -220,9 +220,7 @@ static void messaging_listen_handler(struct event_context *ev, struct fd_event * fde2.flags = EVENT_FD_READ; fde2.handler = messaging_recv_handler; - rec->fde = event_add_fd(msg->event.ev, &fde2); - - talloc_steal(rec, rec->fde); + rec->fde = event_add_fd(msg->event.ev, &fde2, rec); } /* @@ -358,8 +356,7 @@ static void messaging_backoff_handler(struct event_context *ev, struct timed_eve fde.flags = EVENT_FD_WRITE; fde.handler = messaging_send_handler; - rec->fde = event_add_fd(msg->event.ev, &fde); - talloc_steal(rec, rec->fde); + rec->fde = event_add_fd(msg->event.ev, &fde, rec); messaging_send_handler(msg->event.ev, rec->fde, timeval_zero(), EVENT_FD_WRITE); } @@ -408,7 +405,7 @@ NTSTATUS messaging_send(struct messaging_context *msg, servid_t server, uint32_t te.next_event = timeval_current_ofs(0, MESSAGING_BACKOFF); te.handler = messaging_backoff_handler; te.private = rec; - event_add_timed(msg->event.ev, &te); + event_add_timed(msg->event.ev, &te, rec); return NT_STATUS_OK; } @@ -422,8 +419,7 @@ NTSTATUS messaging_send(struct messaging_context *msg, servid_t server, uint32_t fde.flags = EVENT_FD_WRITE; fde.handler = messaging_send_handler; - rec->fde = event_add_fd(msg->event.ev, &fde); - talloc_steal(rec, rec->fde); + rec->fde = event_add_fd(msg->event.ev, &fde, rec); messaging_send_handler(msg->event.ev, rec->fde, timeval_zero(), EVENT_FD_WRITE); @@ -501,8 +497,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, servid_t server_id fde.handler = messaging_listen_handler; msg->event.ev = talloc_reference(msg,ev); - msg->event.fde = event_add_fd(ev, &fde); - talloc_steal(msg, msg->event.fde); + msg->event.fde = event_add_fd(ev, &fde, msg); talloc_set_destructor(msg, messaging_destructor); diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c index d970f8e4e0..1eea77d356 100644 --- a/source4/libcli/nbt/nbtsocket.c +++ b/source4/libcli/nbt/nbtsocket.c @@ -266,9 +266,7 @@ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, fde.flags = 0; fde.handler = nbt_name_socket_handler; fde.private = nbtsock; - nbtsock->fde = event_add_fd(nbtsock->event_ctx, &fde); - - talloc_steal(nbtsock, nbtsock->fde); + nbtsock->fde = event_add_fd(nbtsock->event_ctx, &fde, nbtsock); return nbtsock; @@ -344,8 +342,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, te.next_event = timeout; te.handler = nbt_name_socket_timeout; te.private = req; - req->te = event_add_timed(nbtsock->event_ctx, &te); - talloc_steal(req, req->te); + req->te = event_add_timed(nbtsock->event_ctx, &te, req); talloc_set_destructor(req, nbt_name_request_destructor); diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c index 847f5c1b0a..c9934fa16d 100644 --- a/source4/libcli/raw/clisocket.c +++ b/source4/libcli/raw/clisocket.c @@ -138,8 +138,7 @@ static NTSTATUS smbcli_sock_connect_one(struct smbcli_socket *sock, fde.handler = smbcli_sock_connect_handler; fde.private = sock; - sock->event.fde = event_add_fd(sock->event.ctx, &fde); - talloc_steal(sock, sock->event.fde); + sock->event.fde = event_add_fd(sock->event.ctx, &fde, sock); sock->port = port; set_blocking(fde.fd, False); diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index b053b362ca..e3a8281f3f 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -321,8 +321,8 @@ void smbcli_transport_idle_handler(struct smbcli_transport *transport, te.next_event = timeval_current_ofs(0, period); 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); + transport->socket->event.te = event_add_timed(transport->socket->event.ctx, + &te, transport); } /* diff --git a/source4/libcli/resolve/host.c b/source4/libcli/resolve/host.c index b9aa1aa272..5b28a850fc 100644 --- a/source4/libcli/resolve/host.c +++ b/source4/libcli/resolve/host.c @@ -165,13 +165,12 @@ struct smbcli_composite *resolve_name_host_send(struct nbt_name *name, fde.flags = EVENT_FD_READ; fde.handler = pipe_handler; fde.private = c; - state->fde = event_add_fd(c->event_ctx, &fde); + state->fde = event_add_fd(c->event_ctx, &fde, state); if (state->fde == NULL) { close(fd[0]); 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?? */ diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c index 720055087b..a01832764d 100644 --- a/source4/librpc/rpc/dcerpc_sock.c +++ b/source4/librpc/rpc/dcerpc_sock.c @@ -347,7 +347,7 @@ static NTSTATUS dcerpc_pipe_open_socket(struct dcerpc_connection *c, fde.handler = sock_io_handler; fde.private = c; - sock->fde = event_add_fd(sock->event_ctx, &fde); + sock->fde = event_add_fd(sock->event_ctx, &fde, sock); c->transport.private = sock; diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index e4175ca8cc..da36ac2239 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -143,8 +143,7 @@ static int pvfs_wait_destructor(void *ptr) te.next_event = end_time; te.handler = pvfs_wait_timeout; te.private = pwait; - pwait->te = event_add_timed(pwait->ev, &te); - talloc_steal(pwait, pwait->te); + pwait->te = event_add_timed(pwait->ev, &te, pwait); /* register with the messaging subsystem for this message type */ diff --git a/source4/rpc_server/echo/rpc_echo.c b/source4/rpc_server/echo/rpc_echo.c index 2b4f31482d..88fd7fb12d 100644 --- a/source4/rpc_server/echo/rpc_echo.c +++ b/source4/rpc_server/echo/rpc_echo.c @@ -159,11 +159,10 @@ static long echo_TestSleep(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_c te.private = p; te.next_event = timeval_add(&dce_call->time, r->in.seconds, 0); - p->te = event_add_timed(dce_call->event_ctx, &te); + p->te = event_add_timed(dce_call->event_ctx, &te, p); if (!p->te) { return 0; } - talloc_steal(p, p->te); dce_call->state_flags |= DCESRV_CALL_STATE_FLAG_ASYNC; return 0; diff --git a/source4/smbd/service.c b/source4/smbd/service.c index 7067a26e7a..378ca1914d 100644 --- a/source4/smbd/service.c +++ b/source4/smbd/service.c @@ -163,15 +163,14 @@ struct server_stream_socket *service_setup_stream_socket(struct server_service * stream_socket->service = service; stream_socket->socket = sock; stream_socket->event.ctx = service->server->event.ctx; - stream_socket->event.fde = event_add_fd(stream_socket->event.ctx, &fde); + stream_socket->event.fde = event_add_fd(stream_socket->event.ctx, + &fde, stream_socket); if (!stream_socket->event.fde) { - DEBUG(0,("event_add_fd(stream_socket->event.ctx, &fde) failed\n")); socket_destroy(sock); return NULL; } talloc_steal(stream_socket, sock); - talloc_steal(stream_socket, stream_socket->event.fde); if (stream_socket->stream.ops->socket_init) { stream_socket->stream.ops->socket_init(stream_socket); @@ -239,11 +238,8 @@ struct server_connection *server_setup_connection(struct event_context *ev, stream_socket->stream.ops->accept_connection(srv_conn); /* accpect_connection() of the service may changed idle.next_event */ - srv_conn->event.fde = event_add_fd(ev,&fde); - srv_conn->event.idle = event_add_timed(ev,&idle); - - talloc_steal(srv_conn, srv_conn->event.fde); - talloc_steal(srv_conn, srv_conn->event.idle); + srv_conn->event.fde = event_add_fd(ev, &fde, srv_conn); + srv_conn->event.idle = event_add_timed(ev, &idle, srv_conn); talloc_set_destructor(srv_conn, server_connection_destructor); |