Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Use a non-blocking SVC for TCP connections.



details:   https://anonhg.NetBSD.org/src/rev/b23937b53ae9
branches:  trunk
changeset: 539099:b23937b53ae9
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Fri Nov 08 00:14:50 2002 +0000

description:
Use a non-blocking SVC for TCP connections.

diffstat:

 dist/am-utils/conf/transp/transp_sockets.c |  10 +++++++++-
 usr.sbin/mountd/mountd.c                   |  13 +++++++++----
 usr.sbin/rpc.lockd/lockd.c                 |  10 +++++++---
 usr.sbin/rpc.statd/statd.c                 |   7 +++++--
 usr.sbin/rpc.yppasswdd/rpc.yppasswdd.c     |   9 ++++++---
 usr.sbin/rpcbind/rpcb_svc_com.c            |   8 ++++++--
 usr.sbin/rpcbind/rpcbind.c                 |  11 ++++++++---
 7 files changed, 50 insertions(+), 18 deletions(-)

diffs (297 lines):

diff -r c4468879b0f6 -r b23937b53ae9 dist/am-utils/conf/transp/transp_sockets.c
--- a/dist/am-utils/conf/transp/transp_sockets.c        Fri Nov 08 00:13:51 2002 +0000
+++ b/dist/am-utils/conf/transp/transp_sockets.c        Fri Nov 08 00:14:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: transp_sockets.c,v 1.1.1.4 2001/05/13 17:50:23 veego Exp $     */
+/*     $NetBSD: transp_sockets.c,v 1.2 2002/11/08 00:14:50 fvdl Exp $  */
 
 /*
  * Copyright (c) 1997-2001 Erez Zadok
@@ -52,6 +52,9 @@
 #include <am_defs.h>
 #include <amu.h>
 
+#ifndef RPC_MAXDATASIZE
+#define RPC_MAXDATASIZE 9000
+#endif
 
 /*
  * find the IP address that can be used to connect to the local host
@@ -217,6 +220,8 @@
 int
 create_amq_service(int *udp_soAMQp, SVCXPRT **udp_amqpp, int *tcp_soAMQp, SVCXPRT **tcp_amqpp)
 {
+  int maxrec = RPC_MAXDATASIZE;
+
   /* first create TCP service */
   if (tcp_soAMQp) {
     *tcp_soAMQp = socket(AF_INET, SOCK_STREAM, 0);
@@ -231,6 +236,9 @@
       plog(XLOG_FATAL, "cannot create tcp service for amq: soAMQp=%d", *tcp_soAMQp);
       return 2;
     }
+#ifdef SVCSET_CONNMAXREC
+    SVC_CONTROL(*tcp_amqpp, SVCSET_CONNMAXREC, &maxrec);
+#endif
   }
 
   /* next create UDP service */
