diff options
author | Doug Rabson <dfr@FreeBSD.org> | 2008-06-26 10:21:54 +0000 |
---|---|---|
committer | Doug Rabson <dfr@FreeBSD.org> | 2008-06-26 10:21:54 +0000 |
commit | c675522fc4323ee02bfabe08fb00086132c32708 (patch) | |
tree | 994a214037913bc4e44eaee5070c65aeadf53485 /usr.sbin/rpc.statd/file.c | |
parent | 91bc389e54b5909c6fe96dbc593066ec4a5d9e81 (diff) | |
download | src-c675522fc4323ee02bfabe08fb00086132c32708.tar.gz src-c675522fc4323ee02bfabe08fb00086132c32708.zip |
Re-implement the client side of rpc.lockd in the kernel. This implementation
provides the correct semantics for flock(2) style locks which are used by the
lockf(1) command line tool and the pidfile(3) library. It also implements
recovery from server restarts and ensures that dirty cache blocks are written
to the server before obtaining locks (allowing multiple clients to use file
locking to safely share data).
Sponsored by: Isilon Systems
PR: 94256
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=180025
Diffstat (limited to 'usr.sbin/rpc.statd/file.c')
-rw-r--r-- | usr.sbin/rpc.statd/file.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/usr.sbin/rpc.statd/file.c b/usr.sbin/rpc.statd/file.c index efcaaaf537b4..0625e30b9f85 100644 --- a/usr.sbin/rpc.statd/file.c +++ b/usr.sbin/rpc.statd/file.c @@ -36,6 +36,7 @@ #include <err.h> #include <errno.h> #include <fcntl.h> +#include <netdb.h> #include <stdio.h> #include <string.h> #include <unistd.h> @@ -78,8 +79,11 @@ HostInfo *find_host(char *hostname, int create) HostInfo *hp; HostInfo *spare_slot = NULL; HostInfo *result = NULL; + struct addrinfo *ai1, *ai2; int i; + if (getaddrinfo(hostname, NULL, NULL, &ai1) != 0) + ai1 = NULL; for (i = 0, hp = status_info->hosts; i < status_info->noOfHosts; i++, hp++) { if (!strncasecmp(hostname, hp->hostname, SM_MAXSTRLEN)) @@ -87,9 +91,35 @@ HostInfo *find_host(char *hostname, int create) result = hp; break; } + if (hp->hostname[0] && + getaddrinfo(hp->hostname, NULL, NULL, &ai2) != 0) + ai2 = NULL; + if (ai1 && ai2) + { + struct addrinfo *p1, *p2; + for (p1 = ai1; !result && p1; p1 = p1->ai_next) + { + for (p2 = ai2; !result && p2; p2 = p2->ai_next) + { + if (p1->ai_family == p2->ai_family + && p1->ai_addrlen == p2->ai_addrlen + && !memcmp(p1->ai_addr, p2->ai_addr, p1->ai_addrlen)) + { + result = hp; + break; + } + } + } + if (result) + break; + } + if (ai2) + freeaddrinfo(ai2); if (!spare_slot && !hp->monList && !hp->notifyReqd) spare_slot = hp; } + if (ai1) + freeaddrinfo(ai1); /* Return if entry found, or if not asked to create one. */ if (result || !create) return (result); |