summaryrefslogtreecommitdiff
path: root/usr.sbin/bind/lib/isc
diff options
context:
space:
mode:
authorJakob Schlyter <jakob@cvs.openbsd.org>2006-04-05 17:36:37 +0000
committerJakob Schlyter <jakob@cvs.openbsd.org>2006-04-05 17:36:37 +0000
commit0505bad000912a66c4f92c91a72202b9250e4bd5 (patch)
tree00d8701ac1f3ee5feadd765c0274e9ff0a95aeac /usr.sbin/bind/lib/isc
parent1da54ca1fd7764e567cd4bc055abd54d602773e1 (diff)
resolve conflicts
Diffstat (limited to 'usr.sbin/bind/lib/isc')
-rw-r--r--usr.sbin/bind/lib/isc/api6
-rw-r--r--usr.sbin/bind/lib/isc/include/isc/Makefile.in8
-rw-r--r--usr.sbin/bind/lib/isc/inet_pton.c19
-rw-r--r--usr.sbin/bind/lib/isc/lfsr.c8
-rw-r--r--usr.sbin/bind/lib/isc/mem.c31
-rw-r--r--usr.sbin/bind/lib/isc/rwlock.c18
-rw-r--r--usr.sbin/bind/lib/isc/unix/entropy.c21
-rw-r--r--usr.sbin/bind/lib/isc/unix/ifiter_ioctl.c16
-rw-r--r--usr.sbin/bind/lib/isc/unix/socket.c105
9 files changed, 138 insertions, 94 deletions
diff --git a/usr.sbin/bind/lib/isc/api b/usr.sbin/bind/lib/isc/api
index 63704dd62ad..ddeff334f03 100644
--- a/usr.sbin/bind/lib/isc/api
+++ b/usr.sbin/bind/lib/isc/api
@@ -1,3 +1,3 @@
-LIBINTERFACE = 10
-LIBREVISION = 5
-LIBAGE = 1
+LIBINTERFACE = 11
+LIBREVISION = 1
+LIBAGE = 0
diff --git a/usr.sbin/bind/lib/isc/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/include/isc/Makefile.in
index 92ddfcd51e7..b3e0ed58f70 100644
--- a/usr.sbin/bind/lib/isc/include/isc/Makefile.in
+++ b/usr.sbin/bind/lib/isc/include/isc/Makefile.in
@@ -1,4 +1,4 @@
-# Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 1998-2001, 2003 Internet Software Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
@@ -13,7 +13,7 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
-# $ISC: Makefile.in,v 1.50.12.4 2004/03/06 08:14:38 marka Exp $
+# $ISC: Makefile.in,v 1.50.12.6 2005/03/22 02:32:07 marka Exp $
srcdir = @srcdir@
VPATH = @srcdir@
@@ -28,8 +28,8 @@ top_srcdir = @top_srcdir@
#
HEADERS = app.h assertions.h base64.h bitstring.h boolean.h buffer.h \
bufferlist.h commandline.h entropy.h error.h event.h \
- eventclass.h \
- file.h formatcheck.h fsaccess.h heap.h hex.h hmacmd5.h \
+ eventclass.h file.h formatcheck.h fsaccess.h \
+ hash.h heap.h hex.h hmacmd5.h \
interfaceiter.h @ISC_IPV6_H@ lang.h lcg.h lex.h \
lfsr.h lib.h list.h log.h magic.h md5.h mem.h msgcat.h msgs.h \
mutexblock.h netaddr.h ondestroy.h os.h parseint.h \
diff --git a/usr.sbin/bind/lib/isc/inet_pton.c b/usr.sbin/bind/lib/isc/inet_pton.c
index fb1793ea1f5..75b8c4161bc 100644
--- a/usr.sbin/bind/lib/isc/inet_pton.c
+++ b/usr.sbin/bind/lib/isc/inet_pton.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1996-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -17,7 +17,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] =
- "$ISC: inet_pton.c,v 1.10.2.4.2.1 2004/03/06 08:14:31 marka Exp $";
+ "$ISC: inet_pton.c,v 1.10.2.4.2.3 2005/03/31 23:56:14 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <config.h>
@@ -132,7 +132,7 @@ inet_pton6(const char *src, unsigned char *dst) {
xdigits_u[] = "0123456789ABCDEF";
unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
const char *xdigits, *curtok;
- int ch, saw_xdigit;
+ int ch, seen_xdigits;
unsigned int val;
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
@@ -143,7 +143,7 @@ inet_pton6(const char *src, unsigned char *dst) {
if (*++src != ':')
return (0);
curtok = src;
- saw_xdigit = 0;
+ seen_xdigits = 0;
val = 0;
while ((ch = *src++) != '\0') {
const char *pch;
@@ -153,14 +153,13 @@ inet_pton6(const char *src, unsigned char *dst) {
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
- if (val > 0xffff)
+ if (++seen_xdigits > 4)
return (0);
- saw_xdigit = 1;
continue;
}
if (ch == ':') {
curtok = src;
- if (!saw_xdigit) {
+ if (!seen_xdigits) {
if (colonp)
return (0);
colonp = tp;
@@ -170,19 +169,19 @@ inet_pton6(const char *src, unsigned char *dst) {
return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
- saw_xdigit = 0;
+ seen_xdigits = 0;
val = 0;
continue;
}
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
inet_pton4(curtok, tp) > 0) {
tp += NS_INADDRSZ;
- saw_xdigit = 0;
+ seen_xdigits = 0;
break; /* '\0' was seen by inet_pton4(). */
}
return (0);
}
- if (saw_xdigit) {
+ if (seen_xdigits) {
if (tp + NS_INT16SZ > endp)
return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
diff --git a/usr.sbin/bind/lib/isc/lfsr.c b/usr.sbin/bind/lib/isc/lfsr.c
index 0874cb1bb2f..c317744b3a1 100644
--- a/usr.sbin/bind/lib/isc/lfsr.c
+++ b/usr.sbin/bind/lib/isc/lfsr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2002 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -15,10 +15,11 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $ISC: lfsr.c,v 1.11.2.2.2.3 2004/03/08 09:04:49 marka Exp $ */
+/* $ISC: lfsr.c,v 1.11.2.2.2.6 2005/10/14 01:38:50 marka Exp $ */
#include <config.h>
+#include <stddef.h>
#include <stdlib.h>
#include <isc/assertions.h>
@@ -55,9 +56,6 @@ isc_lfsr_init(isc_lfsr_t *lfsr, isc_uint32_t state, unsigned int bits,
static inline isc_uint32_t
lfsr_generate(isc_lfsr_t *lfsr)
{
- unsigned int highbit;
-
- highbit = 1 << (lfsr->bits - 1);
/*
* If the previous state is zero, we must fill it with something
diff --git a/usr.sbin/bind/lib/isc/mem.c b/usr.sbin/bind/lib/isc/mem.c
index 3e6612d07ee..4a5ea4b33df 100644
--- a/usr.sbin/bind/lib/isc/mem.c
+++ b/usr.sbin/bind/lib/isc/mem.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1997-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $ISC: mem.c,v 1.98.2.7.2.5 2004/03/16 05:50:24 marka Exp $ */
+/* $ISC: mem.c,v 1.98.2.7.2.7 2005/03/17 03:58:32 marka Exp $ */
#include <config.h>
@@ -717,6 +717,15 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
if (ctx == NULL)
return (ISC_R_NOMEMORY);
+ if (isc_mutex_init(&ctx->lock) != ISC_R_SUCCESS) {
+ UNEXPECTED_ERROR(__FILE__, __LINE__,
+ "isc_mutex_init() %s",
+ isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
+ ISC_MSG_FAILED, "failed"));
+ (memfree)(arg, ctx);
+ return (ISC_R_UNEXPECTED);
+ }
+
if (init_max_size == 0U)
ctx->max_size = DEF_MAX_SIZE;
else
@@ -775,15 +784,6 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
ctx->highest = NULL;
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
- if (isc_mutex_init(&ctx->lock) != ISC_R_SUCCESS) {
- UNEXPECTED_ERROR(__FILE__, __LINE__,
- "isc_mutex_init() %s",
- isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
- ISC_MSG_FAILED, "failed"));
- result = ISC_R_UNEXPECTED;
- goto error;
- }
-
#if ISC_MEM_TRACKLINES
if ((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0) {
unsigned int i;
@@ -805,17 +805,18 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
return (ISC_R_SUCCESS);
error:
- if (ctx) {
- if (ctx->stats)
+ if (ctx != NULL) {
+ if (ctx->stats != NULL)
(memfree)(arg, ctx->stats);
#if ISC_MEM_USE_INTERNAL_MALLOC
- if (ctx->freelists)
+ if (ctx->freelists != NULL)
(memfree)(arg, ctx->freelists);
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
#if ISC_MEM_TRACKLINES
- if (ctx->debuglist)
+ if (ctx->debuglist != NULL)
(ctx->memfree)(ctx->arg, ctx->debuglist);
#endif /* ISC_MEM_TRACKLINES */
+ DESTROYLOCK(&ctx->lock);
(memfree)(arg, ctx);
}
diff --git a/usr.sbin/bind/lib/isc/rwlock.c b/usr.sbin/bind/lib/isc/rwlock.c
index b8c590039d1..8cec462b9d4 100644
--- a/usr.sbin/bind/lib/isc/rwlock.c
+++ b/usr.sbin/bind/lib/isc/rwlock.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $ISC: rwlock.c,v 1.33.2.4.2.1 2004/03/06 08:14:35 marka Exp $ */
+/* $ISC: rwlock.c,v 1.33.2.4.2.3 2005/03/17 03:58:32 marka Exp $ */
#include <config.h>
@@ -109,7 +109,9 @@ isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
ISC_MSG_FAILED, "failed"),
isc_result_totext(result));
- return (ISC_R_UNEXPECTED);
+ result = ISC_R_UNEXPECTED;
+ goto destroy_lock;
+
}
result = isc_condition_init(&rwl->writeable);
if (result != ISC_R_SUCCESS) {
@@ -118,12 +120,20 @@ isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
ISC_MSG_FAILED, "failed"),
isc_result_totext(result));
- return (ISC_R_UNEXPECTED);
+ result = ISC_R_UNEXPECTED;
+ goto destroy_rcond;
}
rwl->magic = RWLOCK_MAGIC;
return (ISC_R_SUCCESS);
+
+ destroy_rcond:
+ (void)isc_condition_destroy(&rwl->readable);
+ destroy_lock:
+ DESTROYLOCK(&rwl->lock);
+
+ return (result);
}
static isc_result_t
diff --git a/usr.sbin/bind/lib/isc/unix/entropy.c b/usr.sbin/bind/lib/isc/unix/entropy.c
index 257b43be7bc..399887599e5 100644
--- a/usr.sbin/bind/lib/isc/unix/entropy.c
+++ b/usr.sbin/bind/lib/isc/unix/entropy.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $ISC: entropy.c,v 1.60.2.3.8.9 2004/03/16 05:02:31 marka Exp $ */
+/* $ISC: entropy.c,v 1.60.2.3.8.11 2005/07/12 05:47:43 marka Exp $ */
/*
* This is the system depenedent part of the ISC entropy API.
@@ -446,16 +446,25 @@ make_nonblock(int fd) {
int ret;
int flags;
char strbuf[ISC_STRERRORSIZE];
+#ifdef USE_FIONBIO_IOCTL
+ int on = 1;
+ ret = ioctl(fd, FIONBIO, (char *)&on);
+#else
flags = fcntl(fd, F_GETFL, 0);
- flags |= O_NONBLOCK;
+ flags |= PORT_NONBLOCK;
ret = fcntl(fd, F_SETFL, flags);
+#endif
if (ret == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
- "fcntl(%d, F_SETFL, %d): %s",
- fd, flags, strbuf);
+#ifdef USE_FIONBIO_IOCTL
+ "ioctl(%d, FIONBIO, &on): %s", fd,
+#else
+ "fcntl(%d, F_SETFL, %d): %s", fd, flags,
+#endif
+ strbuf);
return (ISC_R_UNEXPECTED);
}
@@ -501,7 +510,7 @@ isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) {
if (is_usocket)
fd = socket(PF_UNIX, SOCK_STREAM, 0);
else
- fd = open(fname, O_RDONLY | O_NONBLOCK, 0);
+ fd = open(fname, O_RDONLY | PORT_NONBLOCK, 0);
if (fd < 0) {
ret = isc__errno2result(errno);
diff --git a/usr.sbin/bind/lib/isc/unix/ifiter_ioctl.c b/usr.sbin/bind/lib/isc/unix/ifiter_ioctl.c
index 65c090b78b2..8c418fb42df 100644
--- a/usr.sbin/bind/lib/isc/unix/ifiter_ioctl.c
+++ b/usr.sbin/bind/lib/isc/unix/ifiter_ioctl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $ISC: ifiter_ioctl.c,v 1.19.2.5.2.15 2004/11/10 22:22:49 marka Exp $ */
+/* $ISC: ifiter_ioctl.c,v 1.19.2.5.2.17 2005/10/14 02:13:07 marka Exp $ */
/*
* Obtain the list of network interfaces using the SIOCGLIFCONF ioctl.
@@ -896,7 +896,9 @@ internal_current(isc_interfaceiter_t *iter) {
*/
static isc_result_t
internal_next4(isc_interfaceiter_t *iter) {
+#ifdef ISC_PLATFORM_HAVESALEN
struct ifreq *ifrp;
+#endif
REQUIRE (iter->pos < (unsigned int) iter->ifc.ifc_len);
@@ -906,14 +908,14 @@ internal_next4(isc_interfaceiter_t *iter) {
if (!iter->first)
return (ISC_R_SUCCESS);
#endif
+#ifdef ISC_PLATFORM_HAVESALEN
ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos);
-#ifdef ISC_PLATFORM_HAVESALEN
if (ifrp->ifr_addr.sa_len > sizeof(struct sockaddr))
iter->pos += sizeof(ifrp->ifr_name) + ifrp->ifr_addr.sa_len;
else
#endif
- iter->pos += sizeof(*ifrp);
+ iter->pos += sizeof(struct ifreq);
if (iter->pos >= (unsigned int) iter->ifc.ifc_len)
return (ISC_R_NOMORE);
@@ -924,21 +926,23 @@ internal_next4(isc_interfaceiter_t *iter) {
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
static isc_result_t
internal_next6(isc_interfaceiter_t *iter) {
+#ifdef ISC_PLATFORM_HAVESALEN
struct LIFREQ *ifrp;
+#endif
if (iter->result6 != ISC_R_SUCCESS && iter->result6 != ISC_R_IGNORE)
return (iter->result6);
REQUIRE(iter->pos6 < (unsigned int) iter->lifc.lifc_len);
+#ifdef ISC_PLATFORM_HAVESALEN
ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6);
-#ifdef ISC_PLATFORM_HAVESALEN
if (ifrp->lifr_addr.sa_len > sizeof(struct sockaddr))
iter->pos6 += sizeof(ifrp->lifr_name) + ifrp->lifr_addr.sa_len;
else
#endif
- iter->pos6 += sizeof(*ifrp);
+ iter->pos6 += sizeof(struct LIFREQ);
if (iter->pos6 >= (unsigned int) iter->lifc.lifc_len)
return (ISC_R_NOMORE);
diff --git a/usr.sbin/bind/lib/isc/unix/socket.c b/usr.sbin/bind/lib/isc/unix/socket.c
index 16eac939e62..c2a7468c663 100644
--- a/usr.sbin/bind/lib/isc/unix/socket.c
+++ b/usr.sbin/bind/lib/isc/unix/socket.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $ISC: socket.c,v 1.207.2.19.2.15 2004/11/18 21:31:16 marka Exp $ */
+/* $ISC: socket.c,v 1.207.2.19.2.22 2005/11/03 23:08:42 marka Exp $ */
#include <config.h>
@@ -283,7 +283,7 @@ socket_log(isc_socket_t *sock, isc_sockaddr_t *address,
const char *fmt, ...)
{
char msgbuf[2048];
- char peerbuf[256];
+ char peerbuf[ISC_SOCKADDR_FORMATSIZE];
va_list ap;
if (! isc_log_wouldlog(isc_lctx, level))
@@ -366,7 +366,7 @@ select_poke(isc_socketmgr_t *mgr, int fd, int msg) {
}
#endif
} while (cc < 0 && SOFT_ERROR(errno));
-
+
if (cc < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
FATAL_ERROR(__FILE__, __LINE__,
@@ -392,6 +392,7 @@ select_readmsg(isc_socketmgr_t *mgr, int *fd, int *msg) {
cc = read(mgr->pipe_fds[0], buf, sizeof(buf));
if (cc < 0) {
*msg = SELECT_POKE_NOTHING;
+ *fd = -1; /* Silence compiler. */
if (SOFT_ERROR(errno))
return;
@@ -432,16 +433,25 @@ make_nonblock(int fd) {
int ret;
int flags;
char strbuf[ISC_STRERRORSIZE];
+#ifdef USE_FIONBIO_IOCTL
+ int on = 1;
+ ret = ioctl(fd, FIONBIO, (char *)&on);
+#else
flags = fcntl(fd, F_GETFL, 0);
- flags |= O_NONBLOCK;
+ flags |= PORT_NONBLOCK;
ret = fcntl(fd, F_SETFL, flags);
+#endif
if (ret == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
- "fcntl(%d, F_SETFL, %d): %s",
- fd, flags, strbuf);
+#ifdef USE_FIONBIO_IOCTL
+ "ioctl(%d, FIONBIO, &on): %s", fd,
+#else
+ "fcntl(%d, F_SETFL, %d): %s", fd, flags,
+#endif
+ strbuf);
return (ISC_R_UNEXPECTED);
}
@@ -464,7 +474,11 @@ cmsg_len(ISC_SOCKADDR_LEN_T len) {
#else
ISC_SOCKADDR_LEN_T hdrlen;
- hdrlen = (ISC_SOCKADDR_LEN_T)CMSG_DATA(NULL); /* XXX */
+ /*
+ * Cast NULL so that any pointer arithmetic performed by CMSG_DATA
+ * is correct.
+ */
+ hdrlen = (ISC_SOCKADDR_LEN_T)CMSG_DATA(((struct cmsghdr *)NULL));
return (hdrlen + len);
#endif
}
@@ -1225,7 +1239,7 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
cmsgbuflen += cmsg_space(sizeof(struct timeval));
#endif
sock->recvcmsgbuflen = cmsgbuflen;
- if (sock->recvcmsgbuflen != 0) {
+ if (sock->recvcmsgbuflen != 0U) {
sock->recvcmsgbuf = isc_mem_get(manager->mctx, cmsgbuflen);
if (sock->recvcmsgbuf == NULL)
goto error;
@@ -1236,7 +1250,7 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
cmsgbuflen = cmsg_space(sizeof(struct in6_pktinfo));
#endif
sock->sendcmsgbuflen = cmsgbuflen;
- if (sock->sendcmsgbuflen != 0) {
+ if (sock->sendcmsgbuflen != 0U) {
sock->sendcmsgbuf = isc_mem_get(manager->mctx, cmsgbuflen);
if (sock->sendcmsgbuf == NULL)
goto error;
@@ -1351,6 +1365,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
int on = 1;
#endif
char strbuf[ISC_STRERRORSIZE];
+ const char *err = "socket";
REQUIRE(VALID_MANAGER(manager));
REQUIRE(socketp != NULL && *socketp == NULL);
@@ -1370,23 +1385,24 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
}
#ifdef F_DUPFD
- /*
- * Leave a space for stdio to work in.
- */
- if (sock->fd >= 0 && sock->fd < 20) {
- int new, tmp;
- new = fcntl(sock->fd, F_DUPFD, 20);
- tmp = errno;
- (void)close(sock->fd);
- errno = tmp;
- sock->fd = new;
- }
+ /*
+ * Leave a space for stdio to work in.
+ */
+ if (sock->fd >= 0 && sock->fd < 20) {
+ int new, tmp;
+ new = fcntl(sock->fd, F_DUPFD, 20);
+ tmp = errno;
+ (void)close(sock->fd);
+ errno = tmp;
+ sock->fd = new;
+ err = "isc_socket_create: fcntl";
+ }
#endif
if (sock->fd >= (int)FD_SETSIZE) {
(void)close(sock->fd);
isc_log_iwrite(isc_lctx, ISC_LOGCATEGORY_GENERAL,
- ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
+ ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
isc_msgcat, ISC_MSGSET_SOCKET,
ISC_MSG_TOOMANYFDS,
"%s: too many open file descriptors", "socket");
@@ -1416,7 +1432,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
default:
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
- "socket() %s: %s",
+ "%s() %s: %s", err,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_GENERAL,
ISC_MSG_FAILED,
@@ -1467,7 +1483,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
#endif /* SO_TIMESTAMP */
#if defined(ISC_PLATFORM_HAVEIPV6)
- if (pf == AF_INET6 && sock->recvcmsgbuflen == 0) {
+ if (pf == AF_INET6 && sock->recvcmsgbuflen == 0U) {
/*
* Warn explicitly because this anomaly can be hidden
* in usual operation (and unexpectedly appear later).
@@ -1767,6 +1783,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
int fd;
isc_result_t result = ISC_R_SUCCESS;
char strbuf[ISC_STRERRORSIZE];
+ const char *err = "accept";
UNUSED(me);
@@ -1820,17 +1837,18 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
(void *)&addrlen);
#ifdef F_DUPFD
- /*
- * Leave a space for stdio to work in.
- */
- if (fd >= 0 && fd < 20) {
- int new, tmp;
- new = fcntl(fd, F_DUPFD, 20);
- tmp = errno;
- (void)close(fd);
- errno = tmp;
- fd = new;
- }
+ /*
+ * Leave a space for stdio to work in.
+ */
+ if (fd >= 0 && fd < 20) {
+ int new, tmp;
+ new = fcntl(fd, F_DUPFD, 20);
+ tmp = errno;
+ (void)close(fd);
+ errno = tmp;
+ fd = new;
+ err = "fcntl";
+ }
#endif
if (fd < 0) {
@@ -1859,7 +1877,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
}
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
- "internal_accept: accept() %s: %s",
+ "internal_accept: %s() %s: %s", err,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_GENERAL,
ISC_MSG_FAILED,
@@ -1868,7 +1886,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
fd = -1;
result = ISC_R_UNEXPECTED;
} else {
- if (addrlen == 0) {
+ if (addrlen == 0U) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"internal_accept(): "
"accept() failed to return "
@@ -2200,7 +2218,7 @@ watcher(void *uap) {
cc = select(maxfd, &readfds, &writefds, NULL, NULL);
if (cc < 0) {
if (!SOFT_ERROR(errno)) {
- isc__strerror(errno, strbuf,
+ isc__strerror(errno, strbuf,
sizeof(strbuf));
FATAL_ERROR(__FILE__, __LINE__,
"select() %s: %s",
@@ -3105,6 +3123,7 @@ isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr,
ERROR_MATCH(ENOBUFS, ISC_R_NORESOURCES);
ERROR_MATCH(EPERM, ISC_R_HOSTUNREACH);
ERROR_MATCH(EPIPE, ISC_R_NOTCONNECTED);
+ ERROR_MATCH(ECONNRESET, ISC_R_CONNECTIONRESET);
#undef ERROR_MATCH
}
@@ -3174,6 +3193,7 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
int cc;
ISC_SOCKADDR_LEN_T optlen;
char strbuf[ISC_STRERRORSIZE];
+ char peerbuf[ISC_SOCKADDR_FORMATSIZE];
UNUSED(me);
INSIST(ev->ev_type == ISC_SOCKEVENT_INTW);
@@ -3250,13 +3270,16 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
ERROR_MATCH(EPERM, ISC_R_HOSTUNREACH);
ERROR_MATCH(EPIPE, ISC_R_NOTCONNECTED);
ERROR_MATCH(ETIMEDOUT, ISC_R_TIMEDOUT);
+ ERROR_MATCH(ECONNRESET, ISC_R_CONNECTIONRESET);
#undef ERROR_MATCH
default:
dev->result = ISC_R_UNEXPECTED;
+ isc_sockaddr_format(&sock->address, peerbuf,
+ sizeof(peerbuf));
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
- "internal_connect: connect() %s",
- strbuf);
+ "internal_connect: connect(%s) %s",
+ peerbuf, strbuf);
}
} else {
dev->result = ISC_R_SUCCESS;
@@ -3418,7 +3441,7 @@ isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) {
dev->result = ISC_R_CANCELED;
dev->ev_sender = sock;
isc_task_sendanddetach(&current_task,
- ISC_EVENT_PTR(&dev));
+ ISC_EVENT_PTR(&dev));
}
dev = next;