svn commit: samba r13092 - in trunk/source: lib nsswitch
jra at samba.org
jra at samba.org
Mon Jan 23 22:00:35 GMT 2006
Author: jra
Date: 2006-01-23 22:00:30 +0000 (Mon, 23 Jan 2006)
New Revision: 13092
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=13092
Log:
Add code to remove a race condition when we're fork'ing a new
child and changing message disposition.
Jeremy.
Modified:
trunk/source/lib/messages.c
trunk/source/nsswitch/winbindd_dual.c
Changeset:
Modified: trunk/source/lib/messages.c
===================================================================
--- trunk/source/lib/messages.c 2006-01-23 21:57:58 UTC (rev 13091)
+++ trunk/source/lib/messages.c 2006-01-23 22:00:30 UTC (rev 13092)
@@ -604,4 +604,19 @@
*n_sent = msg_all.n_sent;
return True;
}
+
+/*
+ * Block and unblock receiving of messages. Allows removal of race conditions
+ * when doing a fork and changing message disposition.
+ */
+
+void message_block(void)
+{
+ BlockSignals(True, SIGUSR1);
+}
+
+void message_unblock(void)
+{
+ BlockSignals(False, SIGUSR1);
+}
/** @} **/
Modified: trunk/source/nsswitch/winbindd_dual.c
===================================================================
--- trunk/source/nsswitch/winbindd_dual.c 2006-01-23 21:57:58 UTC (rev 13091)
+++ trunk/source/nsswitch/winbindd_dual.c 2006-01-23 22:00:30 UTC (rev 13092)
@@ -557,10 +557,15 @@
ZERO_STRUCT(state);
state.pid = getpid();
+ /* Ensure we don't process messages whilst we're
+ changing the disposition for the child. */
+ message_block();
+
child->pid = sys_fork();
if (child->pid == -1) {
DEBUG(0, ("Could not fork: %s\n", strerror(errno)));
+ message_unblock();
return False;
}
@@ -573,6 +578,8 @@
child->event.flags = 0;
child->requests = NULL;
add_fd_event(&child->event);
+ /* We're ok with online/offline messages now. */
+ message_unblock();
return True;
}
@@ -600,6 +607,9 @@
message_deregister(MSG_WINBIND_OFFLINE);
message_deregister(MSG_WINBIND_ONLINE);
+ /* The child is ok with online/offline messages now. */
+ message_unblock();
+
child->mem_ctx = talloc_init("child_mem_ctx");
if (child->mem_ctx == NULL) {
return False;
More information about the samba-cvs
mailing list