FreeBSD Bugzilla – Attachment 215182 Details for
Bug 246597
Race condition in mountd
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
fix the race between SIGHUP and exports reload
mountd-reload.patch (text/plain), 2.26 KB, created by
Rick Macklem
on 2020-06-03 00:02:12 UTC
(
hide
)
Description:
fix the race between SIGHUP and exports reload
Filename:
MIME Type:
Creator:
Rick Macklem
Created:
2020-06-03 00:02:12 UTC
Size:
2.26 KB
patch
obsolete
>--- usr.sbin/mountd/mountd.c.reload 2020-06-02 16:22:42.032503000 -0700 >+++ usr.sbin/mountd/mountd.c 2020-06-02 16:45:21.706425000 -0700 >@@ -309,6 +309,12 @@ static struct pidfh *pfh = NULL; > #define OP_MASKLEN 0x200 > #define OP_SEC 0x400 > >+/* >+ * How long to delay a reload of exports when there are RPC request(s) >+ * to process, in usec. >+ */ >+#define RELOADDELAY 250000 >+ > #ifdef DEBUG > static int debug = 1; > static void SYSLOG(int, const char *, ...) __printflike(2, 3); >@@ -413,6 +419,9 @@ main(int argc, char **argv) > 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 @@ main(int argc, char **argv) > } > > /* 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);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 246597
:
215182
|
215283