diff -r c4468879b0f6 -r b23937b53ae9 usr.sbin/mountd/mountd.c
--- a/usr.sbin/mountd/mountd.c  Fri Nov 08 00:13:51 2002 +0000
+++ b/usr.sbin/mountd/mountd.c  Fri Nov 08 00:14:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mountd.c,v 1.80 2002/09/21 20:35:00 christos Exp $      */
+/*     $NetBSD: mountd.c,v 1.81 2002/11/08 00:15:46 fvdl Exp $  */
 
 /*
  * Copyright (c) 1989, 1993
@@ -51,7 +51,7 @@
 #if 0
 static char     sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.80 2002/09/21 20:35:00 christos Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.81 2002/11/08 00:15:46 fvdl Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -296,6 +296,7 @@
        int udpsock, tcpsock, udp6sock, tcp6sock;
        int xcreated = 0, s;
        int c, one = 1;
+       int maxrec = RPC_MAXDATASIZE;
 #ifdef IPSEC
        char *policy = NULL;
 #define ADDOPTS "P:"
@@ -389,6 +390,8 @@
        udp6conf = getnetconfigent("udp6");
        tcp6conf = getnetconfigent("tcp6");
 
+       rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
+
        if (udpsock != -1 && udpconf != NULL) {
                bindresvport(udpsock, NULL);
 #ifdef IPSEC
@@ -416,7 +419,8 @@
                        ipsecsetup(AF_INET, tcpsock, policy);
 #endif
                listen(tcpsock, SOMAXCONN);
-               tcptransp = svc_vc_create(tcpsock, 0, 0);
+               tcptransp = svc_vc_create(tcpsock, RPC_MAXDATASIZE,
+                   RPC_MAXDATASIZE);
                if (tcptransp != NULL) {
                        if (!svc_reg(tcptransp, RPCPROG_MNT, RPCMNT_VER1,
                                mntsrv, tcpconf) ||
@@ -457,7 +461,8 @@
                        ipsecsetup(AF_INET6, tcpsock, policy);
 #endif
                listen(tcp6sock, SOMAXCONN);
-               tcp6transp = svc_vc_create(tcp6sock, 0, 0);
+               tcp6transp = svc_vc_create(tcp6sock, RPC_MAXDATASIZE,
+                   RPC_MAXDATASIZE);
                if (tcp6transp != NULL) {
                        if (!svc_reg(tcp6transp, RPCPROG_MNT, RPCMNT_VER1,
                                mntsrv, tcp6conf) ||
diff -r c4468879b0f6 -r b23937b53ae9 usr.sbin/rpc.lockd/lockd.c
--- a/usr.sbin/rpc.lockd/lockd.c        Fri Nov 08 00:13:51 2002 +0000
+++ b/usr.sbin/rpc.lockd/lockd.c        Fri Nov 08 00:14:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lockd.c,v 1.7 2000/08/12 18:08:44 thorpej Exp $        */
+/*     $NetBSD: lockd.c,v 1.8 2002/11/08 00:16:39 fvdl Exp $   */
 
 /*
  * Copyright (c) 1995
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lockd.c,v 1.7 2000/08/12 18:08:44 thorpej Exp $");
+__RCSID("$NetBSD: lockd.c,v 1.8 2002/11/08 00:16:39 fvdl Exp $");
 #endif
 
 /*
@@ -91,6 +91,7 @@
        struct sigaction sigchild, sigalarm;
        int grace_period = 30;
        struct netconfig *nconf;
+       int maxrec = RPC_MAXDATASIZE;
 
        while ((ch = getopt(argc, argv, "d:g:")) != (-1)) {
                switch (ch) {
@@ -131,12 +132,15 @@
                maxindex = 4;
        }
 
+       rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
+
        for (i = 0; i < maxindex; i++) {
                nconf = getnetconfigent(transports[i]);
                if (nconf == NULL)
                        errx(1, "cannot get udp netconf.");
 
-               transp = svc_tli_create(RPC_ANYFD, nconf, NULL, 0, 0);
+               transp = svc_tli_create(RPC_ANYFD, nconf, NULL, RPC_MAXDATASIZE,
+                   RPC_MAXDATASIZE);
                if (transp == NULL) {
                        errx(1, "cannot create %s service.", transports[i]);
                        /* NOTREACHED */
diff -r c4468879b0f6 -r b23937b53ae9 usr.sbin/rpc.statd/statd.c
--- a/usr.sbin/rpc.statd/statd.c        Fri Nov 08 00:13:51 2002 +0000
+++ b/usr.sbin/rpc.statd/statd.c        Fri Nov 08 00:14:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: statd.c,v 1.20 2001/11/23 17:10:29 christos Exp $      */
+/*     $NetBSD: statd.c,v 1.21 2002/11/08 00:16:39 fvdl Exp $  */
 
 /*
  * Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: statd.c,v 1.20 2001/11/23 17:10:29 christos Exp $");
+__RCSID("$NetBSD: statd.c,v 1.21 2002/11/08 00:16:39 fvdl Exp $");
 #endif
 
 /* main() function for status monitor daemon.  Some of the code in this        */
@@ -99,6 +99,7 @@
 {
        int ch;
        struct sigaction nsa;
+       int maxrec = RPC_MAXDATASIZE;
 
        sigemptyset(&nsa.sa_mask);
        nsa.sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT;
@@ -120,6 +121,8 @@
        }
        (void)rpcb_unset(SM_PROG, SM_VERS, NULL);
 
