From 38e43be7b89673282f8853ffedf726d84ef5ce30 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 27 Sep 2005 12:54:08 +0000 Subject: r10537: - we now use a much nicer way to handle talloc_free(timed_event) the events code replaces a destructor to one that returns allways -1 while it's calling the event handler - we don't need the composite and winsrepl specific fixes any more - this also fixes the problem with smbcli, dcerpc, cldap, ldap and nbt request timeouts metze (This used to be commit 495996cfc49a1c6eefde6ff04fc75e0739be3aab) --- source4/gtk/common/gtk_events.c | 45 +++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'source4/gtk') diff --git a/source4/gtk/common/gtk_events.c b/source4/gtk/common/gtk_events.c index fdc6d55621..df4ffc5cc8 100644 --- a/source4/gtk/common/gtk_events.c +++ b/source4/gtk/common/gtk_events.c @@ -209,46 +209,44 @@ static void gtk_event_set_fd_flags(struct fd_event *fde, uint16_t flags) } struct gtk_timed_event { - BOOL running; guint te_id; }; -static gboolean gtk_event_timed_handler(gpointer data) +/* + destroy a timed event +*/ +static int gtk_event_timed_destructor(void *ptr) { - struct timed_event *te = talloc_get_type(data, struct timed_event); + struct timed_event *te = talloc_get_type(ptr, struct timed_event); struct gtk_timed_event *gtk_te = talloc_get_type(te->additional_data, struct gtk_timed_event); - struct timeval t = timeval_current(); - gtk_te->running = True; - te->handler(te->event_ctx, te, t, te->private_data); - gtk_te->running = False; + g_source_remove(gtk_te->te_id); - talloc_free(te); + return 0; +} - /* return FALSE mean this event should be removed */ - return gtk_false(); +static int gtk_event_timed_deny_destructor(void *ptr) +{ + return -1; } -/* - destroy a timed event -*/ -static int gtk_event_timed_destructor(void *ptr) +static gboolean gtk_event_timed_handler(gpointer data) { - struct timed_event *te = talloc_get_type(ptr, struct timed_event); + struct timed_event *te = talloc_get_type(data, struct timed_event); struct gtk_timed_event *gtk_te = talloc_get_type(te->additional_data, struct gtk_timed_event); + struct timeval t = timeval_current(); - if (gtk_te->running) { - /* the event is running reject the talloc_free() - as it's done by the gtk_event_timed_handler() - */ - return -1; - } + /* deny the handler to free the event */ + talloc_set_destructor(te, gtk_event_timed_deny_destructor); + te->handler(te->event_ctx, te, t, te->private_data); - g_source_remove(gtk_te->te_id); + talloc_set_destructor(te, gtk_event_timed_destructor); + talloc_free(te); - return 0; + /* return FALSE mean this event should be removed */ + return gtk_false(); } /* @@ -285,7 +283,6 @@ static struct timed_event *gtk_event_add_timed(struct event_context *ev, TALLOC_ timeout = ((diff_tv.tv_usec+999)/1000)+(diff_tv.tv_sec*1000); gtk_te->te_id = g_timeout_add(timeout, gtk_event_timed_handler, te); - gtk_te->running = False; talloc_set_destructor(te, gtk_event_timed_destructor); -- cgit