From 0781a35d270ac129ac62679ca103056086ef4a7d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 26 Feb 1998 09:48:38 +0000 Subject: [PATCH] Give clnt handle after error checking free, change return codes to fix problems with rpc.nisd in YP mode on Ultra's. --- nis/ypclnt.c | 71 ++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/nis/ypclnt.c b/nis/ypclnt.c index 4f1fd9c1571..98f15062412 100644 --- a/nis/ypclnt.c +++ b/nis/ypclnt.c @@ -101,7 +101,7 @@ __yp_bind (const char *domain, dom_binding **ypdb) } #if USE_BINDINGDIR - if (ysd->dom_vers < 1) + if (ysd->dom_vers < 1 && try < 3) { char path[strlen (BINDINGDIR) + strlen (domain) + 10]; struct iovec vec[2]; @@ -248,10 +248,11 @@ do_ypcall (const char *domain, u_long prog, xdrproc_t xargs, { dom_binding *ydb = NULL; bool_t use_ypbindlist = FALSE; - int try, result; + int try, status; + enum clnt_stat result; try = 0; - result = YPERR_YPERR; + status = YPERR_YPERR; __libc_lock_lock (ypbindlist_lock); if (__ypbindlist != NULL) @@ -271,7 +272,7 @@ do_ypcall (const char *domain, u_long prog, xdrproc_t xargs, else __libc_lock_unlock (ypbindlist_lock); - while (try < MAXTRIES && result != RPC_SUCCESS) + while (try < MAXTRIES && status != YPERR_SUCCESS) { if (__yp_bind (domain, &ydb) != 0) { @@ -293,8 +294,11 @@ do_ypcall (const char *domain, u_long prog, xdrproc_t xargs, free (ydb); ydb = NULL; } - result = YPERR_RPC; + status = YPERR_RPC; } + else + status = YPERR_SUCCESS; + try++; } if (use_ypbindlist) @@ -310,7 +314,7 @@ do_ypcall (const char *domain, u_long prog, xdrproc_t xargs, ydb = NULL; } - return result; + return status; } int @@ -410,7 +414,7 @@ yp_match (const char *indomain, const char *inmap, const char *inkey, { ypreq_key req; ypresp_val resp; - int result; + enum clnt_stat result; if (indomain == NULL || indomain[0] == '\0' || inmap == NULL || inmap[0] == '\0' || @@ -431,7 +435,7 @@ yp_match (const char *indomain, const char *inmap, const char *inkey, (caddr_t) & resp); if (result != RPC_SUCCESS) - return result; + return YPERR_RPC; if (resp.stat != YP_TRUE) return ypprot_err (resp.stat); @@ -451,7 +455,7 @@ yp_first (const char *indomain, const char *inmap, char **outkey, { ypreq_nokey req; ypresp_key_val resp; - int result; + enum clnt_stat result; if (indomain == NULL || indomain[0] == '\0' || inmap == NULL || inmap[0] == '\0') @@ -469,7 +473,7 @@ yp_first (const char *indomain, const char *inmap, char **outkey, (caddr_t) & resp); if (result != RPC_SUCCESS) - return result; + return YPERR_RPC; if (resp.stat != YP_TRUE) return ypprot_err (resp.stat); @@ -494,7 +498,7 @@ yp_next (const char *indomain, const char *inmap, const char *inkey, { ypreq_key req; ypresp_key_val resp; - int result; + enum clnt_stat result; if (indomain == NULL || indomain[0] == '\0' || inmap == NULL || inmap[0] == '\0' || @@ -515,7 +519,7 @@ yp_next (const char *indomain, const char *inmap, const char *inkey, (caddr_t) & resp); if (result != RPC_SUCCESS) - return result; + return YPERR_RPC; if (resp.stat != YP_TRUE) return ypprot_err (resp.stat); @@ -538,7 +542,7 @@ yp_master (const char *indomain, const char *inmap, char **outname) { ypreq_nokey req; ypresp_master resp; - int result; + enum clnt_stat result; if (indomain == NULL || indomain[0] == '\0' || inmap == NULL || inmap[0] == '\0') @@ -553,7 +557,7 @@ yp_master (const char *indomain, const char *inmap, char **outname) (caddr_t) & req, (xdrproc_t) xdr_ypresp_master, (caddr_t) & resp); if (result != RPC_SUCCESS) - return result; + return YPERR_RPC; if (resp.stat != YP_TRUE) return ypprot_err (resp.stat); @@ -568,7 +572,7 @@ yp_order (const char *indomain, const char *inmap, unsigned int *outorder) { struct ypreq_nokey req; struct ypresp_order resp; - int result; + enum clnt_stat result; if (indomain == NULL || indomain[0] == '\0' || inmap == NULL || inmap == '\0') @@ -583,7 +587,7 @@ yp_order (const char *indomain, const char *inmap, unsigned int *outorder) (caddr_t) & req, (xdrproc_t) xdr_ypresp_order, (caddr_t) & resp); if (result != RPC_SUCCESS) - return result; + return YPERR_RPC; if (resp.stat != YP_TRUE) return ypprot_err (resp.stat); @@ -609,13 +613,13 @@ __xdr_ypresp_all (XDR * xdrs, u_long * objp) { xdr_free ((xdrproc_t) xdr_ypresp_all, (char *) &resp); *objp = YP_YPERR; - return (FALSE); + return FALSE; } if (resp.more == 0) { xdr_free ((xdrproc_t) xdr_ypresp_all, (char *) &resp); *objp = YP_NOMORE; - return (FALSE); + return TRUE; } switch (resp.ypresp_all_u.val.stat) @@ -657,7 +661,8 @@ yp_all (const char *indomain, const char *inmap, { struct ypreq_nokey req; dom_binding *ydb = NULL; - int try, result; + int try, res; + enum clnt_stat result; struct sockaddr_in clnt_sin; CLIENT *clnt; unsigned long status; @@ -668,9 +673,9 @@ yp_all (const char *indomain, const char *inmap, return YPERR_BADARGS; try = 0; - result = YPERR_YPERR; + res = YPERR_YPERR; - while (try < MAXTRIES && result != RPC_SUCCESS) + while (try < MAXTRIES && res != YPERR_SUCCESS) { if (__yp_bind (indomain, &ydb) != 0) { @@ -683,10 +688,7 @@ yp_all (const char *indomain, const char *inmap, clnt_sin.sin_port = 0; clnt = clnttcp_create (&clnt_sin, YPPROG, YPVERS, &clnt_sock, 0, 0); if (clnt == NULL) - { - puts (_("yp_all: clnttcp_create failed")); - return YPERR_PMAP; - } + return YPERR_PMAP; req.domain = (char *) indomain; req.map = (char *) inmap; @@ -697,31 +699,30 @@ yp_all (const char *indomain, const char *inmap, (caddr_t) &req, (xdrproc_t) __xdr_ypresp_all, (caddr_t) &status, RPCTIMEOUT); - clnt_destroy (clnt); - close (clnt_sock); if (result != RPC_SUCCESS) { - clnt_perror (ydb->dom_client, "yp_all: clnt_call"); - __yp_unbind (ydb); - free (ydb); - result = YPERR_RPC; + clnt_perror (clnt, "yp_all: clnt_call"); + res = YPERR_RPC; } else - result = YPERR_SUCCESS; + res = YPERR_SUCCESS; + + clnt_destroy (clnt); + close (clnt_sock); if (status != YP_NOMORE) return ypprot_err (status); try++; } - return result; + return res; } int yp_maplist (const char *indomain, struct ypmaplist **outmaplist) { struct ypresp_maplist resp; - int result; + enum clnt_stat result; if (indomain == NULL || indomain[0] == '\0') return YPERR_BADARGS; @@ -732,7 +733,7 @@ yp_maplist (const char *indomain, struct ypmaplist **outmaplist) (caddr_t) & indomain, (xdrproc_t) xdr_ypresp_maplist, (caddr_t) & resp); if (result != RPC_SUCCESS) - return result; + return YPERR_RPC; if (resp.stat != YP_TRUE) return ypprot_err (resp.stat); -- 2.47.2