Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/rpc Don't try to use listen(2) on a UDP socket whic...
details: https://anonhg.NetBSD.org/src/rev/6ba4e17805a4
branches: trunk
changeset: 341604:6ba4e17805a4
user: tron <tron%NetBSD.org@localhost>
date: Fri Nov 13 11:23:08 2015 +0000
description:
Don't try to use listen(2) on a UDP socket which will always fail.
Previously this was not a problem because the return value of listen(2)
was ignored. With this fix amd(8) no longer fails to start with the
error message "cannot create rpc/udp service".
TL;DR: Make amd(8) work again
diffstat:
lib/libc/rpc/rpc_soc.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diffs (34 lines):
diff -r 4c6f789db0eb -r 6ba4e17805a4 lib/libc/rpc/rpc_soc.c
--- a/lib/libc/rpc/rpc_soc.c Fri Nov 13 10:43:32 2015 +0000
+++ b/lib/libc/rpc/rpc_soc.c Fri Nov 13 11:23:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_soc.c,v 1.21 2015/11/10 20:56:20 christos Exp $ */
+/* $NetBSD: rpc_soc.c,v 1.22 2015/11/13 11:23:08 tron Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@@ -45,7 +45,7 @@
#if 0
static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
#else
-__RCSID("$NetBSD: rpc_soc.c,v 1.21 2015/11/10 20:56:20 christos Exp $");
+__RCSID("$NetBSD: rpc_soc.c,v 1.22 2015/11/13 11:23:08 tron Exp $");
#endif
#endif
@@ -255,8 +255,13 @@
memset(&sccsin, 0, sizeof sccsin);
sccsin.sin_family = AF_INET;
(void)bindresvport(fd, &sccsin);
- if (listen(fd, SOMAXCONN) == -1)
- goto out;
+ if (strcmp(netid, "udp") != 0 && listen(fd, SOMAXCONN) == -1) {
+ (void) syslog(LOG_ERR,
+ "svc%s_create: listen(2) failed: %s",
+ netid, strerror(errno));
+ (void) freenetconfigent(nconf);
+ goto out;
+ }
svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize);
(void) freenetconfigent(nconf);
if (svc == NULL)
Home |
Main Index |
Thread Index |
Old Index