From b4a233e9572f06ec4a130362a5e4f8cf43918782 Mon Sep 17 00:00:00 2001 From: Steve Dickson Date: Thu, 28 Jul 2022 13:18:01 -0400 Subject: [PATCH] Updated to the latest upstream RC release: libtirpc-1-3-3-rc4 Signed-off-by: Steve Dickson --- libtirpc-1.1.5-rc3.patch | 417 ----------- libtirpc-1.2.6-rc2.patch | 71 -- libtirpc-1.3.2-rc2.patch | 96 --- libtirpc-1.3.3-rc1.patch | 523 -------------- libtirpc-1.3.3-rc4.patch | 1448 ++++++++++++++++++++++++++++++++++++++ libtirpc.spec | 7 +- 6 files changed, 1453 insertions(+), 1109 deletions(-) delete mode 100644 libtirpc-1.1.5-rc3.patch delete mode 100644 libtirpc-1.2.6-rc2.patch delete mode 100644 libtirpc-1.3.2-rc2.patch delete mode 100644 libtirpc-1.3.3-rc1.patch create mode 100644 libtirpc-1.3.3-rc4.patch diff --git a/libtirpc-1.1.5-rc3.patch b/libtirpc-1.1.5-rc3.patch deleted file mode 100644 index 3478ad8..0000000 --- a/libtirpc-1.1.5-rc3.patch +++ /dev/null @@ -1,417 +0,0 @@ -diff --git a/man/rpc_secure.3t b/man/rpc_secure.3t -index 4a1ad93..404df0b 100644 ---- a/man/rpc_secure.3t -+++ b/man/rpc_secure.3t -@@ -19,7 +19,7 @@ - .Ft AUTH * - .Fo authdes_pk_create - .Fa "char *name" --.FA "netobj *publickey" -+.Fa "netobj *publickey" - .Fa "unsigned window" - .Fa "struct sockaddr *addr" - .Fa "des_block *ckey" -diff --git a/src/Makefile.am b/src/Makefile.am -index 932414d..b40a6b4 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -38,7 +38,7 @@ endif - if GSS - libtirpc_la_SOURCES += auth_gss.c authgss_prot.c svc_auth_gss.c \ - rpc_gss_utils.c -- libtirpc_la_LDFLAGS += $(GSSAPI_LIBS) -+ libtirpc_la_LIBADD = $(GSSAPI_LIBS) - libtirpc_la_CFLAGS = -DHAVE_RPCSEC_GSS $(GSSAPI_CFLAGS) - endif - -diff --git a/src/auth_des.c b/src/auth_des.c -index af2f61f..c9af2e9 100644 ---- a/src/auth_des.c -+++ b/src/auth_des.c -@@ -396,7 +396,7 @@ authdes_validate(AUTH *auth, struct opaque_auth *rverf) - /* - * validate - */ -- if (bcmp((char *)&ad->ad_timestamp, (char *)&verf.adv_timestamp, -+ if (memcmp((char *)&ad->ad_timestamp, (char *)&verf.adv_timestamp, - sizeof(struct timeval)) != 0) { - LIBTIRPC_DEBUG(1, ("authdes_validate: verifier mismatch")); - return (FALSE); -diff --git a/src/auth_gss.c b/src/auth_gss.c -index 5959893..7d08262 100644 ---- a/src/auth_gss.c -+++ b/src/auth_gss.c -@@ -207,6 +207,7 @@ authgss_create(CLIENT *clnt, gss_name_t name, struct rpc_gss_sec *sec) - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = ENOMEM; - free(auth); -+ free(gd); - return (NULL); - } - } -@@ -592,7 +593,7 @@ _rpc_gss_refresh(AUTH *auth, rpc_gss_options_ret_t *options_ret) - if (rpc_gss_oid_to_mech(actual_mech_type, &mechanism)) { - strncpy(options_ret->actual_mechanism, - mechanism, -- sizeof(options_ret->actual_mechanism)); -+ (sizeof(options_ret->actual_mechanism)-1)); - } - - gd->established = TRUE; -diff --git a/src/auth_time.c b/src/auth_time.c -index 69400bc..936dd76 100644 ---- a/src/auth_time.c -+++ b/src/auth_time.c -@@ -104,7 +104,7 @@ static int uaddr_to_sockaddr(uaddr, sin) - p_bytes[1] = (unsigned char)a[5] & 0x000000FF; - - sin->sin_family = AF_INET; /* always */ -- bcopy((char *)&p_bytes, (char *)&sin->sin_port, 2); -+ memcpy((char *)&sin->sin_port, (char *)&p_bytes, 2); - - return (0); - } -diff --git a/src/clnt_bcast.c b/src/clnt_bcast.c -index 98cf061..2ad6c89 100644 ---- a/src/clnt_bcast.c -+++ b/src/clnt_bcast.c -@@ -330,6 +330,7 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, - if (nettype == NULL) - nettype = "datagram_n"; - if ((handle = __rpc_setconf(nettype)) == NULL) { -+ AUTH_DESTROY(sys_auth); - return (RPC_UNKNOWNPROTO); - } - while ((nconf = __rpc_getconf(handle)) != NULL) { -diff --git a/src/crypt_client.c b/src/crypt_client.c -index f393926..cd6f7de 100644 ---- a/src/crypt_client.c -+++ b/src/crypt_client.c -@@ -75,8 +75,8 @@ _des_crypt_call(buf, len, dparms) - des_crypt_1_arg.desbuf.desbuf_val = buf; - des_crypt_1_arg.des_dir = dparms->des_dir; - des_crypt_1_arg.des_mode = dparms->des_mode; -- bcopy(dparms->des_ivec, des_crypt_1_arg.des_ivec, 8); -- bcopy(dparms->des_key, des_crypt_1_arg.des_key, 8); -+ memcpy(des_crypt_1_arg.des_ivec, dparms->des_ivec, 8); -+ memcpy(des_crypt_1_arg.des_key, dparms->des_key, 8); - - result_1 = des_crypt_1(&des_crypt_1_arg, clnt); - if (result_1 == (desresp *) NULL) { -@@ -88,8 +88,8 @@ _des_crypt_call(buf, len, dparms) - - if (result_1->stat == DESERR_NONE || - result_1->stat == DESERR_NOHWDEVICE) { -- bcopy(result_1->desbuf.desbuf_val, buf, len); -- bcopy(result_1->des_ivec, dparms->des_ivec, 8); -+ memcpy(buf, result_1->desbuf.desbuf_val, len); -+ memcpy(dparms->des_ivec, result_1->des_ivec, 8); - } - - clnt_freeres(clnt, (xdrproc_t)xdr_desresp, result_1); -diff --git a/src/getnetconfig.c b/src/getnetconfig.c -index 92e7c43..cfd33c2 100644 ---- a/src/getnetconfig.c -+++ b/src/getnetconfig.c -@@ -681,6 +681,7 @@ struct netconfig *ncp; - { - struct netconfig *p; - char *tmp; -+ char *t; - u_int i; - - if ((tmp=malloc(MAXNETCONFIGLINE)) == NULL) -@@ -700,20 +701,21 @@ struct netconfig *ncp; - */ - *p = *ncp; - p->nc_netid = (char *)strcpy(tmp,ncp->nc_netid); -- tmp = strchr(tmp, 0) + 1; -- p->nc_protofmly = (char *)strcpy(tmp,ncp->nc_protofmly); -- tmp = strchr(tmp, 0) + 1; -- p->nc_proto = (char *)strcpy(tmp,ncp->nc_proto); -- tmp = strchr(tmp, 0) + 1; -- p->nc_device = (char *)strcpy(tmp,ncp->nc_device); -+ t = strchr(tmp, 0) + 1; -+ p->nc_protofmly = (char *)strcpy(t,ncp->nc_protofmly); -+ t = strchr(t, 0) + 1; -+ p->nc_proto = (char *)strcpy(t,ncp->nc_proto); -+ t = strchr(t, 0) + 1; -+ p->nc_device = (char *)strcpy(t,ncp->nc_device); - p->nc_lookups = (char **)malloc((size_t)(p->nc_nlookups+1) * sizeof(char *)); - if (p->nc_lookups == NULL) { -- free(p->nc_netid); -+ free(p); -+ free(tmp); - return(NULL); - } - for (i=0; i < p->nc_nlookups; i++) { -- tmp = strchr(tmp, 0) + 1; -- p->nc_lookups[i] = (char *)strcpy(tmp,ncp->nc_lookups[i]); -+ t = strchr(t, 0) + 1; -+ p->nc_lookups[i] = (char *)strcpy(t,ncp->nc_lookups[i]); - } - return(p); - } -diff --git a/src/getnetpath.c b/src/getnetpath.c -index 7c19932..ea1a18c 100644 ---- a/src/getnetpath.c -+++ b/src/getnetpath.c -@@ -88,6 +88,7 @@ setnetpath() - } - if ((np_sessionp->nc_handlep = setnetconfig()) == NULL) { - syslog (LOG_ERR, "rpc: failed to open " NETCONFIG); -+ free(np_sessionp); - return (NULL); - } - np_sessionp->valid = NP_VALID; -diff --git a/src/getpublickey.c b/src/getpublickey.c -index 8cf4dc2..be37a24 100644 ---- a/src/getpublickey.c -+++ b/src/getpublickey.c -@@ -74,7 +74,7 @@ __getpublickey_real(netname, publickey) - return (0); - } - *p = '\0'; -- (void) strncpy(publickey, lookup, HEXKEYBYTES); -+ memcpy(publickey, lookup, HEXKEYBYTES); - publickey[HEXKEYBYTES] = '\0'; - return (1); - } -diff --git a/src/getrpcent.c b/src/getrpcent.c -index cba4cd8..e49dc05 100644 ---- a/src/getrpcent.c -+++ b/src/getrpcent.c -@@ -100,7 +100,7 @@ _rpcdata() - return (d); - } - --#if !HAVE_GETRPCBYNYMBER -+#if !HAVE_GETRPCBYNUMBER - struct rpcent * - getrpcbynumber(number) - int number; -diff --git a/src/rpc_generic.c b/src/rpc_generic.c -index 589cbd5..51f36ac 100644 ---- a/src/rpc_generic.c -+++ b/src/rpc_generic.c -@@ -319,6 +319,7 @@ __rpc_setconf(nettype) - handle->nflag = FALSE; - break; - default: -+ free(handle); - return (NULL); - } - -diff --git a/src/rpc_soc.c b/src/rpc_soc.c -index 5a6eeb7..a85cb17 100644 ---- a/src/rpc_soc.c -+++ b/src/rpc_soc.c -@@ -663,15 +663,17 @@ svcunix_create(sock, sendsize, recvsize, path) - strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) - break; - } -- if (nconf == NULL) -+ if (nconf == NULL) { -+ endnetconfig(localhandle); - return(xprt); -+ } - - if ((sock = __rpc_nconf2fd(nconf)) < 0) - goto done; - - memset(&sun, 0, sizeof sun); - sun.sun_family = AF_LOCAL; -- strncpy(sun.sun_path, path, sizeof(sun.sun_path)); -+ strncpy(sun.sun_path, path, (sizeof(sun.sun_path)-1)); - addrlen = sizeof(struct sockaddr_un); - sa = (struct sockaddr *)&sun; - -@@ -692,6 +694,8 @@ svcunix_create(sock, sendsize, recvsize, path) - } - - xprt = (SVCXPRT *)svc_tli_create(sock, nconf, &taddr, sendsize, recvsize); -+ if (xprt == NULL) -+ close(sock); - - done: - endnetconfig(localhandle); -diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c -index e45736a..0c34cb7 100644 ---- a/src/rpcb_clnt.c -+++ b/src/rpcb_clnt.c -@@ -547,6 +547,7 @@ try_nconf: - if (tmpnconf == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - mutex_unlock(&loopnconf_lock); -+ endnetconfig(nc_handle); - return (NULL); - } - loopnconf = getnetconfigent(tmpnconf->nc_netid); -diff --git a/src/rtime.c b/src/rtime.c -index b642840..29fbf0a 100644 ---- a/src/rtime.c -+++ b/src/rtime.c -@@ -90,6 +90,7 @@ rtime(addrp, timep, timeout) - - /* TCP and UDP port are the same in this case */ - if ((serv = getservbyname("time", "tcp")) == NULL) { -+ do_close(s); - return(-1); - } - -diff --git a/src/svc_auth_des.c b/src/svc_auth_des.c -index 19a7c60..b096e08 100644 ---- a/src/svc_auth_des.c -+++ b/src/svc_auth_des.c -@@ -145,7 +145,7 @@ _svcauth_des(rqst, msg) - return (AUTH_BADCRED); - } - cred->adc_fullname.name = area->area_netname; -- bcopy((char *)ixdr, cred->adc_fullname.name, -+ memcpy(cred->adc_fullname.name, (char *)ixdr, - (u_int)namelen); - cred->adc_fullname.name[namelen] = 0; - ixdr += (RNDUP(namelen) / BYTES_PER_XDR_UNIT); -@@ -419,7 +419,7 @@ cache_spot(key, name, timestamp) - if (cp->key.key.high == hi && - cp->key.key.low == key->key.low && - cp->rname != NULL && -- bcmp(cp->rname, name, strlen(name) + 1) == 0) { -+ memcmp(cp->rname, name, strlen(name) + 1) == 0) { - if (BEFORE(timestamp, &cp->laststamp)) { - svcauthdes_stats.ncachereplays++; - return (-1); /* replay */ -diff --git a/src/svc_generic.c b/src/svc_generic.c -index 52a56c2..20abaa2 100644 ---- a/src/svc_generic.c -+++ b/src/svc_generic.c -@@ -113,6 +113,7 @@ svc_create(dispatch, prognum, versnum, nettype) - if (l == NULL) { - warnx("svc_create: no memory"); - mutex_unlock(&xprtlist_lock); -+ __rpc_endconf(handle); - return (0); - } - l->xprt = xprt; -diff --git a/src/svc_simple.c b/src/svc_simple.c -index cb58002..c32fe0a 100644 ---- a/src/svc_simple.c -+++ b/src/svc_simple.c -@@ -157,6 +157,7 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype) - ((netid = strdup(nconf->nc_netid)) == NULL)) { - warnx(rpc_reg_err, rpc_reg_msg, __no_mem_str); - SVC_DESTROY(svcxprt); -+ free(xdrbuf); - break; - } - madenow = TRUE; -diff --git a/src/svc_vc.c b/src/svc_vc.c -index 97a76a3..c23cd36 100644 ---- a/src/svc_vc.c -+++ b/src/svc_vc.c -@@ -502,9 +502,14 @@ read_vc(xprtp, buf, len) - cfp = (struct cf_conn *)xprt->xp_p1; - - if (cfp->nonblock) { -+ /* Since len == 0 is returned on zero length -+ * read or EOF errno needs to be reset before -+ * the read -+ */ -+ errno = 0; - len = read(sock, buf, (size_t)len); - if (len < 0) { -- if (errno == EAGAIN) -+ if (errno == EAGAIN || errno == EWOULDBLOCK) - len = 0; - else - goto fatal_err; -diff --git a/src/xdr.c b/src/xdr.c -index b9a1558..28d1382 100644 ---- a/src/xdr.c -+++ b/src/xdr.c -@@ -877,7 +877,8 @@ xdr_int64_t(xdrs, llp) - if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE) - return (FALSE); - *llp = (int64_t) -- (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1])); -+ (((u_int64_t)ul[0] << 32) | -+ ((u_int64_t)(ul[1]) & 0xffffffff)); - return (TRUE); - case XDR_FREE: - return (TRUE); -@@ -910,7 +911,8 @@ xdr_u_int64_t(xdrs, ullp) - if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE) - return (FALSE); - *ullp = (u_int64_t) -- (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1])); -+ (((u_int64_t)ul[0] << 32) | -+ ((u_int64_t)(ul[1]) & 0xffffffff)); - return (TRUE); - case XDR_FREE: - return (TRUE); -diff --git a/src/xdr_rec.c b/src/xdr_rec.c -index 7d535cf..676cc82 100644 ---- a/src/xdr_rec.c -+++ b/src/xdr_rec.c -@@ -61,6 +61,7 @@ - #include - #include - #include -+#include - #include "rpc_com.h" - static bool_t xdrrec_getlong(XDR *, long *); - static bool_t xdrrec_putlong(XDR *, const long *); -@@ -537,7 +538,13 @@ __xdrrec_getrec(xdrs, statp, expectdata) - n = rstrm->readit(rstrm->tcp_handle, rstrm->in_hdrp, - (int)sizeof (rstrm->in_header) - rstrm->in_hdrlen); - if (n == 0) { -- *statp = expectdata ? XPRT_DIED : XPRT_IDLE; -+ /* EAGAIN or EWOULDBLOCK means a zero length -+ * read not an EOF. -+ */ -+ if (errno == EAGAIN || errno == EWOULDBLOCK) -+ *statp = XPRT_IDLE; -+ else -+ *statp = expectdata ? XPRT_DIED : XPRT_IDLE; - return FALSE; - } - if (n < 0) { -@@ -564,6 +571,7 @@ __xdrrec_getrec(xdrs, statp, expectdata) - rstrm->in_header &= ~LAST_FRAG; - rstrm->last_frag = TRUE; - } -+ rstrm->in_haveheader = 1; - } - - n = rstrm->readit(rstrm->tcp_handle, -@@ -576,7 +584,13 @@ __xdrrec_getrec(xdrs, statp, expectdata) - } - - if (n == 0) { -- *statp = expectdata ? XPRT_DIED : XPRT_IDLE; -+ /* EAGAIN or EWOULDBLOCK means a zero length -+ * read not an EOF. -+ */ -+ if (errno == EAGAIN || errno == EWOULDBLOCK) -+ *statp = XPRT_IDLE; -+ else -+ *statp = expectdata ? XPRT_DIED : XPRT_IDLE; - return FALSE; - } - -diff --git a/tirpc/rpc/rpcent.h b/tirpc/rpc/rpcent.h -index 9d3ef9c..5bff876 100644 ---- a/tirpc/rpc/rpcent.h -+++ b/tirpc/rpc/rpcent.h -@@ -48,8 +48,9 @@ - extern "C" { - #endif - --/* These are defined in /usr/include/rpc/netdb.h */ --#if !defined(__GLIBC__) || defined(__UCLIBC__) -+/* These are defined in /usr/include/rpc/netdb.h, unless we are using -+ the C library without RPC support. */ -+#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_RPC__) || !defined(__GLIBC__) - struct rpcent { - char *r_name; /* name of server for this rpc program */ - char **r_aliases; /* alias list */ diff --git a/libtirpc-1.2.6-rc2.patch b/libtirpc-1.2.6-rc2.patch deleted file mode 100644 index f80d40f..0000000 --- a/libtirpc-1.2.6-rc2.patch +++ /dev/null @@ -1,71 +0,0 @@ -diff --git a/doc/bindresvport.blacklist b/doc/bindresvport.blacklist -index 8904277..a7ed193 100644 ---- a/doc/bindresvport.blacklist -+++ b/doc/bindresvport.blacklist -@@ -8,6 +8,7 @@ - 631 # cups - 636 # ldaps - 664 # Secure ASF, used by IPMI on some cards -+774 # rpasswd - 921 # lwresd - 993 # imaps - 995 # pops -diff --git a/src/rpc_com.h b/src/rpc_com.h -index 10bec79..76badef 100644 ---- a/src/rpc_com.h -+++ b/src/rpc_com.h -@@ -61,8 +61,7 @@ void __xprt_unregister_unlocked(SVCXPRT *); - void __xprt_set_raddr(SVCXPRT *, const struct sockaddr_storage *); - - --SVCXPRT **__svc_xports; --int __svc_maxrec; -+extern int __svc_maxrec; - - #ifdef __cplusplus - } -diff --git a/src/rpc_soc.c b/src/rpc_soc.c -index ac7d312..fde121d 100644 ---- a/src/rpc_soc.c -+++ b/src/rpc_soc.c -@@ -613,6 +613,13 @@ authdes_pk_create(servername, pkey, window, syncaddr, ckey) - des_block *ckey; /* optional conversation key to use */ - { return (NULL); } - -+AUTH * -+authdes_seccreate(const char *servername, const u_int win, -+ const char *timehost, const des_block *ckey) -+{ -+ return (NULL); -+} -+ - #endif - - -diff --git a/src/svc.c b/src/svc.c -index b59467b..6db164b 100644 ---- a/src/svc.c -+++ b/src/svc.c -@@ -57,6 +57,9 @@ - - #define max(a, b) (a > b ? a : b) - -+static SVCXPRT **__svc_xports; -+int __svc_maxrec; -+ - /* - * The services list - * Each entry represents a set of procedures (an rpc program). -diff --git a/src/xdr_float.c b/src/xdr_float.c -index 26bc865..349d48f 100644 ---- a/src/xdr_float.c -+++ b/src/xdr_float.c -@@ -83,7 +83,7 @@ static struct sgl_limits { - }; - #else - --#include -+#include - #define IEEEFP - - #endif /* vax */ diff --git a/libtirpc-1.3.2-rc2.patch b/libtirpc-1.3.2-rc2.patch deleted file mode 100644 index f47bc59..0000000 --- a/libtirpc-1.3.2-rc2.patch +++ /dev/null @@ -1,96 +0,0 @@ -diff --git a/doc/bindresvport.blacklist b/doc/bindresvport.blacklist -index a7ed193..67ff771 100644 ---- a/doc/bindresvport.blacklist -+++ b/doc/bindresvport.blacklist -@@ -8,7 +8,11 @@ - 631 # cups - 636 # ldaps - 664 # Secure ASF, used by IPMI on some cards -+749 # Kerberos V kadmin - 774 # rpasswd -+873 # rsyncd - 921 # lwresd -+992 # SSL-enabled telnet - 993 # imaps -+994 # irc - 995 # pops -diff --git a/src/auth_gss.c b/src/auth_gss.c -index d871672..e317664 100644 ---- a/src/auth_gss.c -+++ b/src/auth_gss.c -@@ -982,3 +982,9 @@ rpc_gss_max_data_length(AUTH *auth, int maxlen) - rpc_gss_clear_error(); - return result; - } -+ -+bool_t -+is_authgss_client(CLIENT *clnt) -+{ -+ return (clnt->cl_auth->ah_ops == &authgss_ops); -+} -diff --git a/src/clnt_dg.c b/src/clnt_dg.c -index abc09f1..e1255de 100644 ---- a/src/clnt_dg.c -+++ b/src/clnt_dg.c -@@ -61,6 +61,9 @@ - #include - #endif - -+#ifdef HAVE_RPCSEC_GSS -+#include -+#endif - - #define MAX_DEFAULT_FDS 20000 - -@@ -334,6 +337,11 @@ clnt_dg_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) - salen = cu->cu_rlen; - } - -+#ifdef HAVE_RPCSEC_GSS -+ if (is_authgss_client(cl)) -+ nrefreshes = 0; -+#endif -+ - /* Clean up in case the last call ended in a longjmp(3) call. */ - call_again: - xdrs = &(cu->cu_outxdrs); -diff --git a/src/clnt_vc.c b/src/clnt_vc.c -index 6f7f7da..a07e297 100644 ---- a/src/clnt_vc.c -+++ b/src/clnt_vc.c -@@ -69,6 +69,10 @@ - #include "rpc_com.h" - #include "clnt_fd_locks.h" - -+#ifdef HAVE_RPCSEC_GSS -+#include -+#endif -+ - #define MCALL_MSG_SIZE 24 - - #define CMGROUP_MAX 16 -@@ -363,6 +367,11 @@ clnt_vc_call(cl, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) - (xdr_results == NULL && timeout.tv_sec == 0 - && timeout.tv_usec == 0) ? FALSE : TRUE; - -+#ifdef HAVE_RPCSEC_GSS -+ if (is_authgss_client(cl)) -+ refreshes = 0; -+#endif -+ - call_again: - xdrs->x_op = XDR_ENCODE; - ct->ct_error.re_status = RPC_SUCCESS; -diff --git a/tirpc/rpc/auth_gss.h b/tirpc/rpc/auth_gss.h -index 5316ed6..f2af6e9 100644 ---- a/tirpc/rpc/auth_gss.h -+++ b/tirpc/rpc/auth_gss.h -@@ -120,6 +120,8 @@ void gss_log_debug (const char *fmt, ...); - void gss_log_status (char *m, OM_uint32 major, OM_uint32 minor); - void gss_log_hexdump (const u_char *buf, int len, int offset); - -+bool_t is_authgss_client (CLIENT *); -+ - #ifdef __cplusplus - } - #endif diff --git a/libtirpc-1.3.3-rc1.patch b/libtirpc-1.3.3-rc1.patch deleted file mode 100644 index 7aa5678..0000000 --- a/libtirpc-1.3.3-rc1.patch +++ /dev/null @@ -1,523 +0,0 @@ -diff --git a/INSTALL b/INSTALL -deleted file mode 100644 -index 2099840..0000000 ---- a/INSTALL -+++ /dev/null -@@ -1,370 +0,0 @@ --Installation Instructions --************************* -- --Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, --Inc. -- -- Copying and distribution of this file, with or without modification, --are permitted in any medium without royalty provided the copyright --notice and this notice are preserved. This file is offered as-is, --without warranty of any kind. -- --Basic Installation --================== -- -- Briefly, the shell command `./configure && make && make install' --should configure, build, and install this package. The following --more-detailed instructions are generic; see the `README' file for --instructions specific to this package. Some packages provide this --`INSTALL' file but do not implement all of the features documented --below. The lack of an optional feature in a given package is not --necessarily a bug. More recommendations for GNU packages can be found --in *note Makefile Conventions: (standards)Makefile Conventions. -- -- The `configure' shell script attempts to guess correct values for --various system-dependent variables used during compilation. It uses --those values to create a `Makefile' in each directory of the package. --It may also create one or more `.h' files containing system-dependent --definitions. Finally, it creates a shell script `config.status' that --you can run in the future to recreate the current configuration, and a --file `config.log' containing compiler output (useful mainly for --debugging `configure'). -- -- It can also use an optional file (typically called `config.cache' --and enabled with `--cache-file=config.cache' or simply `-C') that saves --the results of its tests to speed up reconfiguring. Caching is --disabled by default to prevent problems with accidental use of stale --cache files. -- -- If you need to do unusual things to compile the package, please try --to figure out how `configure' could check whether to do them, and mail --diffs or instructions to the address given in the `README' so they can --be considered for the next release. If you are using the cache, and at --some point `config.cache' contains results you don't want to keep, you --may remove or edit it. -- -- The file `configure.ac' (or `configure.in') is used to create --`configure' by a program called `autoconf'. You need `configure.ac' if --you want to change it or regenerate `configure' using a newer version --of `autoconf'. -- -- The simplest way to compile this package is: -- -- 1. `cd' to the directory containing the package's source code and type -- `./configure' to configure the package for your system. -- -- Running `configure' might take a while. While running, it prints -- some messages telling which features it is checking for. -- -- 2. Type `make' to compile the package. -- -- 3. Optionally, type `make check' to run any self-tests that come with -- the package, generally using the just-built uninstalled binaries. -- -- 4. Type `make install' to install the programs and any data files and -- documentation. When installing into a prefix owned by root, it is -- recommended that the package be configured and built as a regular -- user, and only the `make install' phase executed with root -- privileges. -- -- 5. Optionally, type `make installcheck' to repeat any self-tests, but -- this time using the binaries in their final installed location. -- This target does not install anything. Running this target as a -- regular user, particularly if the prior `make install' required -- root privileges, verifies that the installation completed -- correctly. -- -- 6. You can remove the program binaries and object files from the -- source code directory by typing `make clean'. To also remove the -- files that `configure' created (so you can compile the package for -- a different kind of computer), type `make distclean'. There is -- also a `make maintainer-clean' target, but that is intended mainly -- for the package's developers. If you use it, you may have to get -- all sorts of other programs in order to regenerate files that came -- with the distribution. -- -- 7. Often, you can also type `make uninstall' to remove the installed -- files again. In practice, not all packages have tested that -- uninstallation works correctly, even though it is required by the -- GNU Coding Standards. -- -- 8. Some packages, particularly those that use Automake, provide `make -- distcheck', which can by used by developers to test that all other -- targets like `make install' and `make uninstall' work correctly. -- This target is generally not run by end users. -- --Compilers and Options --===================== -- -- Some systems require unusual options for compilation or linking that --the `configure' script does not know about. Run `./configure --help' --for details on some of the pertinent environment variables. -- -- You can give `configure' initial values for configuration parameters --by setting variables in the command line or in the environment. Here --is an example: -- -- ./configure CC=c99 CFLAGS=-g LIBS=-lposix -- -- *Note Defining Variables::, for more details. -- --Compiling For Multiple Architectures --==================================== -- -- You can compile the package for more than one kind of computer at the --same time, by placing the object files for each architecture in their --own directory. To do this, you can use GNU `make'. `cd' to the --directory where you want the object files and executables to go and run --the `configure' script. `configure' automatically checks for the --source code in the directory that `configure' is in and in `..'. This --is known as a "VPATH" build. -- -- With a non-GNU `make', it is safer to compile the package for one --architecture at a time in the source code directory. After you have --installed the package for one architecture, use `make distclean' before --reconfiguring for another architecture. -- -- On MacOS X 10.5 and later systems, you can create libraries and --executables that work on multiple system types--known as "fat" or --"universal" binaries--by specifying multiple `-arch' options to the --compiler but only a single `-arch' option to the preprocessor. Like --this: -- -- ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ -- CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ -- CPP="gcc -E" CXXCPP="g++ -E" -- -- This is not guaranteed to produce working output in all cases, you --may have to build one architecture at a time and combine the results --using the `lipo' tool if you have problems. -- --Installation Names --================== -- -- By default, `make install' installs the package's commands under --`/usr/local/bin', include files under `/usr/local/include', etc. You --can specify an installation prefix other than `/usr/local' by giving --`configure' the option `--prefix=PREFIX', where PREFIX must be an --absolute file name. -- -- You can specify separate installation prefixes for --architecture-specific files and architecture-independent files. If you --pass the option `--exec-prefix=PREFIX' to `configure', the package uses --PREFIX as the prefix for installing programs and libraries. --Documentation and other data files still use the regular prefix. -- -- In addition, if you use an unusual directory layout you can give --options like `--bindir=DIR' to specify different values for particular --kinds of files. Run `configure --help' for a list of the directories --you can set and what kinds of files go in them. In general, the --default for these options is expressed in terms of `${prefix}', so that --specifying just `--prefix' will affect all of the other directory --specifications that were not explicitly provided. -- -- The most portable way to affect installation locations is to pass the --correct locations to `configure'; however, many packages provide one or --both of the following shortcuts of passing variable assignments to the --`make install' command line to change installation locations without --having to reconfigure or recompile. -- -- The first method involves providing an override variable for each --affected directory. For example, `make install --prefix=/alternate/directory' will choose an alternate location for all --directory configuration variables that were expressed in terms of --`${prefix}'. Any directories that were specified during `configure', --but not in terms of `${prefix}', must each be overridden at install --time for the entire installation to be relocated. The approach of --makefile variable overrides for each directory variable is required by --the GNU Coding Standards, and ideally causes no recompilation. --However, some platforms have known limitations with the semantics of --shared libraries that end up requiring recompilation when using this --method, particularly noticeable in packages that use GNU Libtool. -- -- The second method involves providing the `DESTDIR' variable. For --example, `make install DESTDIR=/alternate/directory' will prepend --`/alternate/directory' before all installation names. The approach of --`DESTDIR' overrides is not required by the GNU Coding Standards, and --does not work on platforms that have drive letters. On the other hand, --it does better at avoiding recompilation issues, and works well even --when some directory options were not specified in terms of `${prefix}' --at `configure' time. -- --Optional Features --================= -- -- If the package supports it, you can cause programs to be installed --with an extra prefix or suffix on their names by giving `configure' the --option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. -- -- Some packages pay attention to `--enable-FEATURE' options to --`configure', where FEATURE indicates an optional part of the package. --They may also pay attention to `--with-PACKAGE' options, where PACKAGE --is something like `gnu-as' or `x' (for the X Window System). The --`README' should mention any `--enable-' and `--with-' options that the --package recognizes. -- -- For packages that use the X Window System, `configure' can usually --find the X include and library files automatically, but if it doesn't, --you can use the `configure' options `--x-includes=DIR' and --`--x-libraries=DIR' to specify their locations. -- -- Some packages offer the ability to configure how verbose the --execution of `make' will be. For these packages, running `./configure ----enable-silent-rules' sets the default to minimal output, which can be --overridden with `make V=1'; while running `./configure ----disable-silent-rules' sets the default to verbose, which can be --overridden with `make V=0'. -- --Particular systems --================== -- -- On HP-UX, the default C compiler is not ANSI C compatible. If GNU --CC is not installed, it is recommended to use the following options in --order to use an ANSI C compiler: -- -- ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" -- --and if that doesn't work, install pre-built binaries of GCC for HP-UX. -- -- HP-UX `make' updates targets which have the same time stamps as --their prerequisites, which makes it generally unusable when shipped --generated files such as `configure' are involved. Use GNU `make' --instead. -- -- On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot --parse its `' header file. The option `-nodtk' can be used as --a workaround. If GNU CC is not installed, it is therefore recommended --to try -- -- ./configure CC="cc" -- --and if that doesn't work, try -- -- ./configure CC="cc -nodtk" -- -- On Solaris, don't put `/usr/ucb' early in your `PATH'. This --directory contains several dysfunctional programs; working variants of --these programs are available in `/usr/bin'. So, if you need `/usr/ucb' --in your `PATH', put it _after_ `/usr/bin'. -- -- On Haiku, software installed for all users goes in `/boot/common', --not `/usr/local'. It is recommended to use the following options: -- -- ./configure --prefix=/boot/common -- --Specifying the System Type --========================== -- -- There may be some features `configure' cannot figure out --automatically, but needs to determine by the type of machine the package --will run on. Usually, assuming the package is built to be run on the --_same_ architectures, `configure' can figure that out, but if it prints --a message saying it cannot guess the machine type, give it the --`--build=TYPE' option. TYPE can either be a short name for the system --type, such as `sun4', or a canonical name which has the form: -- -- CPU-COMPANY-SYSTEM -- --where SYSTEM can have one of these forms: -- -- OS -- KERNEL-OS -- -- See the file `config.sub' for the possible values of each field. If --`config.sub' isn't included in this package, then this package doesn't --need to know the machine type. -- -- If you are _building_ compiler tools for cross-compiling, you should --use the option `--target=TYPE' to select the type of system they will --produce code for. -- -- If you want to _use_ a cross compiler, that generates code for a --platform different from the build platform, you should specify the --"host" platform (i.e., that on which the generated programs will --eventually be run) with `--host=TYPE'. -- --Sharing Defaults --================ -- -- If you want to set default values for `configure' scripts to share, --you can create a site shell script called `config.site' that gives --default values for variables like `CC', `cache_file', and `prefix'. --`configure' looks for `PREFIX/share/config.site' if it exists, then --`PREFIX/etc/config.site' if it exists. Or, you can set the --`CONFIG_SITE' environment variable to the location of the site script. --A warning: not all `configure' scripts look for a site script. -- --Defining Variables --================== -- -- Variables not defined in a site shell script can be set in the --environment passed to `configure'. However, some packages may run --configure again during the build, and the customized values of these --variables may be lost. In order to avoid this problem, you should set --them in the `configure' command line, using `VAR=value'. For example: -- -- ./configure CC=/usr/local2/bin/gcc -- --causes the specified `gcc' to be used as the C compiler (unless it is --overridden in the site shell script). -- --Unfortunately, this technique does not work for `CONFIG_SHELL' due to --an Autoconf limitation. Until the limitation is lifted, you can use --this workaround: -- -- CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash -- --`configure' Invocation --====================== -- -- `configure' recognizes the following options to control how it --operates. -- --`--help' --`-h' -- Print a summary of all of the options to `configure', and exit. -- --`--help=short' --`--help=recursive' -- Print a summary of the options unique to this package's -- `configure', and exit. The `short' variant lists options used -- only in the top level, while the `recursive' variant lists options -- also present in any nested packages. -- --`--version' --`-V' -- Print the version of Autoconf used to generate the `configure' -- script, and exit. -- --`--cache-file=FILE' -- Enable the cache: use and save the results of the tests in FILE, -- traditionally `config.cache'. FILE defaults to `/dev/null' to -- disable caching. -- --`--config-cache' --`-C' -- Alias for `--cache-file=config.cache'. -- --`--quiet' --`--silent' --`-q' -- Do not print messages saying which checks are being made. To -- suppress all normal output, redirect it to `/dev/null' (any error -- messages will still be shown). -- --`--srcdir=DIR' -- Look for the package's source code in directory DIR. Usually -- `configure' can determine that directory automatically. -- --`--prefix=DIR' -- Use DIR as the installation prefix. *note Installation Names:: -- for more details, including other options available for fine-tuning -- the installation locations. -- --`--no-create' --`-n' -- Run the configure checks, but stop before creating any output -- files. -- --`configure' also accepts some other, not widely useful, options. Run --`configure --help' for more details. -diff --git a/INSTALL b/INSTALL -new file mode 120000 -index 0000000..e3f22c0 ---- /dev/null -+++ b/INSTALL -@@ -0,0 +1 @@ -+/usr/share/automake-1.16/INSTALL -\ No newline at end of file -diff --git a/src/svc.c b/src/svc.c -index 6db164b..3a8709f 100644 ---- a/src/svc.c -+++ b/src/svc.c -@@ -57,7 +57,7 @@ - - #define max(a, b) (a > b ? a : b) - --static SVCXPRT **__svc_xports; -+SVCXPRT **__svc_xports; - int __svc_maxrec; - - /* -@@ -194,6 +194,21 @@ __xprt_do_unregister (xprt, dolock) - rwlock_unlock (&svc_fd_lock); - } - -+int -+svc_open_fds() -+{ -+ int ix; -+ int nfds = 0; -+ -+ rwlock_rdlock (&svc_fd_lock); -+ for (ix = 0; ix < svc_max_pollfd; ++ix) { -+ if (svc_pollfd[ix].fd != -1) -+ nfds++; -+ } -+ rwlock_unlock (&svc_fd_lock); -+ return (nfds); -+} -+ - /* - * Add a service program to the callout list. - * The dispatch routine will be called when a rpc request for this -diff --git a/src/svc_vc.c b/src/svc_vc.c -index f1d9f00..3dc8a75 100644 ---- a/src/svc_vc.c -+++ b/src/svc_vc.c -@@ -64,6 +64,8 @@ - - - extern rwlock_t svc_fd_lock; -+extern SVCXPRT **__svc_xports; -+extern int svc_open_fds(); - - static SVCXPRT *makefd_xprt(int, u_int, u_int); - static bool_t rendezvous_request(SVCXPRT *, struct rpc_msg *); -@@ -82,6 +84,7 @@ static void svc_vc_ops(SVCXPRT *); - static bool_t svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in); - static bool_t svc_vc_rendezvous_control (SVCXPRT *xprt, const u_int rq, - void *in); -+static int __svc_destroy_idle(int timeout); - - struct cf_rendezvous { /* kept in xprt->xp_p1 for rendezvouser */ - u_int sendsize; -@@ -313,13 +316,14 @@ done: - return (xprt); - } - -+ - /*ARGSUSED*/ - static bool_t - rendezvous_request(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; - { -- int sock, flags; -+ int sock, flags, nfds, cnt; - struct cf_rendezvous *r; - struct cf_conn *cd; - struct sockaddr_storage addr; -@@ -379,6 +383,16 @@ again: - - gettimeofday(&cd->last_recv_time, NULL); - -+ nfds = svc_open_fds(); -+ if (nfds >= (_rpc_dtablesize() / 5) * 4) { -+ /* destroy idle connections */ -+ cnt = __svc_destroy_idle(15); -+ if (cnt == 0) { -+ /* destroy least active */ -+ __svc_destroy_idle(0); -+ } -+ } -+ - return (FALSE); /* there is never an rpc msg to be processed */ - } - -@@ -820,3 +834,49 @@ __svc_clean_idle(fd_set *fds, int timeout, bool_t cleanblock) - { - return FALSE; - } -+ -+static int -+__svc_destroy_idle(int timeout) -+{ -+ int i, ncleaned = 0; -+ SVCXPRT *xprt, *least_active; -+ struct timeval tv, tdiff, tmax; -+ struct cf_conn *cd; -+ -+ gettimeofday(&tv, NULL); -+ tmax.tv_sec = tmax.tv_usec = 0; -+ least_active = NULL; -+ rwlock_wrlock(&svc_fd_lock); -+ -+ for (i = 0; i <= svc_max_pollfd; i++) { -+ if (svc_pollfd[i].fd == -1) -+ continue; -+ xprt = __svc_xports[i]; -+ if (xprt == NULL || xprt->xp_ops == NULL || -+ xprt->xp_ops->xp_recv != svc_vc_recv) -+ continue; -+ cd = (struct cf_conn *)xprt->xp_p1; -+ if (!cd->nonblock) -+ continue; -+ if (timeout == 0) { -+ timersub(&tv, &cd->last_recv_time, &tdiff); -+ if (timercmp(&tdiff, &tmax, >)) { -+ tmax = tdiff; -+ least_active = xprt; -+ } -+ continue; -+ } -+ if (tv.tv_sec - cd->last_recv_time.tv_sec > timeout) { -+ __xprt_unregister_unlocked(xprt); -+ __svc_vc_dodestroy(xprt); -+ ncleaned++; -+ } -+ } -+ if (timeout == 0 && least_active != NULL) { -+ __xprt_unregister_unlocked(least_active); -+ __svc_vc_dodestroy(least_active); -+ ncleaned++; -+ } -+ rwlock_unlock(&svc_fd_lock); -+ return (ncleaned); -+} diff --git a/libtirpc-1.3.3-rc4.patch b/libtirpc-1.3.3-rc4.patch new file mode 100644 index 0000000..5c0c743 --- /dev/null +++ b/libtirpc-1.3.3-rc4.patch @@ -0,0 +1,1448 @@ +diff --git a/INSTALL b/INSTALL +deleted file mode 100644 +index 2099840..0000000 +--- a/INSTALL ++++ /dev/null +@@ -1,370 +0,0 @@ +-Installation Instructions +-************************* +- +-Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, +-Inc. +- +- Copying and distribution of this file, with or without modification, +-are permitted in any medium without royalty provided the copyright +-notice and this notice are preserved. This file is offered as-is, +-without warranty of any kind. +- +-Basic Installation +-================== +- +- Briefly, the shell command `./configure && make && make install' +-should configure, build, and install this package. The following +-more-detailed instructions are generic; see the `README' file for +-instructions specific to this package. Some packages provide this +-`INSTALL' file but do not implement all of the features documented +-below. The lack of an optional feature in a given package is not +-necessarily a bug. More recommendations for GNU packages can be found +-in *note Makefile Conventions: (standards)Makefile Conventions. +- +- The `configure' shell script attempts to guess correct values for +-various system-dependent variables used during compilation. It uses +-those values to create a `Makefile' in each directory of the package. +-It may also create one or more `.h' files containing system-dependent +-definitions. Finally, it creates a shell script `config.status' that +-you can run in the future to recreate the current configuration, and a +-file `config.log' containing compiler output (useful mainly for +-debugging `configure'). +- +- It can also use an optional file (typically called `config.cache' +-and enabled with `--cache-file=config.cache' or simply `-C') that saves +-the results of its tests to speed up reconfiguring. Caching is +-disabled by default to prevent problems with accidental use of stale +-cache files. +- +- If you need to do unusual things to compile the package, please try +-to figure out how `configure' could check whether to do them, and mail +-diffs or instructions to the address given in the `README' so they can +-be considered for the next release. If you are using the cache, and at +-some point `config.cache' contains results you don't want to keep, you +-may remove or edit it. +- +- The file `configure.ac' (or `configure.in') is used to create +-`configure' by a program called `autoconf'. You need `configure.ac' if +-you want to change it or regenerate `configure' using a newer version +-of `autoconf'. +- +- The simplest way to compile this package is: +- +- 1. `cd' to the directory containing the package's source code and type +- `./configure' to configure the package for your system. +- +- Running `configure' might take a while. While running, it prints +- some messages telling which features it is checking for. +- +- 2. Type `make' to compile the package. +- +- 3. Optionally, type `make check' to run any self-tests that come with +- the package, generally using the just-built uninstalled binaries. +- +- 4. Type `make install' to install the programs and any data files and +- documentation. When installing into a prefix owned by root, it is +- recommended that the package be configured and built as a regular +- user, and only the `make install' phase executed with root +- privileges. +- +- 5. Optionally, type `make installcheck' to repeat any self-tests, but +- this time using the binaries in their final installed location. +- This target does not install anything. Running this target as a +- regular user, particularly if the prior `make install' required +- root privileges, verifies that the installation completed +- correctly. +- +- 6. You can remove the program binaries and object files from the +- source code directory by typing `make clean'. To also remove the +- files that `configure' created (so you can compile the package for +- a different kind of computer), type `make distclean'. There is +- also a `make maintainer-clean' target, but that is intended mainly +- for the package's developers. If you use it, you may have to get +- all sorts of other programs in order to regenerate files that came +- with the distribution. +- +- 7. Often, you can also type `make uninstall' to remove the installed +- files again. In practice, not all packages have tested that +- uninstallation works correctly, even though it is required by the +- GNU Coding Standards. +- +- 8. Some packages, particularly those that use Automake, provide `make +- distcheck', which can by used by developers to test that all other +- targets like `make install' and `make uninstall' work correctly. +- This target is generally not run by end users. +- +-Compilers and Options +-===================== +- +- Some systems require unusual options for compilation or linking that +-the `configure' script does not know about. Run `./configure --help' +-for details on some of the pertinent environment variables. +- +- You can give `configure' initial values for configuration parameters +-by setting variables in the command line or in the environment. Here +-is an example: +- +- ./configure CC=c99 CFLAGS=-g LIBS=-lposix +- +- *Note Defining Variables::, for more details. +- +-Compiling For Multiple Architectures +-==================================== +- +- You can compile the package for more than one kind of computer at the +-same time, by placing the object files for each architecture in their +-own directory. To do this, you can use GNU `make'. `cd' to the +-directory where you want the object files and executables to go and run +-the `configure' script. `configure' automatically checks for the +-source code in the directory that `configure' is in and in `..'. This +-is known as a "VPATH" build. +- +- With a non-GNU `make', it is safer to compile the package for one +-architecture at a time in the source code directory. After you have +-installed the package for one architecture, use `make distclean' before +-reconfiguring for another architecture. +- +- On MacOS X 10.5 and later systems, you can create libraries and +-executables that work on multiple system types--known as "fat" or +-"universal" binaries--by specifying multiple `-arch' options to the +-compiler but only a single `-arch' option to the preprocessor. Like +-this: +- +- ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ +- CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ +- CPP="gcc -E" CXXCPP="g++ -E" +- +- This is not guaranteed to produce working output in all cases, you +-may have to build one architecture at a time and combine the results +-using the `lipo' tool if you have problems. +- +-Installation Names +-================== +- +- By default, `make install' installs the package's commands under +-`/usr/local/bin', include files under `/usr/local/include', etc. You +-can specify an installation prefix other than `/usr/local' by giving +-`configure' the option `--prefix=PREFIX', where PREFIX must be an +-absolute file name. +- +- You can specify separate installation prefixes for +-architecture-specific files and architecture-independent files. If you +-pass the option `--exec-prefix=PREFIX' to `configure', the package uses +-PREFIX as the prefix for installing programs and libraries. +-Documentation and other data files still use the regular prefix. +- +- In addition, if you use an unusual directory layout you can give +-options like `--bindir=DIR' to specify different values for particular +-kinds of files. Run `configure --help' for a list of the directories +-you can set and what kinds of files go in them. In general, the +-default for these options is expressed in terms of `${prefix}', so that +-specifying just `--prefix' will affect all of the other directory +-specifications that were not explicitly provided. +- +- The most portable way to affect installation locations is to pass the +-correct locations to `configure'; however, many packages provide one or +-both of the following shortcuts of passing variable assignments to the +-`make install' command line to change installation locations without +-having to reconfigure or recompile. +- +- The first method involves providing an override variable for each +-affected directory. For example, `make install +-prefix=/alternate/directory' will choose an alternate location for all +-directory configuration variables that were expressed in terms of +-`${prefix}'. Any directories that were specified during `configure', +-but not in terms of `${prefix}', must each be overridden at install +-time for the entire installation to be relocated. The approach of +-makefile variable overrides for each directory variable is required by +-the GNU Coding Standards, and ideally causes no recompilation. +-However, some platforms have known limitations with the semantics of +-shared libraries that end up requiring recompilation when using this +-method, particularly noticeable in packages that use GNU Libtool. +- +- The second method involves providing the `DESTDIR' variable. For +-example, `make install DESTDIR=/alternate/directory' will prepend +-`/alternate/directory' before all installation names. The approach of +-`DESTDIR' overrides is not required by the GNU Coding Standards, and +-does not work on platforms that have drive letters. On the other hand, +-it does better at avoiding recompilation issues, and works well even +-when some directory options were not specified in terms of `${prefix}' +-at `configure' time. +- +-Optional Features +-================= +- +- If the package supports it, you can cause programs to be installed +-with an extra prefix or suffix on their names by giving `configure' the +-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. +- +- Some packages pay attention to `--enable-FEATURE' options to +-`configure', where FEATURE indicates an optional part of the package. +-They may also pay attention to `--with-PACKAGE' options, where PACKAGE +-is something like `gnu-as' or `x' (for the X Window System). The +-`README' should mention any `--enable-' and `--with-' options that the +-package recognizes. +- +- For packages that use the X Window System, `configure' can usually +-find the X include and library files automatically, but if it doesn't, +-you can use the `configure' options `--x-includes=DIR' and +-`--x-libraries=DIR' to specify their locations. +- +- Some packages offer the ability to configure how verbose the +-execution of `make' will be. For these packages, running `./configure +---enable-silent-rules' sets the default to minimal output, which can be +-overridden with `make V=1'; while running `./configure +---disable-silent-rules' sets the default to verbose, which can be +-overridden with `make V=0'. +- +-Particular systems +-================== +- +- On HP-UX, the default C compiler is not ANSI C compatible. If GNU +-CC is not installed, it is recommended to use the following options in +-order to use an ANSI C compiler: +- +- ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" +- +-and if that doesn't work, install pre-built binaries of GCC for HP-UX. +- +- HP-UX `make' updates targets which have the same time stamps as +-their prerequisites, which makes it generally unusable when shipped +-generated files such as `configure' are involved. Use GNU `make' +-instead. +- +- On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +-parse its `' header file. The option `-nodtk' can be used as +-a workaround. If GNU CC is not installed, it is therefore recommended +-to try +- +- ./configure CC="cc" +- +-and if that doesn't work, try +- +- ./configure CC="cc -nodtk" +- +- On Solaris, don't put `/usr/ucb' early in your `PATH'. This +-directory contains several dysfunctional programs; working variants of +-these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +-in your `PATH', put it _after_ `/usr/bin'. +- +- On Haiku, software installed for all users goes in `/boot/common', +-not `/usr/local'. It is recommended to use the following options: +- +- ./configure --prefix=/boot/common +- +-Specifying the System Type +-========================== +- +- There may be some features `configure' cannot figure out +-automatically, but needs to determine by the type of machine the package +-will run on. Usually, assuming the package is built to be run on the +-_same_ architectures, `configure' can figure that out, but if it prints +-a message saying it cannot guess the machine type, give it the +-`--build=TYPE' option. TYPE can either be a short name for the system +-type, such as `sun4', or a canonical name which has the form: +- +- CPU-COMPANY-SYSTEM +- +-where SYSTEM can have one of these forms: +- +- OS +- KERNEL-OS +- +- See the file `config.sub' for the possible values of each field. If +-`config.sub' isn't included in this package, then this package doesn't +-need to know the machine type. +- +- If you are _building_ compiler tools for cross-compiling, you should +-use the option `--target=TYPE' to select the type of system they will +-produce code for. +- +- If you want to _use_ a cross compiler, that generates code for a +-platform different from the build platform, you should specify the +-"host" platform (i.e., that on which the generated programs will +-eventually be run) with `--host=TYPE'. +- +-Sharing Defaults +-================ +- +- If you want to set default values for `configure' scripts to share, +-you can create a site shell script called `config.site' that gives +-default values for variables like `CC', `cache_file', and `prefix'. +-`configure' looks for `PREFIX/share/config.site' if it exists, then +-`PREFIX/etc/config.site' if it exists. Or, you can set the +-`CONFIG_SITE' environment variable to the location of the site script. +-A warning: not all `configure' scripts look for a site script. +- +-Defining Variables +-================== +- +- Variables not defined in a site shell script can be set in the +-environment passed to `configure'. However, some packages may run +-configure again during the build, and the customized values of these +-variables may be lost. In order to avoid this problem, you should set +-them in the `configure' command line, using `VAR=value'. For example: +- +- ./configure CC=/usr/local2/bin/gcc +- +-causes the specified `gcc' to be used as the C compiler (unless it is +-overridden in the site shell script). +- +-Unfortunately, this technique does not work for `CONFIG_SHELL' due to +-an Autoconf limitation. Until the limitation is lifted, you can use +-this workaround: +- +- CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash +- +-`configure' Invocation +-====================== +- +- `configure' recognizes the following options to control how it +-operates. +- +-`--help' +-`-h' +- Print a summary of all of the options to `configure', and exit. +- +-`--help=short' +-`--help=recursive' +- Print a summary of the options unique to this package's +- `configure', and exit. The `short' variant lists options used +- only in the top level, while the `recursive' variant lists options +- also present in any nested packages. +- +-`--version' +-`-V' +- Print the version of Autoconf used to generate the `configure' +- script, and exit. +- +-`--cache-file=FILE' +- Enable the cache: use and save the results of the tests in FILE, +- traditionally `config.cache'. FILE defaults to `/dev/null' to +- disable caching. +- +-`--config-cache' +-`-C' +- Alias for `--cache-file=config.cache'. +- +-`--quiet' +-`--silent' +-`-q' +- Do not print messages saying which checks are being made. To +- suppress all normal output, redirect it to `/dev/null' (any error +- messages will still be shown). +- +-`--srcdir=DIR' +- Look for the package's source code in directory DIR. Usually +- `configure' can determine that directory automatically. +- +-`--prefix=DIR' +- Use DIR as the installation prefix. *note Installation Names:: +- for more details, including other options available for fine-tuning +- the installation locations. +- +-`--no-create' +-`-n' +- Run the configure checks, but stop before creating any output +- files. +- +-`configure' also accepts some other, not widely useful, options. Run +-`configure --help' for more details. +diff --git a/INSTALL b/INSTALL +new file mode 120000 +index 0000000..e3f22c0 +--- /dev/null ++++ b/INSTALL +@@ -0,0 +1 @@ ++/usr/share/automake-1.16/INSTALL +\ No newline at end of file +diff --git a/configure.ac b/configure.ac +index 013718a..23c4ac8 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -94,7 +94,7 @@ AC_PROG_LIBTOOL + AC_HEADER_DIRENT + AC_PREFIX_DEFAULT(/usr) + AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h locale.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h features.h gssapi/gssapi_ext.h]) +-AC_CHECK_LIB([pthread], [pthread_create]) ++AX_PTHREAD + AC_CHECK_FUNCS([getrpcbyname getrpcbynumber setrpcent endrpcent getrpcent]) + + AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile]) +diff --git a/libtirpc.pc.in b/libtirpc.pc.in +index d2c7878..6979747 100644 +--- a/libtirpc.pc.in ++++ b/libtirpc.pc.in +@@ -8,5 +8,5 @@ Description: Transport Independent RPC Library + Requires: + Version: @PACKAGE_VERSION@ + Libs: -L${libdir} -ltirpc +-Libs.private: -lpthread ++Libs.private: @PTHREAD_LIBS@ + Cflags: -I${includedir}/tirpc +diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 +new file mode 100644 +index 0000000..9f35d13 +--- /dev/null ++++ b/m4/ax_pthread.m4 +@@ -0,0 +1,522 @@ ++# =========================================================================== ++# https://www.gnu.org/software/autoconf-archive/ax_pthread.html ++# =========================================================================== ++# ++# SYNOPSIS ++# ++# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) ++# ++# DESCRIPTION ++# ++# This macro figures out how to build C programs using POSIX threads. It ++# sets the PTHREAD_LIBS output variable to the threads library and linker ++# flags, and the PTHREAD_CFLAGS output variable to any special C compiler ++# flags that are needed. (The user can also force certain compiler ++# flags/libs to be tested by setting these environment variables.) ++# ++# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is ++# needed for multi-threaded programs (defaults to the value of CC ++# respectively CXX otherwise). (This is necessary on e.g. AIX to use the ++# special cc_r/CC_r compiler alias.) ++# ++# NOTE: You are assumed to not only compile your program with these flags, ++# but also to link with them as well. For example, you might link with ++# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS ++# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS ++# ++# If you are only building threaded programs, you may wish to use these ++# variables in your default LIBS, CFLAGS, and CC: ++# ++# LIBS="$PTHREAD_LIBS $LIBS" ++# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" ++# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" ++# CC="$PTHREAD_CC" ++# CXX="$PTHREAD_CXX" ++# ++# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant ++# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to ++# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). ++# ++# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the ++# PTHREAD_PRIO_INHERIT symbol is defined when compiling with ++# PTHREAD_CFLAGS. ++# ++# ACTION-IF-FOUND is a list of shell commands to run if a threads library ++# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it ++# is not found. If ACTION-IF-FOUND is not specified, the default action ++# will define HAVE_PTHREAD. ++# ++# Please let the authors know if this macro fails on any platform, or if ++# you have any other suggestions or comments. This macro was based on work ++# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help ++# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by ++# Alejandro Forero Cuervo to the autoconf macro repository. We are also ++# grateful for the helpful feedback of numerous users. ++# ++# Updated for Autoconf 2.68 by Daniel Richard G. ++# ++# LICENSE ++# ++# Copyright (c) 2008 Steven G. Johnson ++# Copyright (c) 2011 Daniel Richard G. ++# Copyright (c) 2019 Marc Stevens ++# ++# This program is free software: you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by the ++# Free Software Foundation, either version 3 of the License, or (at your ++# option) any later version. ++# ++# This program is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ++# Public License for more details. ++# ++# You should have received a copy of the GNU General Public License along ++# with this program. If not, see . ++# ++# As a special exception, the respective Autoconf Macro's copyright owner ++# gives unlimited permission to copy, distribute and modify the configure ++# scripts that are the output of Autoconf when processing the Macro. You ++# need not follow the terms of the GNU General Public License when using ++# or distributing such scripts, even though portions of the text of the ++# Macro appear in them. The GNU General Public License (GPL) does govern ++# all other use of the material that constitutes the Autoconf Macro. ++# ++# This special exception to the GPL applies to versions of the Autoconf ++# Macro released by the Autoconf Archive. When you make and distribute a ++# modified version of the Autoconf Macro, you may extend this special ++# exception to the GPL to apply to your modified version as well. ++ ++#serial 31 ++ ++AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) ++AC_DEFUN([AX_PTHREAD], [ ++AC_REQUIRE([AC_CANONICAL_HOST]) ++AC_REQUIRE([AC_PROG_CC]) ++AC_REQUIRE([AC_PROG_SED]) ++AC_LANG_PUSH([C]) ++ax_pthread_ok=no ++ ++# We used to check for pthread.h first, but this fails if pthread.h ++# requires special compiler flags (e.g. on Tru64 or Sequent). ++# It gets checked for in the link test anyway. ++ ++# First of all, check if the user has set any of the PTHREAD_LIBS, ++# etcetera environment variables, and if threads linking works using ++# them: ++if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ++ ax_pthread_save_CC="$CC" ++ ax_pthread_save_CFLAGS="$CFLAGS" ++ ax_pthread_save_LIBS="$LIBS" ++ AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) ++ AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"]) ++ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" ++ LIBS="$PTHREAD_LIBS $LIBS" ++ AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) ++ AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) ++ AC_MSG_RESULT([$ax_pthread_ok]) ++ if test "x$ax_pthread_ok" = "xno"; then ++ PTHREAD_LIBS="" ++ PTHREAD_CFLAGS="" ++ fi ++ CC="$ax_pthread_save_CC" ++ CFLAGS="$ax_pthread_save_CFLAGS" ++ LIBS="$ax_pthread_save_LIBS" ++fi ++ ++# We must check for the threads library under a number of different ++# names; the ordering is very important because some systems ++# (e.g. DEC) have both -lpthread and -lpthreads, where one of the ++# libraries is broken (non-POSIX). ++ ++# Create a list of thread flags to try. Items with a "," contain both ++# C compiler flags (before ",") and linker flags (after ","). Other items ++# starting with a "-" are C compiler flags, and remaining items are ++# library names, except for "none" which indicates that we try without ++# any flags at all, and "pthread-config" which is a program returning ++# the flags for the Pth emulation library. ++ ++ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" ++ ++# The ordering *is* (sometimes) important. Some notes on the ++# individual items follow: ++ ++# pthreads: AIX (must check this before -lpthread) ++# none: in case threads are in libc; should be tried before -Kthread and ++# other compiler flags to prevent continual compiler warnings ++# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) ++# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 ++# (Note: HP C rejects this with "bad form for `-t' option") ++# -pthreads: Solaris/gcc (Note: HP C also rejects) ++# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it ++# doesn't hurt to check since this sometimes defines pthreads and ++# -D_REENTRANT too), HP C (must be checked before -lpthread, which ++# is present but should not be used directly; and before -mthreads, ++# because the compiler interprets this as "-mt" + "-hreads") ++# -mthreads: Mingw32/gcc, Lynx/gcc ++# pthread: Linux, etcetera ++# --thread-safe: KAI C++ ++# pthread-config: use pthread-config program (for GNU Pth library) ++ ++case $host_os in ++ ++ freebsd*) ++ ++ # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) ++ # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) ++ ++ ax_pthread_flags="-kthread lthread $ax_pthread_flags" ++ ;; ++ ++ hpux*) ++ ++ # From the cc(1) man page: "[-mt] Sets various -D flags to enable ++ # multi-threading and also sets -lpthread." ++ ++ ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" ++ ;; ++ ++ openedition*) ++ ++ # IBM z/OS requires a feature-test macro to be defined in order to ++ # enable POSIX threads at all, so give the user a hint if this is ++ # not set. (We don't define these ourselves, as they can affect ++ # other portions of the system API in unpredictable ways.) ++ ++ AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING], ++ [ ++# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) ++ AX_PTHREAD_ZOS_MISSING ++# endif ++ ], ++ [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])]) ++ ;; ++ ++ solaris*) ++ ++ # On Solaris (at least, for some versions), libc contains stubbed ++ # (non-functional) versions of the pthreads routines, so link-based ++ # tests will erroneously succeed. (N.B.: The stubs are missing ++ # pthread_cleanup_push, or rather a function called by this macro, ++ # so we could check for that, but who knows whether they'll stub ++ # that too in a future libc.) So we'll check first for the ++ # standard Solaris way of linking pthreads (-mt -lpthread). ++ ++ ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags" ++ ;; ++esac ++ ++# Are we compiling with Clang? ++ ++AC_CACHE_CHECK([whether $CC is Clang], ++ [ax_cv_PTHREAD_CLANG], ++ [ax_cv_PTHREAD_CLANG=no ++ # Note that Autoconf sets GCC=yes for Clang as well as GCC ++ if test "x$GCC" = "xyes"; then ++ AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], ++ [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ ++# if defined(__clang__) && defined(__llvm__) ++ AX_PTHREAD_CC_IS_CLANG ++# endif ++ ], ++ [ax_cv_PTHREAD_CLANG=yes]) ++ fi ++ ]) ++ax_pthread_clang="$ax_cv_PTHREAD_CLANG" ++ ++ ++# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) ++ ++# Note that for GCC and Clang -pthread generally implies -lpthread, ++# except when -nostdlib is passed. ++# This is problematic using libtool to build C++ shared libraries with pthread: ++# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 ++# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 ++# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 ++# To solve this, first try -pthread together with -lpthread for GCC ++ ++AS_IF([test "x$GCC" = "xyes"], ++ [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"]) ++ ++# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first ++ ++AS_IF([test "x$ax_pthread_clang" = "xyes"], ++ [ax_pthread_flags="-pthread,-lpthread -pthread"]) ++ ++ ++# The presence of a feature test macro requesting re-entrant function ++# definitions is, on some systems, a strong hint that pthreads support is ++# correctly enabled ++ ++case $host_os in ++ darwin* | hpux* | linux* | osf* | solaris*) ++ ax_pthread_check_macro="_REENTRANT" ++ ;; ++ ++ aix*) ++ ax_pthread_check_macro="_THREAD_SAFE" ++ ;; ++ ++ *) ++ ax_pthread_check_macro="--" ++ ;; ++esac ++AS_IF([test "x$ax_pthread_check_macro" = "x--"], ++ [ax_pthread_check_cond=0], ++ [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) ++ ++ ++if test "x$ax_pthread_ok" = "xno"; then ++for ax_pthread_try_flag in $ax_pthread_flags; do ++ ++ case $ax_pthread_try_flag in ++ none) ++ AC_MSG_CHECKING([whether pthreads work without any flags]) ++ ;; ++ ++ *,*) ++ PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` ++ PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` ++ AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"]) ++ ;; ++ ++ -*) ++ AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) ++ PTHREAD_CFLAGS="$ax_pthread_try_flag" ++ ;; ++ ++ pthread-config) ++ AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) ++ AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) ++ PTHREAD_CFLAGS="`pthread-config --cflags`" ++ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ++ ;; ++ ++ *) ++ AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) ++ PTHREAD_LIBS="-l$ax_pthread_try_flag" ++ ;; ++ esac ++ ++ ax_pthread_save_CFLAGS="$CFLAGS" ++ ax_pthread_save_LIBS="$LIBS" ++ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" ++ LIBS="$PTHREAD_LIBS $LIBS" ++ ++ # Check for various functions. We must include pthread.h, ++ # since some functions may be macros. (On the Sequent, we ++ # need a special flag -Kthread to make this header compile.) ++ # We check for pthread_join because it is in -lpthread on IRIX ++ # while pthread_create is in libc. We check for pthread_attr_init ++ # due to DEC craziness with -lpthreads. We check for ++ # pthread_cleanup_push because it is one of the few pthread ++ # functions on Solaris that doesn't have a non-functional libc stub. ++ # We try pthread_create on general principles. ++ ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ++# if $ax_pthread_check_cond ++# error "$ax_pthread_check_macro must be defined" ++# endif ++ static void *some_global = NULL; ++ static void routine(void *a) ++ { ++ /* To avoid any unused-parameter or ++ unused-but-set-parameter warning. */ ++ some_global = a; ++ } ++ static void *start_routine(void *a) { return a; }], ++ [pthread_t th; pthread_attr_t attr; ++ pthread_create(&th, 0, start_routine, 0); ++ pthread_join(th, 0); ++ pthread_attr_init(&attr); ++ pthread_cleanup_push(routine, 0); ++ pthread_cleanup_pop(0) /* ; */])], ++ [ax_pthread_ok=yes], ++ []) ++ ++ CFLAGS="$ax_pthread_save_CFLAGS" ++ LIBS="$ax_pthread_save_LIBS" ++ ++ AC_MSG_RESULT([$ax_pthread_ok]) ++ AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) ++ ++ PTHREAD_LIBS="" ++ PTHREAD_CFLAGS="" ++done ++fi ++ ++ ++# Clang needs special handling, because older versions handle the -pthread ++# option in a rather... idiosyncratic way ++ ++if test "x$ax_pthread_clang" = "xyes"; then ++ ++ # Clang takes -pthread; it has never supported any other flag ++ ++ # (Note 1: This will need to be revisited if a system that Clang ++ # supports has POSIX threads in a separate library. This tends not ++ # to be the way of modern systems, but it's conceivable.) ++ ++ # (Note 2: On some systems, notably Darwin, -pthread is not needed ++ # to get POSIX threads support; the API is always present and ++ # active. We could reasonably leave PTHREAD_CFLAGS empty. But ++ # -pthread does define _REENTRANT, and while the Darwin headers ++ # ignore this macro, third-party headers might not.) ++ ++ # However, older versions of Clang make a point of warning the user ++ # that, in an invocation where only linking and no compilation is ++ # taking place, the -pthread option has no effect ("argument unused ++ # during compilation"). They expect -pthread to be passed in only ++ # when source code is being compiled. ++ # ++ # Problem is, this is at odds with the way Automake and most other ++ # C build frameworks function, which is that the same flags used in ++ # compilation (CFLAGS) are also used in linking. Many systems ++ # supported by AX_PTHREAD require exactly this for POSIX threads ++ # support, and in fact it is often not straightforward to specify a ++ # flag that is used only in the compilation phase and not in ++ # linking. Such a scenario is extremely rare in practice. ++ # ++ # Even though use of the -pthread flag in linking would only print ++ # a warning, this can be a nuisance for well-run software projects ++ # that build with -Werror. So if the active version of Clang has ++ # this misfeature, we search for an option to squash it. ++ ++ AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], ++ [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], ++ [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown ++ # Create an alternate version of $ac_link that compiles and ++ # links in two steps (.c -> .o, .o -> exe) instead of one ++ # (.c -> exe), because the warning occurs only in the second ++ # step ++ ax_pthread_save_ac_link="$ac_link" ++ ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' ++ ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"` ++ ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" ++ ax_pthread_save_CFLAGS="$CFLAGS" ++ for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do ++ AS_IF([test "x$ax_pthread_try" = "xunknown"], [break]) ++ CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" ++ ac_link="$ax_pthread_save_ac_link" ++ AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], ++ [ac_link="$ax_pthread_2step_ac_link" ++ AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], ++ [break]) ++ ]) ++ done ++ ac_link="$ax_pthread_save_ac_link" ++ CFLAGS="$ax_pthread_save_CFLAGS" ++ AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no]) ++ ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" ++ ]) ++ ++ case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in ++ no | unknown) ;; ++ *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; ++ esac ++ ++fi # $ax_pthread_clang = yes ++ ++ ++ ++# Various other checks: ++if test "x$ax_pthread_ok" = "xyes"; then ++ ax_pthread_save_CFLAGS="$CFLAGS" ++ ax_pthread_save_LIBS="$LIBS" ++ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" ++ LIBS="$PTHREAD_LIBS $LIBS" ++ ++ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. ++ AC_CACHE_CHECK([for joinable pthread attribute], ++ [ax_cv_PTHREAD_JOINABLE_ATTR], ++ [ax_cv_PTHREAD_JOINABLE_ATTR=unknown ++ for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], ++ [int attr = $ax_pthread_attr; return attr /* ; */])], ++ [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], ++ []) ++ done ++ ]) ++ AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ ++ test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ ++ test "x$ax_pthread_joinable_attr_defined" != "xyes"], ++ [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], ++ [$ax_cv_PTHREAD_JOINABLE_ATTR], ++ [Define to necessary symbol if this constant ++ uses a non-standard name on your system.]) ++ ax_pthread_joinable_attr_defined=yes ++ ]) ++ ++ AC_CACHE_CHECK([whether more special flags are required for pthreads], ++ [ax_cv_PTHREAD_SPECIAL_FLAGS], ++ [ax_cv_PTHREAD_SPECIAL_FLAGS=no ++ case $host_os in ++ solaris*) ++ ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" ++ ;; ++ esac ++ ]) ++ AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ ++ test "x$ax_pthread_special_flags_added" != "xyes"], ++ [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" ++ ax_pthread_special_flags_added=yes]) ++ ++ AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], ++ [ax_cv_PTHREAD_PRIO_INHERIT], ++ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], ++ [[int i = PTHREAD_PRIO_INHERIT; ++ return i;]])], ++ [ax_cv_PTHREAD_PRIO_INHERIT=yes], ++ [ax_cv_PTHREAD_PRIO_INHERIT=no]) ++ ]) ++ AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ ++ test "x$ax_pthread_prio_inherit_defined" != "xyes"], ++ [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.]) ++ ax_pthread_prio_inherit_defined=yes ++ ]) ++ ++ CFLAGS="$ax_pthread_save_CFLAGS" ++ LIBS="$ax_pthread_save_LIBS" ++ ++ # More AIX lossage: compile with *_r variant ++ if test "x$GCC" != "xyes"; then ++ case $host_os in ++ aix*) ++ AS_CASE(["x/$CC"], ++ [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], ++ [#handle absolute path differently from PATH based program lookup ++ AS_CASE(["x$CC"], ++ [x/*], ++ [ ++ AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"]) ++ AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])]) ++ ], ++ [ ++ AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC]) ++ AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])]) ++ ] ++ ) ++ ]) ++ ;; ++ esac ++ fi ++fi ++ ++test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" ++test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" ++ ++AC_SUBST([PTHREAD_LIBS]) ++AC_SUBST([PTHREAD_CFLAGS]) ++AC_SUBST([PTHREAD_CC]) ++AC_SUBST([PTHREAD_CXX]) ++ ++# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: ++if test "x$ax_pthread_ok" = "xyes"; then ++ ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) ++ : ++else ++ ax_pthread_ok=no ++ $2 ++fi ++AC_LANG_POP ++])dnl AX_PTHREAD +diff --git a/man/rpcbind.3t b/man/rpcbind.3t +index ec492cc..4cb271b 100644 +--- a/man/rpcbind.3t ++++ b/man/rpcbind.3t +@@ -187,6 +187,8 @@ in + .El + .Sh AVAILABILITY + These functions are part of libtirpc. ++.Sh ENVIRONMENT ++If RPCB_V2FIRST is defined, rpcbind protocol version tryout algorithm changes from v4,v2,v3 to v2,v4,v3. + .Sh SEE ALSO + .Xr rpc_clnt_calls 3 , + .Xr rpc_svc_calls 3 , +diff --git a/src/Makefile.am b/src/Makefile.am +index b2d5436..0cef093 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -12,7 +12,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/tirpc -include config.h -DPORTMAP -DINET6 \ + + lib_LTLIBRARIES = libtirpc.la + +-libtirpc_la_LDFLAGS = @LDFLAG_NOUNDEFINED@ -no-undefined -lpthread ++libtirpc_la_LDFLAGS = @LDFLAG_NOUNDEFINED@ -no-undefined @PTHREAD_LIBS@ + libtirpc_la_LDFLAGS += -version-info @LT_VERSION_INFO@ + + libtirpc_la_SOURCES = auth_none.c auth_unix.c authunix_prot.c \ +diff --git a/src/bindresvport.c b/src/bindresvport.c +index ef9b345..5c0ddcf 100644 +--- a/src/bindresvport.c ++++ b/src/bindresvport.c +@@ -164,10 +164,11 @@ bindresvport_sa(sd, sa) + int endport = ENDPORT; + int i; + ++ mutex_lock(&port_lock); ++ + if (!blacklist_read) + load_blacklist(); + +- mutex_lock(&port_lock); + nports = ENDPORT - startport + 1; + + if (sa == NULL) { +diff --git a/src/clnt_dg.c b/src/clnt_dg.c +index e1255de..166af63 100644 +--- a/src/clnt_dg.c ++++ b/src/clnt_dg.c +@@ -101,9 +101,10 @@ extern mutex_t clnt_fd_lock; + #define release_fd_lock(fd_lock, mask) { \ + mutex_lock(&clnt_fd_lock); \ + fd_lock->active = FALSE; \ +- mutex_unlock(&clnt_fd_lock); \ ++ fd_lock->pending--; \ + thr_sigsetmask(SIG_SETMASK, &(mask), NULL); \ + cond_signal(&fd_lock->cv); \ ++ mutex_unlock(&clnt_fd_lock); \ + } + + static const char mem_err_clnt_dg[] = "clnt_dg_create: out of memory"; +@@ -172,12 +173,15 @@ clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz) + if (dg_fd_locks == (fd_locks_t *) NULL) { + dg_fd_locks = fd_locks_init(); + if (dg_fd_locks == (fd_locks_t *) NULL) { ++ mutex_unlock(&clnt_fd_lock); + goto err1; + } + } + fd_lock = fd_lock_create(fd, dg_fd_locks); +- if (fd_lock == (fd_lock_t *) NULL) ++ if (fd_lock == (fd_lock_t *) NULL) { ++ mutex_unlock(&clnt_fd_lock); + goto err1; ++ } + + mutex_unlock(&clnt_fd_lock); + thr_sigsetmask(SIG_SETMASK, &(mask), NULL); +@@ -308,6 +312,7 @@ clnt_dg_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) + sigfillset(&newmask); + thr_sigsetmask(SIG_SETMASK, &newmask, &mask); + mutex_lock(&clnt_fd_lock); ++ cu->cu_fd_lock->pending++; + while (cu->cu_fd_lock->active) + cond_wait(&cu->cu_fd_lock->cv, &clnt_fd_lock); + cu->cu_fd_lock->active = TRUE; +@@ -456,9 +461,9 @@ get_reply: + cmsg = CMSG_NXTHDR (&msg, cmsg)) + if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR) + { +- mem_free(cbuf, (outlen + 256)); + e = (struct sock_extended_err *) CMSG_DATA(cmsg); + cu->cu_error.re_errno = e->ee_errno; ++ mem_free(cbuf, (outlen + 256)); + release_fd_lock(cu->cu_fd_lock, mask); + return (cu->cu_error.re_status = RPC_CANTRECV); + } +@@ -568,14 +573,15 @@ clnt_dg_freeres(cl, xdr_res, res_ptr) + sigfillset(&newmask); + thr_sigsetmask(SIG_SETMASK, &newmask, &mask); + mutex_lock(&clnt_fd_lock); ++ cu->cu_fd_lock->pending++; + while (cu->cu_fd_lock->active) + cond_wait(&cu->cu_fd_lock->cv, &clnt_fd_lock); +- cu->cu_fd_lock->active = TRUE; + xdrs->x_op = XDR_FREE; + dummy = (*xdr_res)(xdrs, res_ptr); +- mutex_unlock(&clnt_fd_lock); ++ cu->cu_fd_lock->pending--; + thr_sigsetmask(SIG_SETMASK, &mask, NULL); + cond_signal(&cu->cu_fd_lock->cv); ++ mutex_unlock(&clnt_fd_lock); + return (dummy); + } + +@@ -600,6 +606,7 @@ clnt_dg_control(cl, request, info) + sigfillset(&newmask); + thr_sigsetmask(SIG_SETMASK, &newmask, &mask); + mutex_lock(&clnt_fd_lock); ++ cu->cu_fd_lock->pending++; + while (cu->cu_fd_lock->active) + cond_wait(&cu->cu_fd_lock->cv, &clnt_fd_lock); + cu->cu_fd_lock->active = TRUE; +@@ -740,8 +747,14 @@ clnt_dg_destroy(cl) + sigfillset(&newmask); + thr_sigsetmask(SIG_SETMASK, &newmask, &mask); + mutex_lock(&clnt_fd_lock); +- while (cu_fd_lock->active) ++ /* wait until all pending operations on client are completed. */ ++ while (cu_fd_lock->pending > 0) { ++ /* If a blocked operation can be awakened, then do it. */ ++ if (cu_fd_lock->active == FALSE) ++ cond_signal(&cu_fd_lock->cv); ++ /* keep waiting... */ + cond_wait(&cu_fd_lock->cv, &clnt_fd_lock); ++ } + if (cu->cu_closeit) + (void)close(cu_fd); + XDR_DESTROY(&(cu->cu_outxdrs)); +diff --git a/src/clnt_fd_locks.h b/src/clnt_fd_locks.h +index 359f995..6ba62cb 100644 +--- a/src/clnt_fd_locks.h ++++ b/src/clnt_fd_locks.h +@@ -50,6 +50,7 @@ static unsigned int fd_locks_prealloc = 0; + /* per-fd lock */ + struct fd_lock_t { + bool_t active; ++ int pending; /* Number of pending operations on fd */ + cond_t cv; + }; + typedef struct fd_lock_t fd_lock_t; +@@ -180,6 +181,7 @@ fd_lock_t* fd_lock_create(int fd, fd_locks_t *fd_locks) { + item->fd = fd; + item->refs = 1; + item->fd_lock.active = FALSE; ++ item->fd_lock.pending = 0; + cond_init(&item->fd_lock.cv, 0, (void *) 0); + TAILQ_INSERT_HEAD(list, item, link); + } else { +diff --git a/src/clnt_vc.c b/src/clnt_vc.c +index a07e297..5bbc78b 100644 +--- a/src/clnt_vc.c ++++ b/src/clnt_vc.c +@@ -153,9 +153,10 @@ extern mutex_t clnt_fd_lock; + #define release_fd_lock(fd_lock, mask) { \ + mutex_lock(&clnt_fd_lock); \ + fd_lock->active = FALSE; \ +- mutex_unlock(&clnt_fd_lock); \ ++ fd_lock->pending--; \ + thr_sigsetmask(SIG_SETMASK, &(mask), (sigset_t *) NULL); \ + cond_signal(&fd_lock->cv); \ ++ mutex_unlock(&clnt_fd_lock); \ + } + + static const char clnt_vc_errstr[] = "%s : %s"; +@@ -216,7 +217,9 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz) + if (vc_fd_locks == (fd_locks_t *) NULL) { + vc_fd_locks = fd_locks_init(); + if (vc_fd_locks == (fd_locks_t *) NULL) { +- struct rpc_createerr *ce = &get_rpc_createerr(); ++ struct rpc_createerr *ce; ++ mutex_unlock(&clnt_fd_lock); ++ ce = &get_rpc_createerr(); + ce->cf_stat = RPC_SYSTEMERROR; + ce->cf_error.re_errno = errno; + goto err; +@@ -224,7 +227,9 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz) + } + fd_lock = fd_lock_create(fd, vc_fd_locks); + if (fd_lock == (fd_lock_t *) NULL) { +- struct rpc_createerr *ce = &get_rpc_createerr(); ++ struct rpc_createerr *ce; ++ mutex_unlock(&clnt_fd_lock); ++ ce = &get_rpc_createerr(); + ce->cf_stat = RPC_SYSTEMERROR; + ce->cf_error.re_errno = errno; + goto err; +@@ -353,6 +358,7 @@ clnt_vc_call(cl, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) + sigfillset(&newmask); + thr_sigsetmask(SIG_SETMASK, &newmask, &mask); + mutex_lock(&clnt_fd_lock); ++ ct->ct_fd_lock->pending++; + while (ct->ct_fd_lock->active) + cond_wait(&ct->ct_fd_lock->cv, &clnt_fd_lock); + ct->ct_fd_lock->active = TRUE; +@@ -491,13 +497,15 @@ clnt_vc_freeres(cl, xdr_res, res_ptr) + sigfillset(&newmask); + thr_sigsetmask(SIG_SETMASK, &newmask, &mask); + mutex_lock(&clnt_fd_lock); ++ ct->ct_fd_lock->pending++; + while (ct->ct_fd_lock->active) + cond_wait(&ct->ct_fd_lock->cv, &clnt_fd_lock); + xdrs->x_op = XDR_FREE; + dummy = (*xdr_res)(xdrs, res_ptr); +- mutex_unlock(&clnt_fd_lock); ++ ct->ct_fd_lock->pending--; + thr_sigsetmask(SIG_SETMASK, &(mask), NULL); + cond_signal(&ct->ct_fd_lock->cv); ++ mutex_unlock(&clnt_fd_lock); + + return dummy; + } +@@ -529,6 +537,7 @@ clnt_vc_control(cl, request, info) + sigfillset(&newmask); + thr_sigsetmask(SIG_SETMASK, &newmask, &mask); + mutex_lock(&clnt_fd_lock); ++ ct->ct_fd_lock->pending++; + while (ct->ct_fd_lock->active) + cond_wait(&ct->ct_fd_lock->cv, &clnt_fd_lock); + ct->ct_fd_lock->active = TRUE; +@@ -651,8 +660,14 @@ clnt_vc_destroy(cl) + sigfillset(&newmask); + thr_sigsetmask(SIG_SETMASK, &newmask, &mask); + mutex_lock(&clnt_fd_lock); +- while (ct_fd_lock->active) ++ /* wait until all pending operations on client are completed. */ ++ while (ct_fd_lock->pending > 0) { ++ /* If a blocked operation can be awakened, then do it. */ ++ if (ct_fd_lock->active == FALSE) ++ cond_signal(&ct_fd_lock->cv); ++ /* keep waiting... */ + cond_wait(&ct_fd_lock->cv, &clnt_fd_lock); ++ } + if (ct->ct_closeit && ct->ct_fd != -1) { + (void)close(ct->ct_fd); + } +diff --git a/src/rpc_dtablesize.c b/src/rpc_dtablesize.c +index 3fe503a..bce97e8 100644 +--- a/src/rpc_dtablesize.c ++++ b/src/rpc_dtablesize.c +@@ -41,7 +41,7 @@ _rpc_dtablesize(void) + static int size; + + if (size == 0) { +- size = getdtablesize(); ++ size = sysconf(_SC_OPEN_MAX); + } + return (size); + } +diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c +index 0c34cb7..06f4528 100644 +--- a/src/rpcb_clnt.c ++++ b/src/rpcb_clnt.c +@@ -798,6 +798,10 @@ __try_protocol_version_2(program, version, nconf, host, tp) + pmapaddress->len = pmapaddress->maxlen = remote.len; + + CLNT_DESTROY(client); ++ ++ if (parms.r_addr != NULL && parms.r_addr != nullstring) ++ free(parms.r_addr); ++ + return pmapaddress; + + error: +@@ -806,6 +810,10 @@ error: + client = NULL; + + } ++ ++ if (parms.r_addr != NULL && parms.r_addr != nullstring) ++ free(parms.r_addr); ++ + return (NULL); + + } +@@ -818,7 +826,8 @@ error: + * The algorithm used: If the transports is TCP or UDP, it first tries + * version 4 (srv4), then 3 and then fall back to version 2 (portmap). + * With this algorithm, we get performance as well as a plan for +- * obsoleting version 2. ++ * obsoleting version 2. This behaviour is reverted to old algorithm ++ * if RPCB_V2FIRST environment var is defined + * + * For all other transports, the algorithm remains as 4 and then 3. + * +@@ -839,6 +848,10 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) + #ifdef NOTUSED + static bool_t check_rpcbind = TRUE; + #endif ++ ++#ifdef PORTMAP ++ static bool_t portmap_first = FALSE; ++#endif + CLIENT *client = NULL; + RPCB parms; + enum clnt_stat clnt_st; +@@ -895,8 +908,18 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) + parms.r_addr = (char *) &nullstring[0]; + } + +- /* First try from start_vers(4) and then version 3 (RPCBVERS) */ ++ /* First try from start_vers(4) and then version 3 (RPCBVERS), except ++ * if env. var RPCB_V2FIRST is defined */ ++ ++#ifdef PORTMAP ++ if (getenv(V2FIRST)) { ++ portmap_first = TRUE; ++ LIBTIRPC_DEBUG(3, ("__rpcb_findaddr_timed: trying v2-port first\n")); ++ goto portmap; ++ } ++#endif + ++rpcbind: + CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *) &rpcbrmttime); + for (vers = start_vers; vers >= RPCBVERS; vers--) { + /* Set the version */ +@@ -944,10 +967,17 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) + } + + #ifdef PORTMAP /* Try version 2 for TCP or UDP */ ++ if (portmap_first) ++ goto error; /* we tried all versions if reached here */ ++portmap: + if (strcmp(nconf->nc_protofmly, NC_INET) == 0) { + address = __try_protocol_version_2(program, version, nconf, host, tp); +- if (address == NULL) +- goto error; ++ if (address == NULL) { ++ if (portmap_first) ++ goto rpcbind; ++ else ++ goto error; ++ } + } + #endif /* PORTMAP */ + +diff --git a/src/svc.c b/src/svc.c +index 6db164b..3a8709f 100644 +--- a/src/svc.c ++++ b/src/svc.c +@@ -57,7 +57,7 @@ + + #define max(a, b) (a > b ? a : b) + +-static SVCXPRT **__svc_xports; ++SVCXPRT **__svc_xports; + int __svc_maxrec; + + /* +@@ -194,6 +194,21 @@ __xprt_do_unregister (xprt, dolock) + rwlock_unlock (&svc_fd_lock); + } + ++int ++svc_open_fds() ++{ ++ int ix; ++ int nfds = 0; ++ ++ rwlock_rdlock (&svc_fd_lock); ++ for (ix = 0; ix < svc_max_pollfd; ++ix) { ++ if (svc_pollfd[ix].fd != -1) ++ nfds++; ++ } ++ rwlock_unlock (&svc_fd_lock); ++ return (nfds); ++} ++ + /* + * Add a service program to the callout list. + * The dispatch routine will be called when a rpc request for this +diff --git a/src/svc_vc.c b/src/svc_vc.c +index f1d9f00..3dc8a75 100644 +--- a/src/svc_vc.c ++++ b/src/svc_vc.c +@@ -64,6 +64,8 @@ + + + extern rwlock_t svc_fd_lock; ++extern SVCXPRT **__svc_xports; ++extern int svc_open_fds(); + + static SVCXPRT *makefd_xprt(int, u_int, u_int); + static bool_t rendezvous_request(SVCXPRT *, struct rpc_msg *); +@@ -82,6 +84,7 @@ static void svc_vc_ops(SVCXPRT *); + static bool_t svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in); + static bool_t svc_vc_rendezvous_control (SVCXPRT *xprt, const u_int rq, + void *in); ++static int __svc_destroy_idle(int timeout); + + struct cf_rendezvous { /* kept in xprt->xp_p1 for rendezvouser */ + u_int sendsize; +@@ -313,13 +316,14 @@ done: + return (xprt); + } + ++ + /*ARGSUSED*/ + static bool_t + rendezvous_request(xprt, msg) + SVCXPRT *xprt; + struct rpc_msg *msg; + { +- int sock, flags; ++ int sock, flags, nfds, cnt; + struct cf_rendezvous *r; + struct cf_conn *cd; + struct sockaddr_storage addr; +@@ -379,6 +383,16 @@ again: + + gettimeofday(&cd->last_recv_time, NULL); + ++ nfds = svc_open_fds(); ++ if (nfds >= (_rpc_dtablesize() / 5) * 4) { ++ /* destroy idle connections */ ++ cnt = __svc_destroy_idle(15); ++ if (cnt == 0) { ++ /* destroy least active */ ++ __svc_destroy_idle(0); ++ } ++ } ++ + return (FALSE); /* there is never an rpc msg to be processed */ + } + +@@ -820,3 +834,49 @@ __svc_clean_idle(fd_set *fds, int timeout, bool_t cleanblock) + { + return FALSE; + } ++ ++static int ++__svc_destroy_idle(int timeout) ++{ ++ int i, ncleaned = 0; ++ SVCXPRT *xprt, *least_active; ++ struct timeval tv, tdiff, tmax; ++ struct cf_conn *cd; ++ ++ gettimeofday(&tv, NULL); ++ tmax.tv_sec = tmax.tv_usec = 0; ++ least_active = NULL; ++ rwlock_wrlock(&svc_fd_lock); ++ ++ for (i = 0; i <= svc_max_pollfd; i++) { ++ if (svc_pollfd[i].fd == -1) ++ continue; ++ xprt = __svc_xports[i]; ++ if (xprt == NULL || xprt->xp_ops == NULL || ++ xprt->xp_ops->xp_recv != svc_vc_recv) ++ continue; ++ cd = (struct cf_conn *)xprt->xp_p1; ++ if (!cd->nonblock) ++ continue; ++ if (timeout == 0) { ++ timersub(&tv, &cd->last_recv_time, &tdiff); ++ if (timercmp(&tdiff, &tmax, >)) { ++ tmax = tdiff; ++ least_active = xprt; ++ } ++ continue; ++ } ++ if (tv.tv_sec - cd->last_recv_time.tv_sec > timeout) { ++ __xprt_unregister_unlocked(xprt); ++ __svc_vc_dodestroy(xprt); ++ ncleaned++; ++ } ++ } ++ if (timeout == 0 && least_active != NULL) { ++ __xprt_unregister_unlocked(least_active); ++ __svc_vc_dodestroy(least_active); ++ ncleaned++; ++ } ++ rwlock_unlock(&svc_fd_lock); ++ return (ncleaned); ++} +diff --git a/tirpc/rpc/pmap_prot.h b/tirpc/rpc/pmap_prot.h +index 75354ce..7718b8b 100644 +--- a/tirpc/rpc/pmap_prot.h ++++ b/tirpc/rpc/pmap_prot.h +@@ -84,6 +84,8 @@ + #define PMAPPROC_DUMP ((u_long)4) + #define PMAPPROC_CALLIT ((u_long)5) + ++#define V2FIRST "RPCB_V2FIRST" ++ + struct pmap { + long unsigned pm_prog; + long unsigned pm_vers; +diff --git a/tirpc/rpc/types.h b/tirpc/rpc/types.h +index 0153a5c..798992a 100644 +--- a/tirpc/rpc/types.h ++++ b/tirpc/rpc/types.h +@@ -71,6 +71,11 @@ typedef int32_t rpc_inline_t; + # define __daddr_t_defined + #endif + ++#if defined __BIONIC__ ++typedef int64_t quad_t; ++typedef uint64_t u_quad_t; ++#endif ++ + #ifndef __u_char_defined + typedef __u_char u_char; + typedef __u_short u_short; diff --git a/libtirpc.spec b/libtirpc.spec index 4d799ff..53dd587 100644 --- a/libtirpc.spec +++ b/libtirpc.spec @@ -2,13 +2,13 @@ Name: libtirpc Version: 1.3.2 -Release: 1.rc1%{?dist}.2 +Release: 1.rc4%{?dist} Summary: Transport Independent RPC Library License: SISSL and BSD URL: http://git.linux-nfs.org/?p=steved/libtirpc.git;a=summary Source0: http://downloads.sourceforge.net/libtirpc/libtirpc-%{version}.tar.bz2 -Patch001: libtirpc-1.3.3-rc1.patch +Patch001: libtirpc-1.3.3-rc4.patch BuildRequires: automake, autoconf, libtool, pkgconfig BuildRequires: krb5-devel @@ -114,6 +114,9 @@ mv %{buildroot}%{_mandir}/man3 %{buildroot}%{_mandir}/man3t %{_mandir}/*/* %changelog +* Thu Jul 28 2022 Steve Dickson - 1.3.2-1.rc4 +- Updated to the latest upstream RC release: libtirpc-1-3-3-rc4 + * Thu Jul 21 2022 Fedora Release Engineering - 1.3.2-1.rc1.2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild