svn commit: samba r10538 - in branches/tmp/samba4-winsrepl: . source/gtk/common source/lib/events source/libcli/composite source/libcli/wrepl

metze at samba.org metze at samba.org
Tue Sep 27 12:54:52 GMT 2005


Author: metze
Date: 2005-09-27 12:54:51 +0000 (Tue, 27 Sep 2005)
New Revision: 10538

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10538

Log:
 r12928 at SERNOX (orig r10537):  metze | 2005-09-27 14:54:08 +0200
 - 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

Modified:
   branches/tmp/samba4-winsrepl/
   branches/tmp/samba4-winsrepl/source/gtk/common/gtk_events.c
   branches/tmp/samba4-winsrepl/source/lib/events/events_liboop.c
   branches/tmp/samba4-winsrepl/source/lib/events/events_standard.c
   branches/tmp/samba4-winsrepl/source/libcli/composite/composite.c
   branches/tmp/samba4-winsrepl/source/libcli/wrepl/winsrepl.c


Changeset:

Property changes on: branches/tmp/samba4-winsrepl
___________________________________________________________________
Name: svk:merge
   - 0c0555d6-39d7-0310-84fc-f1cc0bd64818:/branches/SAMBA_4_0:10535
3a72dc49-98ff-0310-ab52-9b7ed7945d91:/local/samba4:9495
a953eb74-4aff-0310-a63c-855d20285ebb:/local/samba4:11632
   + 0c0555d6-39d7-0310-84fc-f1cc0bd64818:/branches/SAMBA_4_0:10537
3a72dc49-98ff-0310-ab52-9b7ed7945d91:/local/samba4:9495
a953eb74-4aff-0310-a63c-855d20285ebb:/local/samba4:11632

Modified: branches/tmp/samba4-winsrepl/source/gtk/common/gtk_events.c
===================================================================
--- branches/tmp/samba4-winsrepl/source/gtk/common/gtk_events.c	2005-09-27 12:54:08 UTC (rev 10537)
+++ branches/tmp/samba4-winsrepl/source/gtk/common/gtk_events.c	2005-09-27 12:54:51 UTC (rev 10538)
@@ -209,46 +209,44 @@
 }
 
 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 @@
 	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);
 

Modified: branches/tmp/samba4-winsrepl/source/lib/events/events_liboop.c
===================================================================
--- branches/tmp/samba4-winsrepl/source/lib/events/events_liboop.c	2005-09-27 12:54:08 UTC (rev 10537)
+++ branches/tmp/samba4-winsrepl/source/lib/events/events_liboop.c	2005-09-27 12:54:51 UTC (rev 10538)
@@ -172,12 +172,23 @@
 	fde->flags = flags;
 }
 
+static int oop_event_timed_destructor(void *ptr);
+static int oop_event_timed_deny_destructor(void *ptr)
+{
+	return -1;
+}
+
 static void *oop_event_timed_handler(oop_source *oop, struct timeval t, void *ptr)
 {
 	struct timed_event *te = ptr;
 
+	/* deny the handler to free the event */
+	talloc_set_destructor(te, oop_event_timed_deny_destructor);
 	te->handler(te->event_ctx, te, t, te->private_data);
 
+	talloc_set_destructor(te, oop_event_timed_destructor);
+	talloc_free(te);
+
 	return OOP_CONTINUE;
 }
 
@@ -218,7 +229,7 @@
 	te->private_data	= private_data;
 	te->additional_data	= NULL;
 
-	oop->cancel_time(oop, te->next_event, oop_event_timed_handler, te);
+	oop->on_time(oop, te->next_event, oop_event_timed_handler, te);
 
 	talloc_set_destructor(te, oop_event_timed_destructor);
 

Modified: branches/tmp/samba4-winsrepl/source/lib/events/events_standard.c
===================================================================
--- branches/tmp/samba4-winsrepl/source/lib/events/events_standard.c	2005-09-27 12:54:08 UTC (rev 10537)
+++ branches/tmp/samba4-winsrepl/source/lib/events/events_standard.c	2005-09-27 12:54:51 UTC (rev 10538)
@@ -284,6 +284,11 @@
 	return 0;
 }
 
+static int std_event_timed_deny_destructor(void *ptr)
+{
+	return -1;
+}
+
 /*
   add a timed event
   return NULL on failure (memory allocation error)
@@ -340,17 +345,12 @@
 		return;
 	}
 
-	te->next_event = timeval_zero();
-
+	/* deny the handler to free the event */
+	talloc_set_destructor(te, std_event_timed_deny_destructor);
 	te->handler(ev, te, t, te->private_data);
 
-	/* note the care taken to prevent referencing a event
-	   that could have been freed by the handler */
-	if (std_ev->timed_events) {
-		if (timeval_is_zero(&std_ev->timed_events->next_event)) {
-			talloc_free(te);
-		}
-	}
+	talloc_set_destructor(te, std_event_timed_destructor);
+	talloc_free(te);
 }
 
 #if WITH_EPOLL

Modified: branches/tmp/samba4-winsrepl/source/libcli/composite/composite.c
===================================================================
--- branches/tmp/samba4-winsrepl/source/libcli/composite/composite.c	2005-09-27 12:54:08 UTC (rev 10537)
+++ branches/tmp/samba4-winsrepl/source/libcli/composite/composite.c	2005-09-27 12:54:51 UTC (rev 10538)
@@ -52,12 +52,6 @@
 {
 	struct composite_context *c = talloc_get_type(ptr, struct composite_context);
 	if (c->async.fn) {
-		/*
-		 * the event is a child of req,
-		 * and req will be free'ed by the callback fn
-		 * but the events code wants to free the event itself
-		 */
-		talloc_steal(ev, te);	
 		c->async.fn(c);
 	}
 }

Modified: branches/tmp/samba4-winsrepl/source/libcli/wrepl/winsrepl.c
===================================================================
--- branches/tmp/samba4-winsrepl/source/libcli/wrepl/winsrepl.c	2005-09-27 12:54:08 UTC (rev 10537)
+++ branches/tmp/samba4-winsrepl/source/libcli/wrepl/winsrepl.c	2005-09-27 12:54:51 UTC (rev 10538)
@@ -385,12 +385,6 @@
 {
 	struct wrepl_request *req = talloc_get_type(ptr, struct wrepl_request);
 	if (req->async.fn) {
-		/*
-		 * the event is a child of req,
-		 * and req will be free'ed by the callback fn
-		 * but the events code wants to free the event itself
-		 */
-		talloc_steal(ev, te);
 		req->async.fn(req);
 	}
 }



More information about the samba-cvs mailing list