summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>2000-09-27 19:03:05 +0000
committerwollman <wollman@FreeBSD.org>2000-09-27 19:03:05 +0000
commitb8ec81dfe325e924fdaa1828ea2722c6f4293ee2 (patch)
tree32d8e63eb36ee82ade085bd76a63b36a1ab123ab /usr.sbin/lpr
parent7413cf0b7c22e575eed40b5227340c14ad266e57 (diff)
downloadFreeBSD-src-b8ec81dfe325e924fdaa1828ea2722c6f4293ee2.zip
FreeBSD-src-b8ec81dfe325e924fdaa1828ea2722c6f4293ee2.tar.gz
Set SO_REUSEADDR so that lpd can start while old lpd connections are still
winding down (or timing out). Also, be slightly more informative in mcleanup() about why lpd is exiting. PR: 21595
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r--usr.sbin/lpr/lpd/lpd.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index 76846a7..367161c 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -285,6 +285,12 @@ main(argc, argv)
if (pflag == 0) {
finet = socket(AF_INET, SOCK_STREAM, 0);
if (finet >= 0) {
+ i = 1;
+ if (setsockopt(finet, SOL_SOCKET, SO_REUSEADDR, &i,
+ sizeof i) < 0) {
+ syslog(LOG_ERR, "setsockopt(SO_REUSEADDR): %m");
+ mcleanup(0);
+ }
if (options & SO_DEBUG &&
setsockopt(finet, SOL_SOCKET, SO_DEBUG, 0, 0) < 0) {
syslog(LOG_ERR, "setsockopt (SO_DEBUG): %m");
@@ -377,8 +383,15 @@ static void
mcleanup(signo)
int signo;
{
- if (lflag)
- syslog(LOG_INFO, "exiting");
+ /*
+ * XXX syslog(3) is not signal-safe.
+ */
+ if (lflag) {
+ if (signo)
+ syslog(LOG_INFO, "exiting on signal %d", signo);
+ else
+ syslog(LOG_INFO, "exiting");
+ }
unlink(_PATH_SOCKETNAME);
exit(0);
}
OpenPOWER on IntegriCloud