From fd62df64188c0f992876c72fdda8a6da5dba3090 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Jan 2005 11:49:15 +0000 Subject: r4943: Smplified the events handling code a lot. The first source of complexity was that events didn't automatically cleanup themselves. This was because the events code was written before we had talloc destructors, so you needed to call event_remove_XX() to clean the event out of the event lists from every piece of code that used events. I have now added automatic event destructors, which in turn allowed me to simplify a lot of the calling code. The 2nd source of complexity was caused by the ref_count, which was needed to cope with event handlers destroying events while handling them, which meant the linked lists became invalid, so the ref_count ws used to mark events for later destruction. The new system is much simpler. I now have a ev->destruction_count, which is incremented in all event destructors. The event dispatch code checks for changes to this and handles it. (This used to be commit a3c7417cfeab429ffb22d5546b205818f531a7b4) --- source4/rpc_server/echo/rpc_echo.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source4/rpc_server/echo/rpc_echo.c') diff --git a/source4/rpc_server/echo/rpc_echo.c b/source4/rpc_server/echo/rpc_echo.c index 164e2d588f..2b4f31482d 100644 --- a/source4/rpc_server/echo/rpc_echo.c +++ b/source4/rpc_server/echo/rpc_echo.c @@ -135,13 +135,6 @@ static void echo_TestSleep_handler(struct event_context *ev, struct timed_event } } -static int echo_TestSleep_destructor(void *ptr) -{ - struct echo_TestSleep_private *p = ptr; - event_remove_timed(p->dce_call->event_ctx, p->te); - return 0; -} - static long echo_TestSleep(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct echo_TestSleep *r) { struct timed_event te; @@ -170,8 +163,7 @@ static long echo_TestSleep(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_c if (!p->te) { return 0; } - - talloc_set_destructor(p, echo_TestSleep_destructor); + talloc_steal(p, p->te); dce_call->state_flags |= DCESRV_CALL_STATE_FLAG_ASYNC; return 0; -- cgit