Make the argument handling for select() less bogus. Also, move the

amq service from UDP to TCP for better reliability.
This commit is contained in:
Joerg Wunsch 1997-03-22 23:12:08 +00:00
parent 5ea8e149f2
commit 3f5323eb71
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=24124
2 changed files with 22 additions and 22 deletions

View File

@ -37,7 +37,7 @@
*
* @(#)nfs_start.c 8.1 (Berkeley) 6/6/93
*
* $Id$
* $Id: nfs_start.c,v 1.4 1997/02/22 16:01:38 peter Exp $
*
*/
@ -64,10 +64,13 @@ unsigned short nfs_port;
SVCXPRT *nfsxprt;
extern int fwd_sock;
int max_fds = -1;
#define MASKED_SIGS (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGCHLD)|sigmask(SIGHUP))
#ifndef FD_SET
#define FD_SETSIZE 32 /* XXX kludge. bind does it this way */
#endif
#ifdef DEBUG
/*
* Check that we are not burning resources
@ -173,7 +176,7 @@ static int rpc_pending_now()
#endif /* FD_SET */
tvv.tv_sec = tvv.tv_usec = 0;
nsel = select(max_fds+1, &readfds, (int *) 0, (int *) 0, &tvv);
nsel = select(FD_SETSIZE, &readfds, (int *) 0, (int *) 0, &tvv);
if (nsel < 1)
return(0);
#ifdef FD_SET
@ -188,7 +191,6 @@ static int rpc_pending_now()
static serv_state run_rpc(P_void)
{
int dtbsz = max_fds + 1;
int smask = sigblock(MASKED_SIGS);
next_softclock = clocktime();
@ -251,7 +253,7 @@ static serv_state run_rpc(P_void)
dlog("Select waits for Godot");
#endif /* DEBUG */
nsel = do_select(smask, dtbsz, &readfds, &tvv);
nsel = do_select(smask, FD_SETSIZE, &readfds, &tvv);
switch (nsel) {
@ -337,6 +339,7 @@ int mount_automounter(ppid)
int ppid;
{
int so = socket(AF_INET, SOCK_DGRAM, 0);
int so2 = socket(AF_INET, SOCK_STREAM, 0);
SVCXPRT *amqp;
int nmount;
@ -345,11 +348,18 @@ int ppid;
return 1;
}
if ((nfsxprt = svcudp_create(so)) == NULL ||
(amqp = svcudp_create(so)) == NULL) {
if (so2 < 0 || bind_resv_port(so2, NULL) < 0) {
perror("Can't create privileged port");
return 1;
}
if ((nfsxprt = svcudp_create(so)) == NULL) {
plog(XLOG_FATAL, "cannot create rpc/udp service");
return 2;
}
if ((amqp = svctcp_create(so2, 0, 0)) == NULL) {
plog(XLOG_FATAL, "cannot create rpc/tcp service");
return 2;
}
if (!svc_register(nfsxprt, NFS_PROGRAM, NFS_VERSION, nfs_program_2, 0)) {
plog(XLOG_FATAL, "unable to register (NFS_PROGRAM, NFS_VERSION, 0)");
@ -362,16 +372,6 @@ int ppid;
if (fwd_init() != 0)
return 3;
/*
* One or other of so, fwd_sock
* must be the highest fd on
* which to select.
*/
if (so > max_fds)
max_fds = so;
if (fwd_sock > max_fds)
max_fds = fwd_sock;
/*
* Construct the root automount node
*/
@ -410,8 +410,8 @@ int ppid;
*/
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)");
if (!svc_register(amqp, AMQ_PROGRAM, AMQ_VERSION, amq_program_1, IPPROTO_TCP)) {
plog(XLOG_FATAL, "unable to register (AMQ_PROGRAM, AMQ_VERSION, tcp)");
return 3;
}
#ifdef DEBUG

View File

@ -37,7 +37,7 @@
*
* @(#)amq.c 8.1 (Berkeley) 6/7/93
*
* $Id$
* $Id: amq.c,v 1.4 1997/02/22 16:02:07 peter Exp $
*
*/
@ -54,7 +54,7 @@ char copyright[] = "\
#endif /* not lint */
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: amq.c,v 1.4 1997/02/22 16:02:07 peter Exp $";
static char sccsid[] = "@(#)amq.c 8.1 (Berkeley) 6/7/93";
#endif /* not lint */
@ -409,7 +409,7 @@ Usage: %s [-h host] [[-f] [-m] [-v] [-s]] | [[-u] directory ...]] |\n\
/*
* Create RPC endpoint
*/
s = privsock(SOCK_STREAM);
s = RPC_ANYSOCK;
clnt = clnttcp_create(&server_addr, AMQ_PROGRAM, AMQ_VERSION, &s, 0, 0);
if (clnt == 0) {
close(s);