From ea30861fe56a9205ad36e733abf3303e2471d0a2 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 28 Jul 2011 11:42:41 +0000 Subject: [PATCH] turn isc_socket_dup into a method --- lib/isc/include/isc/socket.h | 4 +++- lib/isc/socket_api.c | 10 +++++++++- lib/isc/unix/socket.c | 15 ++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/isc/include/isc/socket.h b/lib/isc/include/isc/socket.h index 0307b8082d..8bf5e6b2b4 100644 --- a/lib/isc/include/isc/socket.h +++ b/lib/isc/include/isc/socket.h @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.h,v 1.95 2011/07/28 04:04:37 each Exp $ */ +/* $Id: socket.h,v 1.96 2011/07/28 11:42:41 marka Exp $ */ #ifndef ISC_SOCKET_H #define ISC_SOCKET_H 1 @@ -296,6 +296,8 @@ typedef struct isc_socketmethods { isc_sockettype_t (*gettype)(isc_socket_t *sock); void (*ipv6only)(isc_socket_t *sock, isc_boolean_t yes); isc_result_t (*fdwatchpoke)(isc_socket_t *sock, int flags); + isc_result_t (*dup)(isc_socket_t *socket, + isc_socket_t **socketp); } isc_socketmethods_t; /*% diff --git a/lib/isc/socket_api.c b/lib/isc/socket_api.c index 95075f5a65..a8fa86d444 100644 --- a/lib/isc/socket_api.c +++ b/lib/isc/socket_api.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket_api.c,v 1.5 2009/10/01 01:30:01 sar Exp $ */ +/* $Id: socket_api.c,v 1.6 2011/07/28 11:42:41 marka Exp $ */ #include @@ -214,3 +214,11 @@ isc_socket_fdwatchpoke(isc_socket_t *sock, int flags) return(sock->methods->fdwatchpoke(sock, flags)); } + +isc_result_t +isc_socket_dup(isc_socket_t *sock, isc_socket_t **socketp) { + REQUIRE(ISCAPI_SOCKET_VALID(sock)); + REQUIRE(socketp != NULL && *socketp == NULL); + + return(sock->methods->dup(sock, socketp)); +} diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index c35b4fd965..06522e1e2d 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.342 2011/07/28 04:27:26 marka Exp $ */ +/* $Id: socket.c,v 1.343 2011/07/28 11:42:41 marka Exp $ */ /*! \file */ @@ -551,6 +551,8 @@ isc__socket_fdwatchcreate(isc_socketmgr_t *manager, int fd, int flags, isc_task_t *task, isc_socket_t **socketp); ISC_SOCKETFUNC_SCOPE isc_result_t isc__socket_fdwatchpoke(isc_socket_t *sock, int flags); +ISC_SOCKETFUNC_SCOPE isc_result_t +isc__socket_dup(isc_socket_t *sock, isc_socket_t **socketp); static struct { isc_socketmethods_t methods; @@ -574,7 +576,8 @@ static struct { isc__socket_getsockname, isc__socket_gettype, isc__socket_ipv6only, - isc__socket_fdwatchpoke + isc__socket_fdwatchpoke, + isc__socket_dup } #ifndef BIND9 , @@ -769,6 +772,7 @@ FIX_IPV6_RECVPKTINFO(isc__socket_t *sock) if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, (void *)&on, sizeof(on)) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IPV6_RECVPKTINFO) " "%s: %s", sock->fd, @@ -2474,8 +2478,9 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, */ if (sock->pf == AF_INET6) { int action = IPV6_PMTUDISC_DONT; - (void)setsockopt(sock->fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, - &action, sizeof(action)); + (void)setsockopt(sock->fd, IPPROTO_IPV6, + IPV6_MTU_DISCOVER, &action, + sizeof(action)); } #endif #endif /* ISC_PLATFORM_HAVEIPV6 */ @@ -5714,7 +5719,7 @@ isc__socket_ipv6only(isc_socket_t *sock0, isc_boolean_t yes) { if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&onoff, sizeof(int)) < 0) { char strbuf[ISC_STRERRORSIZE]; - + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IPV6_V6ONLY) " "%s: %s", sock->fd,