Sun Nov 8 01:12:46 2020 UTC ()
syslogd: in die(), don't call die() again recursively.

Particularly not for something as immaterial as close failing.

PR 55795


(dholland)
diff -r1.135 -r1.136 src/usr.sbin/syslogd/syslogd.c

cvs diff -r1.135 -r1.136 src/usr.sbin/syslogd/syslogd.c (expand / switch to unified diff)

--- src/usr.sbin/syslogd/syslogd.c 2020/11/07 17:46:56 1.135
+++ src/usr.sbin/syslogd/syslogd.c 2020/11/08 01:12:46 1.136
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: syslogd.c,v 1.135 2020/11/07 17:46:56 christos Exp $ */ 1/* $NetBSD: syslogd.c,v 1.136 2020/11/08 01:12:46 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1983, 1988, 1993, 1994 4 * Copyright (c) 1983, 1988, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993, 1994\ 34__COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993, 1994\
35 The Regents of the University of California. All rights reserved."); 35 The Regents of the University of California. All rights reserved.");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38#ifndef lint 38#ifndef lint
39#if 0 39#if 0
40static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94"; 40static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
41#else 41#else
42__RCSID("$NetBSD: syslogd.c,v 1.135 2020/11/07 17:46:56 christos Exp $"); 42__RCSID("$NetBSD: syslogd.c,v 1.136 2020/11/08 01:12:46 dholland Exp $");
43#endif 43#endif
44#endif /* not lint */ 44#endif /* not lint */
45 45
46/* 46/*
47 * syslogd -- log system messages 47 * syslogd -- log system messages
48 * 48 *
49 * This program implements a system log. It takes a series of lines. 49 * This program implements a system log. It takes a series of lines.
50 * Each line may have a priority, signified as "<n>" as 50 * Each line may have a priority, signified as "<n>" as
51 * the first characters of the line. If this is 51 * the first characters of the line. If this is
52 * not present, a default priority is used. 52 * not present, a default priority is used.
53 * 53 *
54 * To kill syslogd, send a signal 15 (terminate). A signal 1 (hup) will 54 * To kill syslogd, send a signal 15 (terminate). A signal 1 (hup) will
55 * cause it to reread its configuration file. 55 * cause it to reread its configuration file.
@@ -3002,30 +3002,27 @@ die(int fd, short event, void *ev) @@ -3002,30 +3002,27 @@ die(int fd, short event, void *ev)
3002 next = f->f_next; 3002 next = f->f_next;
3003 DELREF(f->f_prevmsg); 3003 DELREF(f->f_prevmsg);
3004 FREEPTR(f->f_program); 3004 FREEPTR(f->f_program);
3005 FREEPTR(f->f_host); 3005 FREEPTR(f->f_host);
3006 DEL_EVENT(f->f_sq_event); 3006 DEL_EVENT(f->f_sq_event);
3007 free((char *)f); 3007 free((char *)f);
3008 } 3008 }
3009 3009
3010 /* 3010 /*
3011 * Close all open UDP sockets 3011 * Close all open UDP sockets
3012 */ 3012 */
3013 if (finet) { 3013 if (finet) {
3014 for (i = 0; i < finet->fd; i++) { 3014 for (i = 0; i < finet->fd; i++) {
3015 if (close(finet[i+1].fd) < 0) { 3015 (void)close(finet[i+1].fd);
3016 logerror("close() failed"); 
3017 die(0, 0, NULL); 
3018 } 
3019 DEL_EVENT(finet[i+1].ev); 3016 DEL_EVENT(finet[i+1].ev);
3020 FREEPTR(finet[i+1].ev); 3017 FREEPTR(finet[i+1].ev);
3021 } 3018 }
3022 FREEPTR(finet); 3019 FREEPTR(finet);
3023 } 3020 }
3024 3021
3025 /* free config options */ 3022 /* free config options */
3026 for (j = 0; j < A_CNT(TypeInfo); j++) { 3023 for (j = 0; j < A_CNT(TypeInfo); j++) {
3027 FREEPTR(TypeInfo[j].queue_length_string); 3024 FREEPTR(TypeInfo[j].queue_length_string);
3028 FREEPTR(TypeInfo[j].queue_size_string); 3025 FREEPTR(TypeInfo[j].queue_size_string);
3029 } 3026 }
3030 3027
3031#ifndef DISABLE_TLS 3028#ifndef DISABLE_TLS