View | Details | Raw Unified | Return to bug 246597 | Differences between
and this patch

Collapse All | Expand All

(-)usr.sbin/mountd/mountd.c (-5 / +45 lines)
Lines 193-198 struct fhreturn { Link Here
193
193
194
#define	GETPORT_MAXTRY	20	/* Max tries to get a port # */
194
#define	GETPORT_MAXTRY	20	/* Max tries to get a port # */
195
195
196
/*
197
 * How long to delay a reload of exports when there are RPC request(s)
198
 * to process, in usec.  Must be less than 1second.
199
 */
200
#define	RELOADDELAY	250000
201
196
/* Global defs */
202
/* Global defs */
197
static char	*add_expdir(struct dirlist **, char *, int);
203
static char	*add_expdir(struct dirlist **, char *, int);
198
static void	add_dlist(struct dirlist **, struct dirlist *,
204
static void	add_dlist(struct dirlist **, struct dirlist *,
Lines 413-418 main(int argc, char **argv) Link Here
413
	int maxrec = RPC_MAXDATASIZE;
419
	int maxrec = RPC_MAXDATASIZE;
414
	int attempt_cnt, port_len, port_pos, ret;
420
	int attempt_cnt, port_len, port_pos, ret;
415
	char **port_list;
421
	char **port_list;
422
	uint64_t curtime, nexttime;
423
	struct timeval tv;
424
	struct timespec tp;
425
	sigset_t sighup_mask;
416
426
417
	/* Check that another mountd isn't already running. */
427
	/* Check that another mountd isn't already running. */
418
	pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &otherpid);
428
	pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &otherpid);
Lines 668-686 main(int argc, char **argv) Link Here
668
	}
678
	}
669
679
670
	/* Expand svc_run() here so that we can call get_exportlist(). */
680
	/* Expand svc_run() here so that we can call get_exportlist(). */
681
	curtime = nexttime = 0;
682
	sigemptyset(&sighup_mask);
683
	sigaddset(&sighup_mask, SIGHUP);
671
	for (;;) {
684
	for (;;) {
672
		if (got_sighup) {
685
		clock_gettime(CLOCK_MONOTONIC, &tp);
673
			get_exportlist(1);
686
		curtime = tp.tv_sec;
687
		curtime = curtime * 1000000 + tp.tv_nsec / 1000;
688
		sigprocmask(SIG_BLOCK, &sighup_mask, NULL);
689
		if (got_sighup && curtime >= nexttime) {
674
			got_sighup = 0;
690
			got_sighup = 0;
675
		}
691
			sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
692
			get_exportlist(1);
693
			clock_gettime(CLOCK_MONOTONIC, &tp);
694
			nexttime = tp.tv_sec;
695
			nexttime = nexttime * 1000000 + tp.tv_nsec / 1000 +
696
			    RELOADDELAY;
697
		} else
698
			sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
699
700
		/*
701
		 * If a reload is pending, poll for received request(s),
702
		 * otherwise set a RELOADDELAY timeout, since a SIGHUP
703
		 * could be processed between the got_sighup test and
704
		 * the select() system call.
705
		 */
706
		tv.tv_sec = 0;
707
		if (got_sighup)
708
			tv.tv_usec = 0;
709
		else
710
			tv.tv_usec = RELOADDELAY;
676
		readfds = svc_fdset;
711
		readfds = svc_fdset;
677
		switch (select(svc_maxfd + 1, &readfds, NULL, NULL, NULL)) {
712
		switch (select(svc_maxfd + 1, &readfds, NULL, NULL, &tv)) {
678
		case -1:
713
		case -1:
679
			if (errno == EINTR)
714
			if (errno == EINTR) {
715
				/* Allow a reload now. */
716
				nexttime = 0;
680
                                continue;
717
                                continue;
718
			}
681
			syslog(LOG_ERR, "mountd died: select: %m");
719
			syslog(LOG_ERR, "mountd died: select: %m");
682
			exit(1);
720
			exit(1);
683
		case 0:
721
		case 0:
722
			/* Allow a reload now. */
723
			nexttime = 0;
684
			continue;
724
			continue;
685
		default:
725
		default:
686
			svc_getreqset(&readfds);
726
			svc_getreqset(&readfds);

Return to bug 246597