[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Fri Mar 26 04:45:38 MDT 2010


The branch, master has been updated
       via  789d67c... s4-smbd: use tevent_re_initialise()
       via  5609c50... tevent: added tevent_re_initialise()
      from  525a4fb... util: on FreeBSD true is in /usr/bin. Use execvp to find it

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 789d67c4992e008fe17b830d3b23e3b95a4e70d9
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Mar 26 21:13:55 2010 +1100

    s4-smbd: use tevent_re_initialise()
    
    This fixes a crash bug on startup

commit 5609c504337b79fd6f521c42b414c650b23d0c9a
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Mar 26 21:13:27 2010 +1100

    tevent: added tevent_re_initialise()
    
    This allows us to re-initialise a tevent context without destroying
    the pointer. That means that if someone keeps a long term ptr to the
    event context across a fork it will still work.
    
    This also brings the memory handling in single and standard process
    models much closer together, which means less bugs that we don't find
    with make test.

-----------------------------------------------------------------------

Summary of changes:
 lib/tevent/tevent.c             |   15 +++++++++++++++
 lib/tevent/tevent.h             |    2 ++
 source4/smbd/process_standard.c |    8 ++++++--
 3 files changed, 23 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c
index a0ee208..ceae534 100644
--- a/lib/tevent/tevent.c
+++ b/lib/tevent/tevent.c
@@ -616,3 +616,18 @@ int _tevent_loop_wait(struct tevent_context *ev, const char *location)
 {
 	return ev->ops->loop_wait(ev, location);
 }
+
+
+/*
+  re-initialise a tevent context. This leaves you with the same
+  event context, but all events are wiped and the structure is
+  re-initialised. This is most useful after a fork()  
+
+  zero is returned on success, non-zero on failure
+*/
+int tevent_re_initialise(struct tevent_context *ev)
+{
+	tevent_common_context_destructor(ev);
+
+	return ev->ops->context_init(ev);
+}
diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index e318a4b..ad1f2c9 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -366,6 +366,8 @@ int _tevent_loop_until(struct tevent_context *ev,
 	_tevent_loop_until(ev, finished, private_data, __location__)
 #endif
 
+int tevent_re_initialise(struct tevent_context *ev);
+
 
 /**
  * The following structure and registration functions are exclusively
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index dfa4fa6..032b999 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -120,7 +120,9 @@ static void standard_accept_connection(struct tevent_context *ev,
 	/* this will free all the listening sockets and all state that
 	   is not associated with this new connection */
 	talloc_free(sock);
-	talloc_free(ev);
+	if (tevent_re_initialise(ev) != 0) {
+		smb_panic("Failed to re-initialise tevent after fork");
+	}
 
 	/* we don't care if the dup fails, as its only a select()
 	   speed optimisation */
@@ -192,7 +194,9 @@ static void standard_new_task(struct tevent_context *ev,
 
 	/* this will free all the listening sockets and all state that
 	   is not associated with this new connection */
-	talloc_free(ev);
+	if (tevent_re_initialise(ev) != 0) {
+		smb_panic("Failed to re-initialise tevent after fork");
+	}
 
 	/* ldb/tdb need special fork handling */
 	ldb_wrap_fork_hook();


-- 
Samba Shared Repository


More information about the samba-cvs mailing list