Example #1
0
/*ARGSUSED*/
static void *
smbd_localtime_monitor(void *arg)
{
	struct tm local_tm;
	time_t secs;
	int32_t gmtoff, last_gmtoff = -1;
	int timeout;
	int error;

	smbd_online_wait("smbd_localtime_monitor");

	for (;;) {
		gmtoff = smbd_gmtoff();

		if ((last_gmtoff != gmtoff) && smbd.s_kbound) {
			error = smb_kmod_setgmtoff(gmtoff);
			if (error != 0)
				smbd_report("localtime set failed: %s",
				    strerror(error));
		}

		/*
		 * Align the next iteration on a fifteen minute boundary.
		 */
		secs = time(0);
		(void) localtime_r(&secs, &local_tm);
		timeout = ((15 - (local_tm.tm_min % 15)) * SECSPERMIN);
		(void) sleep(timeout);

		last_gmtoff = gmtoff;
	}

	/*NOTREACHED*/
	return (NULL);
}
Example #2
0
/*ARGSUSED*/
static void *
smbd_spool_monitor(void *arg)
{
    uint32_t	spool_num;
    char		username[MAXNAMELEN];
    char		path[MAXPATHLEN];
    smb_inaddr_t	ipaddr;
    int		error_retry_cnt = 5;

    smbd_online_wait("smbd_spool_monitor");

    spoolss_register_copyfile(smbd_spool_copyfile);

    while (!smbd.s_shutting_down && (error_retry_cnt > 0)) {
        errno = 0;

        if (smb_kmod_get_spool_doc(&spool_num, username,
                                   path, &ipaddr) == 0) {
            smbd_spool_copyfile(&ipaddr,
                                username, path, SMBD_CUPS_DOCNAME);
            error_retry_cnt = 5;
        } else {
            if (errno == ECANCELED)
                break;
            if ((errno != EINTR) && (errno != EAGAIN))
                error_retry_cnt--;
            (void) sleep(SMB_SPOOL_WAIT);
        }
    }

    spoolss_register_copyfile(NULL);
    smbd.s_spool_tid = 0;
    return (NULL);
}
Example #3
0
/*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);
}