From 3dde0cbb769b92d922be13677ad076cae9b6a693 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 Jan 2009 12:03:45 +0100 Subject: s3:smbd: move all globals and static variables in globals.[ch] The goal is to move all this variables into a big context structure. metze --- source3/smbd/server.c | 62 +++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) (limited to 'source3/smbd/server.c') diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 26c9b62dce..6be8e9b83e 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -22,28 +22,14 @@ */ #include "includes.h" +#include "smbd/globals.h" static_decl_rpc; -static int am_parent = 1; - -extern struct auth_context *negprot_global_auth_context; -extern SIG_ATOMIC_T got_sig_term; -extern SIG_ATOMIC_T reload_after_sighup; -static SIG_ATOMIC_T got_sig_cld; - #ifdef WITH_DFS extern int dcelogin_atmost_once; #endif /* WITH_DFS */ -/* really we should have a top level context structure that has the - client file descriptor as an element. That would require a major rewrite :( - - the following 2 functions are an alternative - they make the file - descriptor private to smbd - */ -static int server_fd = -1; - int smbd_server_fd(void) { return server_fd; @@ -81,39 +67,39 @@ static int client_get_tcp_info(struct sockaddr_storage *server, struct event_context *smbd_event_context(void) { - static struct event_context *ctx; - - if (!ctx && !(ctx = event_context_init(talloc_autofree_context()))) { + if (!smbd_event_ctx) { + smbd_event_ctx = event_context_init(talloc_autofree_context()); + } + if (!smbd_event_ctx) { smb_panic("Could not init smbd event context"); } - return ctx; + return smbd_event_ctx; } struct messaging_context *smbd_messaging_context(void) { - static struct messaging_context *ctx; - - if (ctx == NULL) { - ctx = messaging_init(talloc_autofree_context(), server_id_self(), - smbd_event_context()); + if (smbd_msg_ctx == NULL) { + smbd_msg_ctx = messaging_init(talloc_autofree_context(), + server_id_self(), + smbd_event_context()); } - if (ctx == NULL) { + if (smbd_msg_ctx == NULL) { DEBUG(0, ("Could not init smbd messaging context.\n")); } - return ctx; + return smbd_msg_ctx; } struct memcache *smbd_memcache(void) { - static struct memcache *cache; - - if (!cache - && !(cache = memcache_init(talloc_autofree_context(), - lp_max_stat_cache_size()*1024))) { - + if (!smbd_memcache_ctx) { + smbd_memcache_ctx = memcache_init(talloc_autofree_context(), + lp_max_stat_cache_size()*1024); + } + if (!smbd_memcache_ctx) { smb_panic("Could not init smbd memcache"); } - return cache; + + return smbd_memcache_ctx; } /******************************************************************* @@ -269,9 +255,6 @@ struct child_pid { pid_t pid; }; -static struct child_pid *children; -static int num_children; - static void add_child_pid(pid_t pid) { struct child_pid *child; @@ -891,12 +874,11 @@ static void exit_server_common(enum server_exit_reason how, static void exit_server_common(enum server_exit_reason how, const char *const reason) { - static int firsttime=1; bool had_open_conn; - if (!firsttime) + if (!exit_firsttime) exit(0); - firsttime = 0; + exit_firsttime = false; change_to_root_user(); @@ -1136,6 +1118,8 @@ extern void build_options(bool screen); }; TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */ + smbd_init_globals(); + TimeInit(); #ifdef HAVE_SET_AUTH_PARAMETERS -- cgit