]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Conserve sockets: Reuse RPC transports.
authorchip <chip>
Mon, 13 Mar 2000 22:23:26 +0000 (22:23 +0000)
committerchip <chip>
Mon, 13 Mar 2000 22:23:26 +0000 (22:23 +0000)
ChangeLog
support/nfs/rpcmisc.c

index 0daf977e8d3fc4b5186d6e8fe7278388b7c05076..753a0731a9af2cf30b342147bb39b6c8fca23c91 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-2000-03-13 H.J. Lu <hjl@lucon.org>
+2000-03-12  Chip Salzenberg  <chip@valinux.com>
+           Neil Brown  <neilb@cse.unsw.edu.au>
+
+       * support/nfs/rpcmisc.c (rpc_init): Share transports.
+
+Wed Mar  8 09:42:43 EST 2000 Neil Brown <neilb@cse.unsw.edu.au>
 
        * etc/redhat/nfsd.init: Updated.
 
index 7b182fd51ab7ab1f6147ae451b87c801eb960de7..b994fb1361fd19e25e4296446ee128e2feccaaf2 100644 (file)
@@ -65,35 +65,53 @@ rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport,
        }
 
        if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_DGRAM)) {
-               if (_rpcfdtype == 0 && defport != 0 &&
-                   ((sock = makesock(defport, IPPROTO_UDP, bufsiz)) < 0)) {
-                       xlog(L_FATAL, "%s: could not make a UDP socket\n",
-                                       name);
+               static SVCXPRT *last_transp = NULL;
+               if (_rpcfdtype == 0 && defport != 0) {
+                       if (last_transp && last_transp->xp_port == defport) {
+                               transp = last_transp;
+                               goto udp_transport;
+                       }
+                       if ((sock = makesock(defport, IPPROTO_UDP, bufsiz)) < 0) {
+                               xlog(L_FATAL, "%s: cannot make a UDP socket\n",
+                                               name);
+                       }
                }
                transp = svcudp_create(sock);
                if (transp == NULL) {
                        xlog(L_FATAL, "cannot create udp service.");
                }
+      udp_transport:
                if (!svc_register(transp, prog, vers, dispatch, IPPROTO_UDP)) {
                        xlog(L_FATAL, "unable to register (%s, %d, udp).",
                                        name, vers);
                }
+               last_transp = transp;
        }
 
        if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_STREAM)) {
-               if (_rpcfdtype == 0 && defport != 0 &&
-                   ((sock = makesock(defport, IPPROTO_TCP, bufsiz)) < 0)) {
-                       xlog(L_FATAL, "%s: could not make a TCP socket\n",
-                                       name);
+               static SVCXPRT *last_transp = NULL;
+
+               if (_rpcfdtype == 0 && defport != 0) {
+                       if (last_transp && last_transp->xp_port == defport) {
+                               transp = last_transp;
+                               goto tcp_transport;
+                       }
+                       if ((sock = makesock(defport, IPPROTO_TCP, bufsiz)) < 0) {
+                               xlog(L_FATAL, "%s: cannot make a TCP socket\n",
+                                               name);
+                       }
                }
                transp = svctcp_create(sock, 0, 0);
                if (transp == NULL) {
                        xlog(L_FATAL, "cannot create tcp service.");
                }
+      tcp_transport:
                if (!svc_register(transp, prog, vers, dispatch, IPPROTO_TCP)) {
                        xlog(L_FATAL, "unable to register (%s, %d, tcp).",
                                        name, vers);
                }
+               last_transp = transp;
        }
 
        if (_rpcpmstart) {