rpc.sprayd: Bring some changes from NetBSD.
Most notable, other than some style issues: CVS 1.11: do not use LOG_CONS. CVS 1.13: consistently use exit instead of return in main(). use LOG_WARNING instead of LOG_ERR for non critical errors. Obtained from: NetBSD MFC after: 2 weeks
This commit is contained in:
parent
d7629e6644
commit
bec1dbb67b
@ -1,3 +1,4 @@
|
|||||||
|
.\" $NetBSD: rpc.sprayd.8,v 1.9 2003/02/25 10:34:50 wiz Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1994 Christos Zoulas
|
.\" Copyright (c) 1994 Christos Zoulas
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
@ -29,11 +30,12 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd June 22, 1994
|
.Dd December 27, 2017
|
||||||
.Dt RPC.SPRAYD 8
|
.Dt RPC.SPRAYD 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm rpc.sprayd
|
.Nm rpc.sprayd ,
|
||||||
|
.Nm sprayd
|
||||||
.Nd spray server
|
.Nd spray server
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm /usr/libexec/rpc.sprayd
|
.Nm /usr/libexec/rpc.sprayd
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* $NetBSD: sprayd.c,v 1.14 2006/05/09 20:18:07 mrg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-4-Clause
|
* SPDX-License-Identifier: BSD-4-Clause
|
||||||
*
|
*
|
||||||
@ -64,7 +66,7 @@ static int from_inetd = 1;
|
|||||||
void
|
void
|
||||||
cleanup(int sig __unused)
|
cleanup(int sig __unused)
|
||||||
{
|
{
|
||||||
(void) rpcb_unset(SPRAYPROG, SPRAYVERS, NULL);
|
(void)rpcb_unset(SPRAYPROG, SPRAYVERS, NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,17 +95,17 @@ main(int argc, char *argv[])
|
|||||||
if (!from_inetd) {
|
if (!from_inetd) {
|
||||||
daemon(0, 0);
|
daemon(0, 0);
|
||||||
|
|
||||||
(void) rpcb_unset(SPRAYPROG, SPRAYVERS, NULL);
|
(void)rpcb_unset(SPRAYPROG, SPRAYVERS, NULL);
|
||||||
|
|
||||||
(void) signal(SIGINT, cleanup);
|
(void)signal(SIGINT, cleanup);
|
||||||
(void) signal(SIGTERM, cleanup);
|
(void)signal(SIGTERM, cleanup);
|
||||||
(void) signal(SIGHUP, cleanup);
|
(void)signal(SIGHUP, cleanup);
|
||||||
} else {
|
} else {
|
||||||
(void) signal(SIGALRM, die);
|
(void)signal(SIGALRM, die);
|
||||||
alarm(TIMEOUT);
|
alarm(TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
openlog("rpc.sprayd", LOG_CONS|LOG_PID, LOG_DAEMON);
|
openlog("rpc.sprayd", LOG_PID, LOG_DAEMON);
|
||||||
|
|
||||||
if (from_inetd) {
|
if (from_inetd) {
|
||||||
transp = svc_tli_create(0, NULL, NULL, 0, 0);
|
transp = svc_tli_create(0, NULL, NULL, 0, 0);
|
||||||
@ -120,7 +122,7 @@ main(int argc, char *argv[])
|
|||||||
syslog(LOG_ERR,
|
syslog(LOG_ERR,
|
||||||
"unable to register (SPRAYPROG, SPRAYVERS, %s)",
|
"unable to register (SPRAYPROG, SPRAYVERS, %s)",
|
||||||
(!from_inetd)?"udp":"(inetd)");
|
(!from_inetd)?"udp":"(inetd)");
|
||||||
return 1;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
svc_run();
|
svc_run();
|
||||||
@ -138,7 +140,7 @@ spray_service(struct svc_req *rqstp, SVCXPRT *transp)
|
|||||||
switch (rqstp->rq_proc) {
|
switch (rqstp->rq_proc) {
|
||||||
case SPRAYPROC_CLEAR:
|
case SPRAYPROC_CLEAR:
|
||||||
scum.counter = 0;
|
scum.counter = 0;
|
||||||
(void) gettimeofday(&clear, 0);
|
(void)gettimeofday(&clear, 0);
|
||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
|
|
||||||
case NULLPROC:
|
case NULLPROC:
|
||||||
@ -150,7 +152,7 @@ spray_service(struct svc_req *rqstp, SVCXPRT *transp)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case SPRAYPROC_GET:
|
case SPRAYPROC_GET:
|
||||||
(void) gettimeofday(&get, 0);
|
(void)gettimeofday(&get, 0);
|
||||||
timersub(&get, &clear, &get);
|
timersub(&get, &clear, &get);
|
||||||
scum.clock.sec = get.tv_sec;
|
scum.clock.sec = get.tv_sec;
|
||||||
scum.clock.usec = get.tv_usec;
|
scum.clock.usec = get.tv_usec;
|
||||||
@ -163,6 +165,6 @@ spray_service(struct svc_req *rqstp, SVCXPRT *transp)
|
|||||||
|
|
||||||
if (!svc_sendreply(transp, (xdrproc_t)xdr_spraycumul, &scum)) {
|
if (!svc_sendreply(transp, (xdrproc_t)xdr_spraycumul, &scum)) {
|
||||||
svcerr_systemerr(transp);
|
svcerr_systemerr(transp);
|
||||||
syslog(LOG_ERR, "bad svc_sendreply");
|
syslog(LOG_WARNING, "bad svc_sendreply");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user