Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Apr 2017 02:24:22 +0000 (UTC)
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316951 - head/usr.sbin/syslogd
Message-ID:  <201704150224.v3F2OMQq070092@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sobomax
Date: Sat Apr 15 02:24:22 2017
New Revision: 316951
URL: https://svnweb.freebsd.org/changeset/base/316951

Log:
  Since shutdown(2) on datagram socket is no longer a NOP after rev 316874
  don't bother to select/recv on that socket. This prevents syslogd(8)
  from spinning endlessly when started with the -s option (default).
  
  Reported by:	peter

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==============================================================================
--- head/usr.sbin/syslogd/syslogd.c	Sat Apr 15 01:52:49 2017	(r316950)
+++ head/usr.sbin/syslogd/syslogd.c	Sat Apr 15 02:24:22 2017	(r316951)
@@ -702,7 +702,7 @@ main(int argc, char *argv[])
 		    sizeof(fd_mask));
 
 		STAILQ_FOREACH(sl, &shead, next) {
-			if (sl->sl_socket != -1)
+			if (sl->sl_socket != -1 && sl->sl_recv != NULL)
 				FD_SET(sl->sl_socket, fdsr);
 		}
 		i = select(fdsrmax + 1, fdsr, NULL, NULL,
@@ -2877,6 +2877,7 @@ socksetup(struct peer *pe)
 	struct addrinfo hints, *res, *res0;
 	int error;
 	char *cp;
+	int (*sl_recv)(struct socklist *);
 	/*
 	 * We have to handle this case for backwards compatibility:
 	 * If there are two (or more) colons but no '[' and ']',
@@ -3003,6 +3004,7 @@ socksetup(struct peer *pe)
 		}
 		dprintf("new socket fd is %d\n", s);
 		listen(s, 5);
+		sl_recv = socklist_recv_sock;
 		dprintf("shutdown\n");
 		if (SecureMode || res->ai_family == AF_LOCAL) {
 			/* Forbid communication in secure mode. */
@@ -3013,13 +3015,14 @@ socksetup(struct peer *pe)
 					die(0);
 			}
 			dprintf("listening on socket\n");
+			sl_recv = NULL;
 		} else
 			dprintf("sending on socket\n");
 		addsock(res->ai_addr, res->ai_addrlen,
 		    &(struct socklist){
 			.sl_socket = s,
 			.sl_peer = pe,
-			.sl_recv = socklist_recv_sock
+			.sl_recv = sl_recv
 		});
 	}
 	freeaddrinfo(res0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704150224.v3F2OMQq070092>