diff options
| author | Ben Myers <bpm@sgi.com> | 2009-04-03 15:13:10 -0400 |
|---|---|---|
| committer | Steve Dickson <steved@redhat.com> | 2009-04-03 15:13:10 -0400 |
| commit | f0ed8401e854e1cbd23b2fb5dca5e88dec2df7c4 (patch) | |
| tree | e525bec15e10a3c984dbc6b26b075a7433e0d417 /utils/mountd | |
| parent | c56152202a3000c69b87f9cb90f40166f1f21275 (diff) | |
| download | nfs-utils-f0ed8401e854e1cbd23b2fb5dca5e88dec2df7c4.tar.gz nfs-utils-f0ed8401e854e1cbd23b2fb5dca5e88dec2df7c4.tar.xz nfs-utils-f0ed8401e854e1cbd23b2fb5dca5e88dec2df7c4.zip | |
Mountd should use separate lockfiles
Mountd keeps file descriptors used for locks separate from
those used for io and seems to assume that the lock will
only be released on close of the file descriptor that was used
with fcntl. Actually the lock is released when any file
descriptor for that file is closed. When setexportent() is called
after xflock() he closes and reopens the io file descriptor and defeats the
lock.
This patch fixes that by using a separate file for locking, cleaning
them up when finished.
Signed-off-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils/mountd')
| -rw-r--r-- | utils/mountd/mountd.c | 10 | ||||
| -rw-r--r-- | utils/mountd/rmtab.c | 8 |
2 files changed, 14 insertions, 4 deletions
diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index 8084359..25d292b 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -88,6 +88,14 @@ unregister_services (void) pmap_unset (MOUNTPROG, MOUNTVERS_NFSV3); } +static void +cleanup_lockfiles (void) +{ + unlink(_PATH_XTABLCK); + unlink(_PATH_ETABLCK); + unlink(_PATH_RMTABLCK); +} + /* Wait for all worker child processes to exit and reap them */ static void wait_for_workers (void) @@ -154,6 +162,7 @@ fork_workers(void) /* in parent */ wait_for_workers(); unregister_services(); + cleanup_lockfiles(); xlog(L_NOTICE, "mountd: no more workers, exiting\n"); exit(0); } @@ -170,6 +179,7 @@ killer (int sig) kill(0, SIGTERM); wait_for_workers(); } + cleanup_lockfiles(); xlog (L_FATAL, "Caught signal %d, un-registering and exiting.", sig); } diff --git a/utils/mountd/rmtab.c b/utils/mountd/rmtab.c index 5787ed6..c371f8d 100644 --- a/utils/mountd/rmtab.c +++ b/utils/mountd/rmtab.c @@ -58,7 +58,7 @@ mountlist_add(char *host, const char *path) int lockid; long pos; - if ((lockid = xflock(_PATH_RMTAB, "a")) < 0) + if ((lockid = xflock(_PATH_RMTABLCK, "a")) < 0) return; setrmtabent("r+"); while ((rep = getrmtabent(1, &pos)) != NULL) { @@ -98,7 +98,7 @@ mountlist_del(char *hname, const char *path) int lockid; int match; - if ((lockid = xflock(_PATH_RMTAB, "w")) < 0) + if ((lockid = xflock(_PATH_RMTABLCK, "w")) < 0) return; if (!setrmtabent("r")) { xfunlock(lockid); @@ -139,7 +139,7 @@ mountlist_del_all(struct sockaddr_in *sin) FILE *fp; int lockid; - if ((lockid = xflock(_PATH_RMTAB, "w")) < 0) + if ((lockid = xflock(_PATH_RMTABLCK, "w")) < 0) return; if (!(hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET))) { xlog(L_ERROR, "can't get hostname of %s", inet_ntoa(addr)); @@ -188,7 +188,7 @@ mountlist_list(void) struct in_addr addr; struct hostent *he; - if ((lockid = xflock(_PATH_RMTAB, "r")) < 0) + if ((lockid = xflock(_PATH_RMTABLCK, "r")) < 0) return NULL; if (stat(_PATH_RMTAB, &stb) < 0) { xlog(L_ERROR, "can't stat %s", _PATH_RMTAB); |
