Page MenuHomeFreeBSD

D25127.1794739487.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D25127.1794739487.diff

Index: usr.sbin/mountd/mountd.c
===================================================================
--- usr.sbin/mountd/mountd.c
+++ usr.sbin/mountd/mountd.c
@@ -193,6 +193,12 @@
#define GETPORT_MAXTRY 20 /* Max tries to get a port # */
+/*
+ * How long to delay a reload of exports when there are RPC request(s)
+ * to process, in usec. Must be less than 1second.
+ */
+#define RELOADDELAY 250000
+
/* Global defs */
static char *add_expdir(struct dirlist **, char *, int);
static void add_dlist(struct dirlist **, struct dirlist *,
@@ -413,6 +419,9 @@
int maxrec = RPC_MAXDATASIZE;
int attempt_cnt, port_len, port_pos, ret;
char **port_list;
+ uint64_t curtime, nexttime;
+ struct timeval tv;
+ sigset_t sighup_mask;
/* Check that another mountd isn't already running. */
pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &otherpid);
@@ -668,19 +677,47 @@
}
/* Expand svc_run() here so that we can call get_exportlist(). */
+ curtime = nexttime = 0;
+ sigemptyset(&sighup_mask);
+ sigaddset(&sighup_mask, SIGHUP);
for (;;) {
- if (got_sighup) {
- get_exportlist(1);
+ gettimeofday(&tv, NULL);
+ curtime = tv.tv_sec * 1000000 + tv.tv_usec;
+ sigprocmask(SIG_BLOCK, &sighup_mask, NULL);
+ if (got_sighup && curtime >= nexttime) {
got_sighup = 0;
- }
+ sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
+ get_exportlist(1);
+ gettimeofday(&tv, NULL);
+ nexttime = tv.tv_sec * 1000000 + tv.tv_usec +
+ RELOADDELAY;
+ } else
+ sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
+
+ /*
+ * If a reload is pending, poll for received request(s),
+ * otherwise set a RELOADDELAY timeout, since a SIGHUP
+ * could be processed between the got_sighup test and
+ * the select() system call.
+ */
+ tv.tv_sec = 0;
+ if (got_sighup)
+ tv.tv_usec = 0;
+ else
+ tv.tv_usec = RELOADDELAY;
readfds = svc_fdset;
- switch (select(svc_maxfd + 1, &readfds, NULL, NULL, NULL)) {
+ switch (select(svc_maxfd + 1, &readfds, NULL, NULL, &tv)) {
case -1:
- if (errno == EINTR)
+ if (errno == EINTR) {
+ /* Allow a reload now. */
+ nexttime = 0;
continue;
+ }
syslog(LOG_ERR, "mountd died: select: %m");
exit(1);
case 0:
+ /* Allow a reload now. */
+ nexttime = 0;
continue;
default:
svc_getreqset(&readfds);

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 15, 10:44 AM (20 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41741805
Default Alt Text
D25127.1794739487.diff (2 KB)

Event Timeline