[SCM] Samba Shared Repository - branch master updated

Simo Sorce idra at samba.org
Thu Jun 10 15:33:09 MDT 2010


The branch, master has been updated
       via  0962763... s3:misc make use of server_[event/messaging]_context directly
       via  cbda036... s3:winbindd use common server context functions
       via  5e576a5... s3:lib make server contexts generic
      from  aeb25ad... Fix the build in the non WITH_AIO case (sorry).

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


- Log -----------------------------------------------------------------
commit 09627638224759c985f0636c5616b0357c91e450
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 10 11:48:39 2010 -0400

    s3:misc make use of server_[event/messaging]_context directly
    
    Untangle these functions from smbd specific dependencies so they can be freely
    used in multiple servers.

commit cbda0369a831ed279cec7ff231ad7399af74db39
Author: Simo Sorce <idra at samba.org>
Date:   Thu Jun 10 11:55:27 2010 -0400

    s3:winbindd use common server context functions

commit 5e576a53abbf2822c0a8fcc87f76140a755599e4
Author: Simo Sorce <idra at samba.org>
Date:   Thu Jun 10 11:54:00 2010 -0400

    s3:lib make server contexts generic
    
    Pair-programmed-with: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 source3/Makefile.in               |    2 +-
 source3/auth/auth_server.c        |    2 +-
 source3/include/proto.h           |    6 +++
 source3/lib/server_contexts.c     |   69 +++++++++++++++++++++++++++++++++++++
 source3/printing/notify.c         |    6 ++--
 source3/printing/print_cups.c     |    8 ++--
 source3/printing/printing.c       |   13 ++++---
 source3/rpc_server/srv_samr_nt.c  |    2 +-
 source3/smbd/globals.c            |   17 +--------
 source3/smbd/server.c             |   13 +------
 source3/smbd/server_exit.c        |    4 +-
 source3/winbindd/winbindd.c       |   14 -------
 source3/winbindd/winbindd.h       |    3 ++
 source3/winbindd/winbindd_event.c |   37 --------------------
 source3/winbindd/winbindd_proto.h |    3 --
 15 files changed, 99 insertions(+), 100 deletions(-)
 create mode 100644 source3/lib/server_contexts.c
 delete mode 100644 source3/winbindd/winbindd_event.c


Changeset truncated at 500 lines:

diff --git a/source3/Makefile.in b/source3/Makefile.in
index 8e2c003..82e677d 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -406,6 +406,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
 	  lib/conn_tdb.o lib/adt_tree.o lib/gencache.o \
 	  lib/sessionid_tdb.o \
 	  lib/module.o lib/events.o @LIBTEVENT_OBJ0@ \
+	  lib/server_contexts.o \
 	  lib/ldap_escape.o @CHARSET_STATIC@ \
 	  lib/secdesc.o lib/util_seaccess.o ../libcli/security/secace.o \
 	  ../libcli/security/sddl.o \
@@ -1170,7 +1171,6 @@ IDMAP_ADEX_OBJ = \
 
 WINBINDD_OBJ1 = \
 		winbindd/winbindd.o       \
-		winbindd/winbindd_event.o \
 		winbindd/winbindd_group.o \
 		winbindd/winbindd_util.o  \
 		winbindd/winbindd_cache.o \
diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index c4d02e2..8f0f98b 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -206,7 +206,7 @@ static struct server_security_state *make_server_security_state(struct cli_state
 		interval.tv_sec = lp_keepalive();
 		interval.tv_usec = 0;
 
-		if (event_add_idle(smbd_event_context(), result, interval,
+		if (event_add_idle(server_event_context(), result, interval,
 				   "server_security_keepalive",
 				   send_server_keepalive,
 				   result) == NULL) {
diff --git a/source3/include/proto.h b/source3/include/proto.h
index e6aec3a..9ae6407 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6247,6 +6247,12 @@ void set_root_sec_ctx(void);
 bool pop_sec_ctx(void);
 void init_sec_ctx(void);
 
+/* The following definitions come from lib/server_contexts.c  */
+struct tevent_context *server_event_context(void);
+void server_event_context_free(void);
+struct messaging_context *server_messaging_context(void);
+void server_messaging_context_free(void);
+
 /* The following definitions come from smbd/server.c  */
 
 int smbd_server_fd(void);
diff --git a/source3/lib/server_contexts.c b/source3/lib/server_contexts.c
new file mode 100644
index 0000000..5e48b79
--- /dev/null
+++ b/source3/lib/server_contexts.c
@@ -0,0 +1,69 @@
+/*
+   Unix SMB/CIFS implementation.
+   Common server globals
+
+   Copyright (C) Simo Sorce <idra at samba.org> 2010
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+
+struct tevent_context *server_event_ctx = NULL;
+
+struct tevent_context *server_event_context(void)
+{
+	if (!server_event_ctx) {
+		/*
+		 * Note we MUST use the NULL context here, not the
+		 * autofree context, to avoid side effects in forked
+		 * children exiting.
+		 */
+		server_event_ctx = s3_tevent_context_init(NULL);
+	}
+	if (!server_event_ctx) {
+		smb_panic("Could not init server's event context");
+	}
+	return server_event_ctx;
+}
+
+void server_event_context_free(void)
+{
+	TALLOC_FREE(server_event_ctx);
+}
+
+struct messaging_context *server_msg_ctx = NULL;
+
+struct messaging_context *server_messaging_context(void)
+{
+	if (server_msg_ctx == NULL) {
+		/*
+		 * Note we MUST use the NULL context here, not the
+		 * autofree context, to avoid side effects in forked
+		 * children exiting.
+		 */
+		server_msg_ctx = messaging_init(NULL,
+					        procid_self(),
+					        server_event_context());
+	}
+	if (server_msg_ctx == NULL) {
+		DEBUG(0, ("Could not init server's messaging context.\n"));
+	}
+	return server_msg_ctx;
+}
+
+void server_messaging_context_free(void)
+{
+	TALLOC_FREE(server_msg_ctx);
+}
diff --git a/source3/printing/notify.c b/source3/printing/notify.c
index 33807f7..a18b2fd 100644
--- a/source3/printing/notify.c
+++ b/source3/printing/notify.c
@@ -232,7 +232,7 @@ static void print_notify_event_send_messages(struct tevent_context *event_ctx,
 	TALLOC_FREE(notify_event);
 
 	change_to_root_user();
-	print_notify_send_messages(smbd_messaging_context(), 0);
+	print_notify_send_messages(server_messaging_context(), 0);
 }
 
 /**********************************************************************
@@ -326,9 +326,9 @@ to notify_queue_head\n", msg->type, msg->field, msg->printer));
 	DLIST_ADD_END(notify_queue_head, pnqueue, struct notify_queue *);
 	num_messages++;
 
-	if ((notify_event == NULL) && (smbd_event_context() != NULL)) {
+	if ((notify_event == NULL) && (server_event_context() != NULL)) {
 		/* Add an event for 1 second's time to send this queue. */
-		notify_event = tevent_add_timer(smbd_event_context(), NULL,
+		notify_event = tevent_add_timer(server_event_context(), NULL,
 					timeval_current_ofs(1,0),
 					print_notify_event_send_messages, NULL);
 	}
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index 7366f85..76a13cf 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -434,8 +434,8 @@ static bool cups_pcap_load_async(int *pfd)
 
 	close_all_print_db();
 
-	if (!NT_STATUS_IS_OK(reinit_after_fork(smbd_messaging_context(),
-					       smbd_event_context(), true))) {
+	if (!NT_STATUS_IS_OK(reinit_after_fork(server_messaging_context(),
+					       server_event_context(), true))) {
 		DEBUG(0,("cups_pcap_load_async: reinit_after_fork() failed\n"));
 		smb_panic("cups_pcap_load_async: reinit_after_fork() failed");
 	}
@@ -576,7 +576,7 @@ bool cups_cache_reload(void)
 		DEBUG(10,("cups_cache_reload: sync read on fd %d\n",
 			*p_pipe_fd ));
 
-		cups_async_callback(smbd_event_context(),
+		cups_async_callback(server_event_context(),
 					NULL,
 					EVENT_FD_READ,
 					(void *)p_pipe_fd);
@@ -592,7 +592,7 @@ bool cups_cache_reload(void)
 			*p_pipe_fd ));
 
 		/* Trigger an event when the pipe can be read. */
-		cache_fd_event = event_add_fd(smbd_event_context(),
+		cache_fd_event = event_add_fd(server_event_context(),
 					NULL, *p_pipe_fd,
 					EVENT_FD_READ,
 					cups_async_callback,
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 05728d1..74edb25 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1436,8 +1436,8 @@ void start_background_queue(void)
 		close(pause_pipe[0]);
 		pause_pipe[0] = -1;
 
-		if (!NT_STATUS_IS_OK(reinit_after_fork(smbd_messaging_context(),
-						       smbd_event_context(),
+		if (!NT_STATUS_IS_OK(reinit_after_fork(server_messaging_context(),
+						       server_event_context(),
 						       true))) {
 			DEBUG(0,("reinit_after_fork() failed\n"));
 			smb_panic("reinit_after_fork() failed");
@@ -1455,10 +1455,11 @@ void start_background_queue(void)
 			exit(1);
 		}
 
-		messaging_register(smbd_messaging_context(), NULL,
+		messaging_register(server_messaging_context(), NULL,
 				   MSG_PRINTER_UPDATE, print_queue_receive);
 
-		fde = tevent_add_fd(smbd_event_context(), smbd_event_context(),
+		fde = tevent_add_fd(server_event_context(),
+				    server_event_context(),
 				    pause_pipe[1], TEVENT_FD_READ,
 				    printing_pause_fd_handler,
 				    NULL);
@@ -1468,7 +1469,7 @@ void start_background_queue(void)
 		}
 
 		DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n"));
-		ret = tevent_loop_wait(smbd_event_context());
+		ret = tevent_loop_wait(server_event_context());
 		/* should not be reached */
 		DEBUG(0,("background_queue: tevent_loop_wait() exited with %d - %s\n",
 			 ret, (ret == 0) ? "out of events" : strerror(errno)));
@@ -1601,7 +1602,7 @@ static void print_queue_update(int snum, bool force)
 
 	/* finally send the message */
 
-	messaging_send_buf(smbd_messaging_context(),
+	messaging_send_buf(server_messaging_context(),
 			   pid_to_procid(background_lpq_updater_pid),
 			   MSG_PRINTER_UPDATE, (uint8 *)buffer, len);
 
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index fda8515..499f959 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -407,7 +407,7 @@ static void set_disp_info_cache_timeout(DISP_INFO *disp_info, time_t secs_fromno
 		  (unsigned int)secs_fromnow ));
 
 	disp_info->cache_timeout_event = event_add_timed(
-		smbd_event_context(), NULL,
+		server_event_context(), NULL,
 		timeval_current_ofs(secs_fromnow, 0),
 		disp_info_cache_idle_timeout_handler, (void *)disp_info);
 }
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index 3150b9f..5df835d 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -113,8 +113,6 @@ struct kernel_oplocks *koplocks = NULL;
 
 int am_parent = 1;
 int server_fd = -1;
-struct event_context *smbd_event_ctx = NULL;
-struct messaging_context *smbd_msg_ctx = NULL;
 struct memcache *smbd_memcache_ctx = NULL;
 bool exit_firsttime = true;
 struct child_pid *children = 0;
@@ -124,20 +122,7 @@ struct smbd_server_connection *smbd_server_conn = NULL;
 
 struct messaging_context *smbd_messaging_context(void)
 {
-	if (smbd_msg_ctx == NULL) {
-		/*
-		 * Note we MUST use the NULL context here, not the
-		 * autofree context, to avoid side effects in forked
-		 * children exiting.
-		 */
-		smbd_msg_ctx = messaging_init(NULL,
-					      procid_self(),
-					      smbd_event_context());
-	}
-	if (smbd_msg_ctx == NULL) {
-		DEBUG(0, ("Could not init smbd messaging context.\n"));
-	}
-	return smbd_msg_ctx;
+	return server_messaging_context();
 }
 
 struct memcache *smbd_memcache(void)
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index a7297d6..2bb0bb8 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -49,18 +49,7 @@ int get_client_fd(void)
 
 struct event_context *smbd_event_context(void)
 {
-	if (!smbd_event_ctx) {
-		/*
-		 * Note we MUST use the NULL context here, not the
-		 * autofree context, to avoid side effects in forked
-		 * children exiting.
-		 */
-		smbd_event_ctx = event_context_init(NULL);
-	}
-	if (!smbd_event_ctx) {
-		smb_panic("Could not init smbd event context");
-	}
-	return smbd_event_ctx;
+	return server_event_context();
 }
 
 /*******************************************************************
diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c
index 3e0da3e..1de9a09 100644
--- a/source3/smbd/server_exit.c
+++ b/source3/smbd/server_exit.c
@@ -119,8 +119,8 @@ static void exit_server_common(enum server_exit_reason how,
 	 */
 	sconn = NULL;
 	TALLOC_FREE(smbd_server_conn);
-	TALLOC_FREE(smbd_msg_ctx);
-	TALLOC_FREE(smbd_event_ctx);
+	server_messaging_context_free();
+	server_event_context_free();
 	TALLOC_FREE(smbd_memcache_ctx);
 
 	if (how != SERVER_EXIT_NORMAL) {
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index fcd3145..87a8be6 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -37,20 +37,6 @@ static bool interactive = False;
 
 extern bool override_logfile;
 
-struct messaging_context *winbind_messaging_context(void)
-{
-	static struct messaging_context *ctx;
-
-	if (ctx == NULL) {
-		ctx = messaging_init(NULL, procid_self(),
-				     winbind_event_context());
-	}
-	if (ctx == NULL) {
-		DEBUG(0, ("Could not init winbind messaging context.\n"));
-	}
-	return ctx;
-}
-
 /* Reload configuration */
 
 static bool reload_services_file(const char *lfile)
diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h
index b8835c0..91ebb6a 100644
--- a/source3/winbindd/winbindd.h
+++ b/source3/winbindd/winbindd.h
@@ -385,4 +385,7 @@ struct WINBINDD_CCACHE_ENTRY {
 #define WINBINDD_PAM_AUTH_KRB5_RENEW_TIME 2592000 /* one month */
 #define DOM_SEQUENCE_NONE ((uint32)-1)
 
+#define winbind_event_context server_event_context
+#define winbind_messaging_context server_messaging_context
+
 #endif /* _WINBINDD_H */
diff --git a/source3/winbindd/winbindd_event.c b/source3/winbindd/winbindd_event.c
deleted file mode 100644
index b6e8353..0000000
--- a/source3/winbindd/winbindd_event.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-
-   Winbind daemon for ntdom nss module
-
-   Copyright (C) by Tim Potter 2000-2002
-   Copyright (C) Andrew Tridgell 2002
-   Copyright (C) Jelmer Vernooij 2003
-   Copyright (C) Volker Lendecke 2004
-   Copyright (C) Andrew Bartlett 2010
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "winbindd.h"
-
-struct event_context *winbind_event_context(void)
-{
-	static struct event_context *winbindd_event_ctx;
-	if (!winbindd_event_ctx && !(winbindd_event_ctx = event_context_init(NULL))) {
-		smb_panic("Could not init winbind event context");
-	}
-	return winbindd_event_ctx;
-}
-
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 49e66f2..caa1cac 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -40,9 +40,6 @@ void debug_nt_user_token(int dbg_class, int dbg_lev, NT_USER_TOKEN *token);
 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
 			   int n_groups, gid_t *groups);
 
-/* The following definitions come from winbindd/winbindd_event.c  */
-struct event_context *winbind_event_context(void);
-
 /* The following definitions come from winbindd/winbindd.c  */
 struct messaging_context *winbind_messaging_context(void);
 void request_error(struct winbindd_cli_state *state);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list