X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=source3%2Fnmbd%2Fnmbd.c;h=5392eb1d659ffefa804906fb39a76b90106e5aa8;hb=37e7981eeaa1c4020a7bc4b90a6808d148d5c2e3;hp=8c41ebbde6e9e34518e458217c35014fafa4610f;hpb=505761b5a3f3e34e3b0e7c8b9b0198c8572f7b9d;p=kai%2Fsamba.git diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 8c41ebbde6e..5392eb1d659 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -47,21 +47,11 @@ struct event_context *nmbd_event_context(void) return server_event_context(); } -static struct messaging_context *nmbd_messaging_context(void) -{ - struct messaging_context *msg_ctx = server_messaging_context(); - if (likely(msg_ctx != NULL)) { - return msg_ctx; - } - smb_panic("Could not init nmbd's messaging context.\n"); - return NULL; -} - /**************************************************************************** ** Handle a SIGTERM in band. **************************************************************************** */ -static void terminate(void) +static void terminate(struct messaging_context *msg) { DEBUG(0,("Got SIGTERM: going down...\n")); @@ -78,7 +68,7 @@ static void terminate(void) kill_async_dns_child(); gencache_stabilize(); - serverid_deregister(procid_self()); + serverid_deregister(messaging_server_id(msg)); pidfile_unlink(); @@ -92,10 +82,13 @@ static void nmbd_sig_term_handler(struct tevent_context *ev, void *siginfo, void *private_data) { - terminate(); + struct messaging_context *msg = talloc_get_type_abort( + private_data, struct messaging_context); + + terminate(msg); } -static bool nmbd_setup_sig_term_handler(void) +static bool nmbd_setup_sig_term_handler(struct messaging_context *msg) { struct tevent_signal *se; @@ -103,7 +96,7 @@ static bool nmbd_setup_sig_term_handler(void) nmbd_event_context(), SIGTERM, 0, nmbd_sig_term_handler, - NULL); + msg); if (!se) { DEBUG(0,("failed to setup SIGTERM handler")); return false; @@ -125,13 +118,15 @@ static void nmbd_sig_hup_handler(struct tevent_context *ev, void *siginfo, void *private_data) { + struct messaging_context *msg = talloc_get_type_abort( + private_data, struct messaging_context); + DEBUG(0,("Got SIGHUP dumping debug info.\n")); - msg_reload_nmbd_services(nmbd_messaging_context(), - NULL, MSG_SMB_CONF_UPDATED, - procid_self(), NULL); + msg_reload_nmbd_services(msg, NULL, MSG_SMB_CONF_UPDATED, + messaging_server_id(msg), NULL); } -static bool nmbd_setup_sig_hup_handler(void) +static bool nmbd_setup_sig_hup_handler(struct messaging_context *msg) { struct tevent_signal *se; @@ -139,7 +134,7 @@ static bool nmbd_setup_sig_hup_handler(void) nmbd_event_context(), SIGHUP, 0, nmbd_sig_hup_handler, - NULL); + msg); if (!se) { DEBUG(0,("failed to setup SIGHUP handler")); return false; @@ -158,7 +153,7 @@ static void nmbd_terminate(struct messaging_context *msg, struct server_id server_id, DATA_BLOB *data) { - terminate(); + terminate(msg); } /**************************************************************************** ** @@ -730,14 +725,15 @@ static bool open_sockets(bool isdaemon, int port) int main(int argc, const char *argv[]) { - static bool is_daemon; - static bool opt_interactive; - static bool Fork = true; - static bool no_process_group; - static bool log_stdout; + bool is_daemon; + bool opt_interactive; + bool Fork = true; + bool no_process_group; + bool log_stdout; poptContext pc; char *p_lmhosts = NULL; int opt; + struct messaging_context *msg; enum { OPT_DAEMON = 1000, OPT_INTERACTIVE, @@ -859,7 +855,8 @@ static bool open_sockets(bool isdaemon, int port) exit(1); } - if (nmbd_messaging_context() == NULL) { + msg = messaging_init(NULL, server_event_context()); + if (msg == NULL) { return 1; } @@ -897,15 +894,11 @@ static bool open_sockets(bool isdaemon, int port) setpgid( (pid_t)0, (pid_t)0 ); #endif - if (nmbd_messaging_context() == NULL) { - return 1; - } - #ifndef SYNC_DNS /* Setup the async dns. We do it here so it doesn't have all the other stuff initialised and thus chewing memory and sockets */ if(lp_we_are_a_wins_server() && lp_dns_proxy()) { - start_async_dns(nmbd_messaging_context()); + start_async_dns(msg); } #endif @@ -915,8 +908,7 @@ static bool open_sockets(bool isdaemon, int port) pidfile_create("nmbd"); - status = reinit_after_fork(nmbd_messaging_context(), - nmbd_event_context(), + status = reinit_after_fork(msg, nmbd_event_context(), false); if (!NT_STATUS_IS_OK(status)) { @@ -924,14 +916,14 @@ static bool open_sockets(bool isdaemon, int port) exit(1); } - if (!nmbd_setup_sig_term_handler()) + if (!nmbd_setup_sig_term_handler(msg)) exit(1); - if (!nmbd_setup_sig_hup_handler()) + if (!nmbd_setup_sig_hup_handler(msg)) exit(1); /* get broadcast messages */ - if (!serverid_register(procid_self(), + if (!serverid_register(messaging_server_id(msg), FLAG_MSG_GENERAL | FLAG_MSG_NMBD | FLAG_MSG_DBWRAP)) { @@ -939,19 +931,19 @@ static bool open_sockets(bool isdaemon, int port) exit(1); } - messaging_register(nmbd_messaging_context(), NULL, - MSG_FORCE_ELECTION, nmbd_message_election); + messaging_register(msg, NULL, MSG_FORCE_ELECTION, + nmbd_message_election); #if 0 /* Until winsrepl is done. */ - messaging_register(nmbd_messaging_context(), NULL, - MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry); + messaging_register(msg, NULL, MSG_WINS_NEW_ENTRY, + nmbd_wins_new_entry); #endif - messaging_register(nmbd_messaging_context(), NULL, - MSG_SHUTDOWN, nmbd_terminate); - messaging_register(nmbd_messaging_context(), NULL, - MSG_SMB_CONF_UPDATED, msg_reload_nmbd_services); - messaging_register(nmbd_messaging_context(), NULL, - MSG_SEND_PACKET, msg_nmbd_send_packet); + messaging_register(msg, NULL, MSG_SHUTDOWN, + nmbd_terminate); + messaging_register(msg, NULL, MSG_SMB_CONF_UPDATED, + msg_reload_nmbd_services); + messaging_register(msg, NULL, MSG_SEND_PACKET, + msg_nmbd_send_packet); TimeInit(); @@ -1012,7 +1004,7 @@ static bool open_sockets(bool isdaemon, int port) } TALLOC_FREE(frame); - process(nmbd_messaging_context()); + process(msg); kill_async_dns_child(); return(0);