diff options
author | Doug Barton <dougb@FreeBSD.org> | 2012-04-04 23:11:25 +0000 |
---|---|---|
committer | Doug Barton <dougb@FreeBSD.org> | 2012-04-04 23:11:25 +0000 |
commit | 42d3eba523963ab015ac451eeea0788b11631c94 (patch) | |
tree | d6eb268f26af23cc29cceb581dd5468a2cfef052 /lib/isc/unix/socket.c | |
parent | 3939884dc90db099f5601bd7c27d39acf7a8c731 (diff) | |
download | src-42d3eba523963ab015ac451eeea0788b11631c94.tar.gz src-42d3eba523963ab015ac451eeea0788b11631c94.zip |
Notes
Diffstat (limited to 'lib/isc/unix/socket.c')
-rw-r--r-- | lib/isc/unix/socket.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index c9aa454dd208..9d64a77ab37b 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.333.14.9 2011-07-29 02:19:20 marka Exp $ */ +/* $Id$ */ /*! \file */ @@ -1584,7 +1584,7 @@ allocate_socketevent(isc__socket_t *sock, isc_eventtype_t eventtype, if (ev == NULL) return (NULL); - ev->result = ISC_R_UNEXPECTED; + ev->result = ISC_R_UNSET; ISC_LINK_INIT(ev, ev_link); ISC_LIST_INIT(ev->bufferlist); ev->region.base = NULL; @@ -2037,8 +2037,6 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type, if (sock == NULL) return (ISC_R_NOMEMORY); - result = ISC_R_UNEXPECTED; - sock->common.magic = 0; sock->common.impmagic = 0; sock->references = 0; @@ -2066,8 +2064,10 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type, sock->recvcmsgbuflen = cmsgbuflen; if (sock->recvcmsgbuflen != 0U) { sock->recvcmsgbuf = isc_mem_get(manager->mctx, cmsgbuflen); - if (sock->recvcmsgbuf == NULL) + if (sock->recvcmsgbuf == NULL) { + result = ISC_R_NOMEMORY; goto error; + } } cmsgbuflen = 0; @@ -2084,8 +2084,10 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type, sock->sendcmsgbuflen = cmsgbuflen; if (sock->sendcmsgbuflen != 0U) { sock->sendcmsgbuf = isc_mem_get(manager->mctx, cmsgbuflen); - if (sock->sendcmsgbuf == NULL) + if (sock->sendcmsgbuf == NULL) { + result = ISC_R_NOMEMORY; goto error; + } } memset(sock->name, 0, sizeof(sock->name)); @@ -2223,6 +2225,7 @@ clear_bsdcompat(void) { static isc_result_t opensocket(isc__socketmgr_t *manager, isc__socket_t *sock) { + isc_result_t result; char strbuf[ISC_STRERRORSIZE]; const char *err = "socket"; int tries = 0; @@ -2327,9 +2330,10 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock) { } } - if (make_nonblock(sock->fd) != ISC_R_SUCCESS) { + result = make_nonblock(sock->fd); + if (result != ISC_R_SUCCESS) { (void)close(sock->fd); - return (ISC_R_UNEXPECTED); + return (result); } #ifdef SO_BSDCOMPAT @@ -3191,10 +3195,12 @@ internal_accept(isc_task_t *me, isc_event_t *ev) { UNLOCK(&sock->lock); - if (fd != -1 && (make_nonblock(fd) != ISC_R_SUCCESS)) { - (void)close(fd); - fd = -1; - result = ISC_R_UNEXPECTED; + if (fd != -1) { + result = make_nonblock(fd); + if (result != ISC_R_SUCCESS) { + (void)close(fd); + fd = -1; + } } /* @@ -3729,7 +3735,6 @@ static isc_threadresult_t watcher(void *uap) { isc__socketmgr_t *manager = uap; isc_boolean_t done; - int ctlfd; int cc; #ifdef USE_KQUEUE const char *fnname = "kevent()"; @@ -3741,16 +3746,19 @@ watcher(void *uap) { #elif defined (USE_SELECT) const char *fnname = "select()"; int maxfd; + int ctlfd; #endif char strbuf[ISC_STRERRORSIZE]; #ifdef ISC_SOCKET_USE_POLLWATCH pollstate_t pollstate = poll_idle; #endif +#if defined (USE_SELECT) /* * Get the control fd here. This will never change. */ ctlfd = manager->pipe_fds[0]; +#endif done = ISC_FALSE; while (!done) { do { @@ -4551,7 +4559,7 @@ isc__socket_recv2(isc_socket_t *sock0, isc_region_t *region, isc__socket_t *sock = (isc__socket_t *)sock0; event->ev_sender = sock; - event->result = ISC_R_UNEXPECTED; + event->result = ISC_R_UNSET; ISC_LIST_INIT(event->bufferlist); event->region = *region; event->n = 0; @@ -4765,7 +4773,7 @@ isc__socket_sendto2(isc_socket_t *sock0, isc_region_t *region, if ((flags & ISC_SOCKFLAG_NORETRY) != 0) REQUIRE(sock->type == isc_sockettype_udp); event->ev_sender = sock; - event->result = ISC_R_UNEXPECTED; + event->result = ISC_R_UNSET; ISC_LIST_INIT(event->bufferlist); event->region = *region; event->n = 0; |