Blame SOURCES/libtirpc-0.2.4-makefd_xprt-fd.patch

1dab28
diff -up libtirpc-0.2.4/src/rtime.c.orig libtirpc-0.2.4/src/rtime.c
1dab28
--- libtirpc-0.2.4/src/rtime.c.orig	2013-12-09 15:59:51.000000000 -0500
1dab28
+++ libtirpc-0.2.4/src/rtime.c	2017-02-25 12:29:25.227847702 -0500
1dab28
@@ -46,6 +46,7 @@
1dab28
 #include <unistd.h>
1dab28
 #include <errno.h>
1dab28
 #include <sys/types.h>
1dab28
+#include <sys/poll.h>
1dab28
 #include <sys/socket.h>
1dab28
 #include <sys/time.h>
1dab28
 #include <netinet/in.h>
1dab28
@@ -67,7 +68,8 @@ rtime(addrp, timep, timeout)
1dab28
 	struct timeval *timeout;
1dab28
 {
1dab28
 	int s;
1dab28
-	fd_set readfds;
1dab28
+	struct pollfd fd;
1dab28
+	int milliseconds;
1dab28
 	int res;
1dab28
 	unsigned long thetime;
1dab28
 	struct sockaddr_in from;
1dab28
@@ -94,31 +96,32 @@ rtime(addrp, timep, timeout)
1dab28
 	addrp->sin_port = serv->s_port;
1dab28
 
1dab28
 	if (type == SOCK_DGRAM) {
1dab28
-		res = sendto(s, (char *)&thetime, sizeof(thetime), 0, 
1dab28
+		res = sendto(s, (char *)&thetime, sizeof(thetime), 0,
1dab28
 			     (struct sockaddr *)addrp, sizeof(*addrp));
1dab28
 		if (res < 0) {
1dab28
 			do_close(s);
1dab28
-			return(-1);	
1dab28
+			return(-1);
1dab28
 		}
1dab28
-		do {
1dab28
-			FD_ZERO(&readfds);
1dab28
-			FD_SET(s, &readfds);
1dab28
-			res = select(_rpc_dtablesize(), &readfds,
1dab28
-				     (fd_set *)NULL, (fd_set *)NULL, timeout);
1dab28
-		} while (res < 0 && errno == EINTR);
1dab28
+
1dab28
+		milliseconds = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000);
1dab28
+		fd.fd = s;
1dab28
+		fd.events = POLLIN;
1dab28
+		do
1dab28
+		  res = poll (&fd, 1, milliseconds);
1dab28
+		while (res < 0 && errno == EINTR);
1dab28
 		if (res <= 0) {
1dab28
 			if (res == 0) {
1dab28
 				errno = ETIMEDOUT;
1dab28
 			}
1dab28
 			do_close(s);
1dab28
-			return(-1);	
1dab28
+			return(-1);
1dab28
 		}
1dab28
 		fromlen = sizeof(from);
1dab28
-		res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0, 
1dab28
+		res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0,
1dab28
 			       (struct sockaddr *)&from, &fromlen);
1dab28
 		do_close(s);
1dab28
 		if (res < 0) {
1dab28
-			return(-1);	
1dab28
+			return(-1);
1dab28
 		}
1dab28
 	} else {
1dab28
 		if (connect(s, (struct sockaddr *)addrp, sizeof(*addrp)) < 0) {
1dab28
diff -up libtirpc-0.2.4/src/svc_vc.c.orig libtirpc-0.2.4/src/svc_vc.c
1dab28
--- libtirpc-0.2.4/src/svc_vc.c.orig	2017-02-25 12:26:55.430978326 -0500
1dab28
+++ libtirpc-0.2.4/src/svc_vc.c	2017-02-25 12:29:25.227847702 -0500
1dab28
@@ -260,14 +260,8 @@ makefd_xprt(fd, sendsize, recvsize)
1dab28
 	struct cf_conn *cd;
1dab28
 	const char *netid;
1dab28
 	struct __rpc_sockinfo si;
1dab28
- 
1dab28
-	assert(fd != -1);
1dab28
 
1dab28
-        if (fd >= FD_SETSIZE) {
1dab28
-                warnx("svc_vc: makefd_xprt: fd too high\n");
1dab28
-                xprt = NULL;
1dab28
-                goto done;
1dab28
-        }
1dab28
+	assert(fd != -1);
1dab28
 
1dab28
 	xprt = mem_alloc(sizeof(SVCXPRT));
1dab28
 	if (xprt == NULL) {
1dab28
@@ -340,6 +334,8 @@ again:
1dab28
 	 */
1dab28
 
1dab28
 	newxprt = makefd_xprt(sock, r->sendsize, r->recvsize);
1dab28
+	if (!newxprt)
1dab28
+		return (FALSE);
1dab28
 
1dab28
 	if (!__rpc_set_netbuf(&newxprt->xp_rtaddr, &addr, len))
1dab28
 		return (FALSE);