diff options
Diffstat (limited to 'source3/smbd/server.c')
-rw-r--r-- | source3/smbd/server.c | 84 |
1 files changed, 31 insertions, 53 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c index a84b58a052..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; @@ -360,13 +343,7 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ } #ifdef HAVE_ATEXIT - { - static int atexit_set; - if(atexit_set == 0) { - atexit_set=1; - atexit(killkids); - } - } + atexit(killkids); #endif /* Stop zombies */ @@ -897,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(); @@ -1109,13 +1085,13 @@ extern void build_options(bool screen); int main(int argc,const char *argv[]) { /* shall I run as a daemon */ - static bool is_daemon = False; - static bool interactive = False; - static bool Fork = True; - static bool no_process_group = False; - static bool log_stdout = False; - static char *ports = NULL; - static char *profile_level = NULL; + bool is_daemon = false; + bool interactive = false; + bool Fork = true; + bool no_process_group = false; + bool log_stdout = false; + char *ports = NULL; + char *profile_level = NULL; int opt; poptContext pc; bool print_build_options = False; @@ -1142,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 |