X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/1c15e88899094343f75aeba04122cd96a96b428e..af359dea2e5ab3e937b62107ecd6a51d78189ed7:/usr/src/usr.sbin/amd/amd/nfs_start.c diff --git a/usr/src/usr.sbin/amd/amd/nfs_start.c b/usr/src/usr.sbin/amd/amd/nfs_start.c index 1f447b73ad..f91066fc78 100644 --- a/usr/src/usr.sbin/amd/amd/nfs_start.c +++ b/usr/src/usr.sbin/amd/amd/nfs_start.c @@ -1,6 +1,4 @@ /* - * $Id: nfs_start.c,v 5.2 90/06/23 22:19:48 jsp Rel $ - * * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -9,21 +7,38 @@ * This code is derived from software contributed to Berkeley by * Jan-Simon Pendry at Imperial College, London. * - * Redistribution and use in source and binary forms are permitted provided - * that: (1) source distributions retain this entire copyright notice and - * comment, and (2) distributions including binaries display the following - * acknowledgement: ``This product includes software developed by the - * University of California, Berkeley and its contributors'' in the - * documentation or other materials provided with the distribution and in - * all advertising materials mentioning features or use of this software. - * Neither the name of the University nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)nfs_start.c 5.3 (Berkeley) 5/12/91 + * + * $Id: nfs_start.c,v 5.2.1.3 91/05/07 22:18:21 jsp Alpha $ * - * @(#)nfs_start.c 5.1 (Berkeley) 6/29/90 */ #include "am.h" @@ -140,6 +155,37 @@ struct timeval *tvp; return nsel; } +/* + * Determine whether anything is left in + * the RPC input queue. + */ +static int rpc_pending_now() +{ + struct timeval tvv; + int nsel; +#ifdef FD_SET + fd_set readfds; + + FD_ZERO(&readfds); + FD_SET(fwd_sock, &readfds); +#else + int readfds = (1 << fwd_sock); +#endif /* FD_SET */ + + tvv.tv_sec = tvv.tv_usec = 0; + nsel = select(max_fds+1, &readfds, (int *) 0, (int *) 0, &tvv); + if (nsel < 1) + return(0); +#ifdef FD_SET + if (FD_ISSET(fwd_sock, &readfds)) + return(1); +#else + if (readfds & (1 << fwd_sock)) + return(1); +#endif + return(0); +} + static serv_state run_rpc(P_void) { int dtbsz = max_fds + 1; @@ -226,19 +272,21 @@ static serv_state run_rpc(P_void) break; default: + /* Read all pending NFS responses at once to avoid + having responses queue up as a consequence of + retransmissions. */ #ifdef FD_SET if (FD_ISSET(fwd_sock, &readfds)) { FD_CLR(fwd_sock, &readfds); - fwd_reply(); - --nsel; - } #else if (readfds & (1 << fwd_sock)) { readfds &= ~(1 << fwd_sock); - fwd_reply(); - --nsel; +#endif + --nsel; + do { + fwd_reply(); + } while (rpc_pending_now() > 0); } -#endif /* FD_SET */ if (nsel) { /* @@ -292,8 +340,6 @@ int ppid; SVCXPRT *amqp; int nmount; - unregister_amq(); - if (so < 0 || bindnfs_port(so) < 0) { perror("Can't create privileged nfs port"); return 1; @@ -310,14 +356,6 @@ int ppid; return 3; } -#ifdef DEBUG - Debug(D_AMQ) -#endif /* DEBUG */ - if (!svc_register(amqp, AMQ_PROGRAM, AMQ_VERSION, amq_program_1, IPPROTO_UDP)) { - plog(XLOG_FATAL, "unable to register (AMQ_PROGRAM, AMQ_VERSION, udp)"); - return 3; - } - /* * Start RPC forwarding */ @@ -364,6 +402,22 @@ int ppid; return 0; } +#ifdef DEBUG + Debug(D_AMQ) { +#endif /* DEBUG */ + /* + * Register with amq + */ + unregister_amq(); + + if (!svc_register(amqp, AMQ_PROGRAM, AMQ_VERSION, amq_program_1, IPPROTO_UDP)) { + plog(XLOG_FATAL, "unable to register (AMQ_PROGRAM, AMQ_VERSION, udp)"); + return 3; + } +#ifdef DEBUG + } +#endif /* DEBUG */ + /* * Start timeout_mp rolling */