/* * Shutdown smbd and smbsrv kernel services. * * Called only by the main thread. */ static void smbd_service_fini(void) { smbd.s_shutting_down = B_TRUE; smbd_report("service shutting down"); smb_kmod_stop(); smb_logon_abort(); smb_lgrp_stop(); smbd_pipesvc_stop(); smbd_door_stop(); smbd_spool_stop(); smbd_kernel_unbind(); smbd_share_stop(); smb_shr_stop(); dyndns_stop(); smbd_nicmon_stop(); smb_ccache_remove(SMB_CCACHE_PATH); smb_pwd_fini(); smb_domain_fini(); mlsvc_fini(); smb_netbios_stop(); smbd_cups_fini(); smbd.s_initialized = B_FALSE; smbd_report("service terminated"); closelog(); }
/*ARGSUSED*/ static void * smbd_refresh_monitor(void *arg) { smbd_online_wait("smbd_refresh_monitor"); while (!smbd.s_shutting_down) { (void) sleep(SMBD_REFRESH_INTERVAL); (void) pthread_mutex_lock(&refresh_mutex); while ((atomic_swap_uint(&smbd.s_refreshes, 0) == 0) && (!smbd.s_shutting_down)) (void) pthread_cond_wait(&refresh_cond, &refresh_mutex); (void) pthread_mutex_unlock(&refresh_mutex); if (smbd.s_shutting_down) { smbd_service_fini(); /*NOTREACHED*/ } (void) mutex_lock(&smbd_service_mutex); smbd_dc_monitor_refresh(); smb_ccache_remove(SMB_CCACHE_PATH); /* * Clear the DNS zones for the existing interfaces * before updating the NIC interface list. */ dyndns_clear_zones(); if (smbd_nicmon_refresh() != 0) smbd_report("NIC monitor refresh failed"); smb_netbios_name_reconfig(); smb_browser_reconfig(); dyndns_update_zones(); (void) smbd_kernel_bind(); smbd_load_shares(); smbd_load_printers(); (void) mutex_unlock(&smbd_service_mutex); } smbd.s_refresh_tid = 0; return (NULL); }
/* * Shutdown smbd and smbsrv kernel services. * * Shutdown will not begin until initialization has completed. * Only one thread is allowed to perform the shutdown. Other * threads will be blocked on fini_in_progress until the process * has exited. */ static void smbd_service_fini(void) { static uint_t fini_in_progress; (void) mutex_lock(&smbd_service_mutex); while (!smbd.s_initialized) (void) cond_wait(&smbd_service_cv, &smbd_service_mutex); if (atomic_swap_uint(&fini_in_progress, 1) != 0) { while (fini_in_progress) (void) cond_wait(&smbd_service_cv, &smbd_service_mutex); /*NOTREACHED*/ } smbd.s_shutting_down = B_TRUE; smbd_report("service shutting down"); smb_kmod_stop(); smb_logon_abort(); smb_lgrp_stop(); smbd_opipe_stop(); smbd_door_stop(); smbd_refresh_fini(); smbd_kernel_unbind(); smbd_share_stop(); smb_shr_stop(); dyndns_stop(); smbd_nicmon_stop(); smb_ccache_remove(SMB_CCACHE_PATH); smb_pwd_fini(); smb_domain_fini(); mlsvc_fini(); smb_netbios_stop(); smbd_cups_fini(); smbd.s_initialized = B_FALSE; smbd_report("service terminated"); (void) mutex_unlock(&smbd_service_mutex); exit((smbd.s_fatal_error) ? SMF_EXIT_ERR_FATAL : SMF_EXIT_OK); }
/* * Called when SMF sends us a SIGHUP. Update the smbd configuration * from SMF and check for changes that require service reconfiguration. */ static void smbd_refresh_handler() { int new_debug; if (smbd.s_shutting_down) return; smbd.s_refreshes++; new_debug = smb_config_get_debug(); if (smbd.s_debug || new_debug) smbd_report("debug=%d", new_debug); smbd.s_debug = new_debug; smbd_spool_stop(); smbd_dc_monitor_refresh(); smb_ccache_remove(SMB_CCACHE_PATH); /* * Clear the DNS zones for the existing interfaces * before updating the NIC interface list. */ dyndns_clear_zones(); if (smbd_nicmon_refresh() != 0) smbd_report("NIC monitor refresh failed"); smb_netbios_name_reconfig(); smb_browser_reconfig(); dyndns_update_zones(); /* This reloads the in-kernel config. */ (void) smbd_kernel_bind(); smbd_load_shares(); smbd_load_printers(); smbd_spool_start(); }