]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - support/nfs/rpcmisc.c
2000-11-09 H.J. Lu <hjl@lucon.org>
[nfs-utils.git] / support / nfs / rpcmisc.c
index 527070b352a82c655b324f9081ed441211ddd2cd..4bb4ec8ce2963b12f4d1e1d6f62cf87fd7539b49 100644 (file)
@@ -50,9 +50,9 @@ rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport,
 
        asize = sizeof(saddr);
        sock = 0;
-       _rpcfdtype = 0;
        if (getsockname(0, (struct sockaddr *) &saddr, &asize) == 0) {
                int ssize = sizeof (int);
+               _rpcfdtype = 0;
                if (saddr.sin_family != AF_INET)
                        xlog(L_FATAL, "init: stdin is bound to non-inet addr");
                if (getsockopt(0, SOL_SOCKET, SO_TYPE,
@@ -68,7 +68,8 @@ rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport,
                static SVCXPRT *last_transp = NULL;
  
                if (_rpcfdtype == 0) {
-                       if (last_transp && last_transp->xp_port == defport) {
+                       if (last_transp
+                           && (!defport || defport == last_transp->xp_port)) {
                                transp = last_transp;
                                goto udp_transport;
                        }
@@ -93,7 +94,8 @@ rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport,
                static SVCXPRT *last_transp = NULL;
 
                if (_rpcfdtype == 0) {
-                       if (last_transp && last_transp->xp_port == defport) {
+                       if (last_transp
+                           && (!defport || defport == last_transp->xp_port)) {
                                transp = last_transp;
                                goto tcp_transport;
                        }