This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

sunrpc patch that fixes nfs-server initialization timeouts


This patch fixes the problem that is causing the following error message:

Cannot register service: RPC: Timed out
rpcmisc.c 99 : unable to register

The problem is described here:
http://cygwin.com/ml/cygwin/2004-08/msg00900.html
http://cygwin.com/ml/cygwin/2013-06/msg00304.html

Sunrpc uses an ioctl to get the local IP address of the machine. This is error prone and in case you have more than one network interfaces it will most probably not work. A better alternative would be to use the loopback address (127.0.0.1).

The procedure to apply the patch is the following:
* Download source packages nfs-server and sunrpc.
* Execute use_loopback.sh

--
George Prekas
Dipl. Electrical and Computer Engineer, National Technical University of Athens
--- a/etc/portmap.c
+++ b/etc/portmap.c
@@ -52,7 +52,6 @@ static	char sccsid[] = "@(#)portmap.c 1.32 87/08/06 Copyr 1984 Sun Micro";
 
 static callit();
 
-char *malloc();
 int reg_service();
 void reap();
 struct pmaplist *pmaplist;
diff --git a/rpc/xdr.c b/rpc/xdr.c
index e9c8382..f370b10 100644
--- a/rpc/xdr.c
+++ b/rpc/xdr.c
@@ -42,7 +42,6 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
  */
 
 #include <stdio.h>
-char *malloc();
 
 #include <rpc/types.h>
 #include <rpc/xdr.h>
--- a/rpc/get_myaddress.c
+++ b/rpc/get_myaddress.c
@@ -53,38 +53,7 @@ static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";
 get_myaddress(addr)
 	struct sockaddr_in *addr;
 {
-	int s;
-	char buf[BUFSIZ];
-	struct ifconf ifc;
-	struct ifreq ifreq, *ifr;
-	int len;
-
-	if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-	    perror("get_myaddress: socket");
-	    exit(1);
-	}
-	ifc.ifc_len = sizeof (buf);
-	ifc.ifc_buf = buf;
-	if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) {
-		perror("get_myaddress: ioctl (get interface configuration)");
-		exit(1);
-	}
-	ifr = ifc.ifc_req;
-	for (len = ifc.ifc_len; len; len -= sizeof ifreq) {
-		ifreq = *ifr;
-		if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
-			perror("get_myaddress: ioctl");
-			exit(1);
-		}
-		if ((ifreq.ifr_flags & IFF_UP) &&
-		    ifr->ifr_addr.sa_family == AF_INET) {
-			*addr = *((struct sockaddr_in *)&ifr->ifr_addr);
-			addr->sin_port = htons(PMAPPORT);
-			if (0 != addr->sin_addr.s_addr) {
-				break;
-			}
-		}
-		ifr++;
-	}
-	(void) close(s);
+	addr->sin_family = AF_INET;
+	addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+	addr->sin_port = htons(PMAPPORT);
 }

Attachment: use_loopback.sh
Description: Bourne shell script


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]