summaryrefslogtreecommitdiffstats
path: root/lib/libc/yp
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1996-03-23 22:48:19 +0000
committerwpaul <wpaul@FreeBSD.org>1996-03-23 22:48:19 +0000
commit7ef60754ce18ea64c92df2a57195800fe666af4c (patch)
tree7368d0689f6b064cf4ac6d68b5658692da810483 /lib/libc/yp
parentce5b804dd075dfa57105aaf12534b68a604f49c0 (diff)
downloadFreeBSD-src-7ef60754ce18ea64c92df2a57195800fe666af4c.zip
FreeBSD-src-7ef60754ce18ea64c92df2a57195800fe666af4c.tar.gz
Don't bother trying to flock() /var/run/ypbind.lock; this breaks when
/var/run resides on an NFS filesystem (flock() always returns 0 in this case, so we falsely assume that ypbind is dead and bail out). Settle instead for better failure checking when using clnttcp_create() and clnt_call() to interact with ypbind. We still try to flock() /var/yp/binding/$DOMAINNAME.2, but if this doesn't work, we drop into the code that retrieves the binding information from ypbind directly. If that also fails, then we're toast. On NFS filesystems, this means we'll be ignoring the binding file for no reason and always talking to ypbind even though we don't have to, but at least things will work. (I could just replace the flock(/var/run/ypbind.lock) check with an RPC call to ypbind's NULLPROC procedure, but if the flock() of the binding file doesn't pan out we're going to try to talk to ypbind later anyway. *sigh* Is NFS file locking ever going to work?)
Diffstat (limited to 'lib/libc/yp')
-rw-r--r--lib/libc/yp/yplib.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c
index 1043fe2..da50d51 100644
--- a/lib/libc/yp/yplib.c
+++ b/lib/libc/yp/yplib.c
@@ -28,7 +28,7 @@
*/
#ifndef LINT
-static char *rcsid = "$Id: yplib.c,v 1.15 1995/12/15 03:26:40 wpaul Exp $";
+static char *rcsid = "$Id: yplib.c,v 1.16 1996/03/19 19:27:03 wpaul Exp $";
#endif
#include <sys/param.h>
@@ -64,10 +64,6 @@ struct dom_binding {
#include <rpcsvc/ypclnt.h>
-#ifndef YPBINDLOCK
-#define YPBINDLOCK "/var/run/ypbind.lock"
-#endif
-
#ifndef BINDINGDIR
#define BINDINGDIR "/var/yp/binding"
#endif
@@ -257,20 +253,6 @@ struct dom_binding **ypdb;
new = 1;
}
- if ((lfd = open(YPBINDLOCK, O_RDONLY)) == -1)
- return(YPERR_YPBIND);
- errno = 0;
- switch (flock(lfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) {
- case 0:
- close(lfd);
- return (YPERR_YPBIND);
- break;
- case 1:
- default:
- close(lfd);
- break;
- }
-
again:
retries++;
if (retries > MAX_RETRIES) {
@@ -333,6 +315,15 @@ skipit:
client = clnttcp_create(&clnt_sin, YPBINDPROG, YPBINDVERS, &clnt_sock,
0, 0);
if(client==NULL) {
+ /*
+ * These conditions indicate ypbind just isn't
+ * alive -- we probably don't want to shoot our
+ * mouth off in this case and generate error
+ * messages only for really exotic problems.
+ */
+ if (rpc_createerr.cf_stat != RPC_PROGNOTREGISTERED &&
+ (rpc_createerr.cf_stat != RPC_SYSTEMERROR &&
+ rpc_createerr.cf_error.re_errno == ECONNREFUSED))
clnt_pcreateerror("clnttcp_create");
if(new)
free(ysd);
@@ -344,10 +335,12 @@ skipit:
r = clnt_call(client, YPBINDPROC_DOMAIN,
xdr_domainname, (char *)&dom, xdr_ypbind_resp, &ypbr, tv);
if(r != RPC_SUCCESS) {
- fprintf(stderr,
- "YP: server for domain %s not responding, retrying\n", dom);
clnt_destroy(client);
ysd->dom_vers = -1;
+ if (r == RPC_PROGUNAVAIL || r == RPC_PROCUNAVAIL)
+ return(YPERR_YPBIND);
+ fprintf(stderr,
+ "YP: server for domain %s not responding, retrying\n", dom);
goto again;
} else {
if (ypbr.ypbind_status != YPBIND_SUCC_VAL) {
OpenPOWER on IntegriCloud