+       rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
+
        if (!svc_create(sm_prog_1, SM_PROG, SM_VERS, "udp")) {
                errx(1, "cannot create udp service.");
                /* NOTREACHED */
diff -r c4468879b0f6 -r b23937b53ae9 usr.sbin/rpc.yppasswdd/rpc.yppasswdd.c
--- a/usr.sbin/rpc.yppasswdd/rpc.yppasswdd.c    Fri Nov 08 00:13:51 2002 +0000
+++ b/usr.sbin/rpc.yppasswdd/rpc.yppasswdd.c    Fri Nov 08 00:14:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpc.yppasswdd.c,v 1.10 2002/01/25 20:30:41 wennmach Exp $      */
+/*     $NetBSD: rpc.yppasswdd.c,v 1.11 2002/11/08 00:16:39 fvdl Exp $  */
 
 /*
  * Copyright (c) 1994 Mats O Jansson <moj%stacken.kth.se@localhost>
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: rpc.yppasswdd.c,v 1.10 2002/01/25 20:30:41 wennmach Exp $");
+__RCSID("$NetBSD: rpc.yppasswdd.c,v 1.11 2002/11/08 00:16:39 fvdl Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -68,6 +68,7 @@
        SVCXPRT *transp;
        int i;
        char *arg;
+       int maxrec = RPC_MAXDATASIZE;
 
        for (i = 1; i < argc; i++) {
                arg = argv[i];
@@ -110,6 +111,8 @@
                err(EXIT_FAILURE, "can't detach");
        pidfile(NULL);
 
+       rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
+
        (void)pmap_unset(YPPASSWDPROG, YPPASSWDVERS);
 
        transp = svcudp_create(RPC_ANYSOCK);
@@ -121,7 +124,7 @@
                errx(EXIT_FAILURE,
                    "unable to register YPPASSWDPROG/YPPASSWDVERS/UDP");
 
-       transp = svctcp_create(RPC_ANYSOCK, 0, 0);
+       transp = svctcp_create(RPC_ANYSOCK, RPC_MAXDATASIZE, RPC_MAXDATASIZE);
        if (transp == NULL)
                errx(EXIT_FAILURE, "cannot create TCP service");
 
diff -r c4468879b0f6 -r b23937b53ae9 usr.sbin/rpcbind/rpcb_svc_com.c
--- a/usr.sbin/rpcbind/rpcb_svc_com.c   Fri Nov 08 00:13:51 2002 +0000
+++ b/usr.sbin/rpcbind/rpcb_svc_com.c   Fri Nov 08 00:14:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpcb_svc_com.c,v 1.8 2002/09/23 12:48:08 mycroft Exp $ */
+/*     $NetBSD: rpcb_svc_com.c,v 1.9 2002/11/08 00:16:39 fvdl Exp $    */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -1065,6 +1065,7 @@
 
 
 #define        MASKVAL (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)
+extern bool_t __svc_clean_idle(fd_set *, int, bool_t);
 
 void
 my_svc_run()
@@ -1077,6 +1078,7 @@
        int i;
 #endif
        register struct pollfd  *p;
+       fd_set cleanfds;
 
        for (;;) {
                p = pollfds;
@@ -1098,7 +1100,7 @@
                        fprintf(stderr, ">\n");
                }
 #endif
-               switch (poll_ret = poll(pollfds, nfds, INFTIM)) {
+               switch (poll_ret = poll(pollfds, nfds, 30 * 1000)) {
                case -1:
                        /*
                         * We ignore all errors, continuing with the assumption
@@ -1106,6 +1108,8 @@
                         * other outside event) and not caused by poll().
                         */
                case 0:
+                       cleanfds = svc_fdset;
+                       __svc_clean_idle(&cleanfds, 30, FALSE);
                        continue;
                default:
 #ifdef SVC_RUN_DEBUG
diff -r c4468879b0f6 -r b23937b53ae9 usr.sbin/rpcbind/rpcbind.c
--- a/usr.sbin/rpcbind/rpcbind.c        Fri Nov 08 00:13:51 2002 +0000
+++ b/usr.sbin/rpcbind/rpcbind.c        Fri Nov 08 00:14:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpcbind.c,v 1.2 2001/01/11 02:45:31 lukem Exp $        */
+/*     $NetBSD: rpcbind.c,v 1.3 2002/11/08 00:16:40 fvdl Exp $ */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -114,6 +114,7 @@
        struct netconfig *nconf;
        void *nc_handle;        /* Net config handle */
        struct rlimit rl;
+       int maxrec = RPC_MAXDATASIZE;
 
        parseargs(argc, argv);
 
@@ -145,6 +146,9 @@
                syslog(LOG_ERR, "%s: can't find local transport\n", argv[0]);
                exit(1);
        }
+
+       rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
+
        init_transport(nconf);
 
        while ((nconf = getnetconfig(nc_handle))) {
@@ -316,8 +320,9 @@
 
        if (nconf->nc_semantics != NC_TPI_CLTS)
                listen(fd, SOMAXCONN);
-
-       my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr, 0, 0);
+               
+       my_xprt = (SVCXPRT *)svc_tli_create(fd, nconf, &taddr, RPC_MAXDATASIZE,
+           RPC_MAXDATASIZE);
        if (my_xprt == (SVCXPRT *)NULL) {
                syslog(LOG_ERR, "%s: could not create service",
                                nconf->nc_netid);



Home | Main Index | Thread Index | Old Index