{
static struct messaging_context *ctx;
- if (!ctx && !(ctx = messaging_init(NULL, server_id_self(),
- nmbd_event_context()))) {
- smb_panic("Could not init nmbd messaging context");
+ if (ctx == NULL) {
+ ctx = messaging_init(NULL, server_id_self(),
+ nmbd_event_context());
+ }
+ if (ctx == NULL) {
+ DEBUG(0, ("Could not init nmbd messaging context.\n"));
}
return ctx;
}
* ignore it here. JRA.
*/
- if (is_loopback_addr(&iface->ip)) {
+ if (is_loopback_addr((struct sockaddr *)&iface->ip)) {
DEBUG(2,("reload_interfaces: Ignoring loopback "
"interface %s\n",
print_sockaddr(str, sizeof(str), &iface->ip) ));
/* We need to wait if there are no subnets... */
if (FIRST_SUBNET == NULL) {
+ void (*saved_handler)(int);
if (print_waiting_msg) {
DEBUG(0,("reload_interfaces: "
* Whilst we're waiting for an interface, allow SIGTERM to
* cause us to exit.
*/
+ saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL );
- BlockSignals(false, SIGTERM);
-
- /* We only count IPv4 interfaces here. */
- while (iface_count_v4() == 0 && !got_sig_term) {
+ /* We only count IPv4, non-loopback interfaces here. */
+ while (iface_count_v4_nl() == 0) {
sleep(5);
load_interfaces();
}
- /*
- * Handle termination inband.
- */
-
- if (got_sig_term) {
- got_sig_term = 0;
- terminate();
- }
+ CatchSignal( SIGTERM, SIGNAL_CAST saved_handler );
/*
* We got an interface, go back to blocking term.
*/
- BlockSignals(true, SIGTERM);
goto try_again;
}
}
if ( lp_loaded() ) {
const char *fname = lp_configfile();
- if (file_exist(fname,NULL) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
+ if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
set_dyn_CONFIGFILE(fname);
test = False;
}
}
in_addr_to_sockaddr_storage(&ss, p->ip);
- pss = iface_ip(&ss);
+ pss = iface_ip((struct sockaddr *)&ss);
if (pss == NULL) {
DEBUG(2, ("Could not find ip for packet from %d\n",
time_t t = time(NULL);
TALLOC_CTX *frame = talloc_stackframe();
- /* Check for internal messages */
-
- message_dispatch(nmbd_messaging_context());
-
/*
* Check all broadcast subnets to see if
* we need to run an election on any of them.
sys_srandom(time(NULL) ^ sys_getpid());
if (!override_logfile) {
- char *logfile = NULL;
- if (asprintf(&logfile, "%s/log.nmbd", get_dyn_LOGFILEBASE()) < 0) {
+ char *lfile = NULL;
+ if (asprintf(&lfile, "%s/log.nmbd", get_dyn_LOGFILEBASE()) < 0) {
exit(1);
}
- lp_set_logfile(logfile);
- SAFE_FREE(logfile);
+ lp_set_logfile(lfile);
+ SAFE_FREE(lfile);
}
fault_setup((void (*)(void *))fault_continue );
reopen_logs();
- DEBUG(0,("nmbd version %s started.\n", SAMBA_VERSION_STRING));
+ DEBUG(0,("nmbd version %s started.\n", samba_version_string()));
DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
- db_tdb2_setup_messaging(NULL, false);
+ if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
+ DEBUG(0, ("error opening config file\n"));
+ exit(1);
+ }
+
+ if (nmbd_messaging_context() == NULL) {
+ return 1;
+ }
if ( !reload_nmbd_services(False) )
return(-1);
}
#endif
- if (!directory_exist(lp_lockdir(), NULL)) {
+ if (!directory_exist(lp_lockdir())) {
mkdir(lp_lockdir(), 0755);
}
pidfile_create("nmbd");
+ if (!reinit_after_fork(nmbd_messaging_context(),
+ nmbd_event_context(), false)) {
+ DEBUG(0,("reinit_after_fork() failed\n"));
+ exit(1);
+ }
+
/* get broadcast messages */
claim_connection(NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP);
messaging_register(nmbd_messaging_context(), NULL,
MSG_SEND_PACKET, msg_nmbd_send_packet);
- db_tdb2_setup_messaging(nmbd_messaging_context(), true);
-
TimeInit();
DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );
exit(1);
}
- /* We can only take signals in the select. */
- BlockSignals( True, SIGTERM );
-
TALLOC_FREE(frame);
process();