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:
pfg 2017-12-28 17:44:30 +00:00
parent 606e1c2893
commit d5811653ed
2 changed files with 17 additions and 13 deletions

View File

@ -1,3 +1,4 @@
.\" $NetBSD: rpc.sprayd.8,v 1.9 2003/02/25 10:34:50 wiz Exp $
.\"
.\" Copyright (c) 1994 Christos Zoulas
.\" All rights reserved.
@ -29,11 +30,12 @@
.\"
.\" $FreeBSD$
.\"
.Dd June 22, 1994
.Dd December 27, 2017
.Dt RPC.SPRAYD 8
.Os
.Sh NAME
.Nm rpc.sprayd
.Nm rpc.sprayd ,
.Nm sprayd
.Nd spray server
.Sh SYNOPSIS
.Nm /usr/libexec/rpc.sprayd

View File

@ -1,3 +1,5 @@
/* $NetBSD: sprayd.c,v 1.14 2006/05/09 20:18:07 mrg Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
*
@ -64,7 +66,7 @@ static int from_inetd = 1;
void
cleanup(int sig __unused)
{
(void) rpcb_unset(SPRAYPROG, SPRAYVERS, NULL);
(void)rpcb_unset(SPRAYPROG, SPRAYVERS, NULL);
exit(0);
}
@ -93,17 +95,17 @@ main(int argc, char *argv[])
if (!from_inetd) {
daemon(0, 0);
(void) rpcb_unset(SPRAYPROG, SPRAYVERS, NULL);
(void)rpcb_unset(SPRAYPROG, SPRAYVERS, NULL);
(void) signal(SIGINT, cleanup);
(void) signal(SIGTERM, cleanup);
(void) signal(SIGHUP, cleanup);
(void)signal(SIGINT, cleanup);
(void)signal(SIGTERM, cleanup);
(void)signal(SIGHUP, cleanup);
} else {
(void) signal(SIGALRM, die);
(void)signal(SIGALRM, die);
alarm(TIMEOUT);
}
openlog("rpc.sprayd", LOG_CONS|LOG_PID, LOG_DAEMON);
openlog("rpc.sprayd", LOG_PID, LOG_DAEMON);
if (from_inetd) {
transp = svc_tli_create(0, NULL, NULL, 0, 0);
@ -120,7 +122,7 @@ main(int argc, char *argv[])
syslog(LOG_ERR,
"unable to register (SPRAYPROG, SPRAYVERS, %s)",
(!from_inetd)?"udp":"(inetd)");
return 1;
exit(1);
}
svc_run();
@ -138,7 +140,7 @@ spray_service(struct svc_req *rqstp, SVCXPRT *transp)
switch (rqstp->rq_proc) {
case SPRAYPROC_CLEAR:
scum.counter = 0;
(void) gettimeofday(&clear, 0);
(void)gettimeofday(&clear, 0);
/*FALLTHROUGH*/
case NULLPROC:
@ -150,7 +152,7 @@ spray_service(struct svc_req *rqstp, SVCXPRT *transp)
return;
case SPRAYPROC_GET:
(void) gettimeofday(&get, 0);
(void)gettimeofday(&get, 0);
timersub(&get, &clear, &get);
scum.clock.sec = get.tv_sec;
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)) {
svcerr_systemerr(transp);
syslog(LOG_ERR, "bad svc_sendreply");
syslog(LOG_WARNING, "bad svc_sendreply");
}
}