From 9a3ee1570d04c3385028dce09fbc36c8f4c14554 Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Tue, 6 Feb 2001 23:43:01 +0000 Subject: [PATCH] "hard" errors in accept() were handled really badly. They were logged twice, and the socket object for the new socket was never destroyed, causing the server to hang on exit (if multithreaded) or dump core on exit (if singlethreaded). Now the only difference between "hard" and "soft" errors is that the latter are not logged. --- lib/isc/unix/socket.c | 45 +++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 471dc36f27..115e3c53f4 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.188 2001/02/06 23:04:02 gson Exp $ */ +/* $Id: socket.c,v 1.189 2001/02/06 23:43:01 gson Exp $ */ #include @@ -1671,33 +1671,19 @@ internal_accept(isc_task_t *me, isc_event_t *ev) { fd = accept(sock->fd, &dev->newsocket->address.type.sa, (void *)&addrlen); if (fd < 0) { - if (SOFT_ERROR(errno)) { - select_poke(sock->manager, sock->fd, - SELECT_POKE_ACCEPT); - UNLOCK(&sock->lock); - return; + if (! SOFT_ERROR(errno)) { + UNEXPECTED_ERROR(__FILE__, __LINE__, + "internal_accept: accept() %s: %s", + isc_msgcat_get(isc_msgcat, + ISC_MSGSET_GENERAL, + ISC_MSG_FAILED, + "failed"), + strerror(errno)); } - - /* - * If some other error, ignore it as well and hope - * for the best, but log it. - */ - if (isc_log_wouldlog(isc_lctx, TRACE_LEVEL)) - socket_log(sock, NULL, TRACE, isc_msgcat, - ISC_MSGSET_SOCKET, - ISC_MSG_ACCEPTRETURNED, - "accept() returned %d/%s", - errno, strerror(errno)); - - fd = -1; - - UNEXPECTED_ERROR(__FILE__, __LINE__, - "internal_accept: accept() %s: %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), - strerror(errno)); - - result = ISC_R_UNEXPECTED; + select_poke(sock->manager, sock->fd, + SELECT_POKE_ACCEPT); + UNLOCK(&sock->lock); + return; } else { if (dev->newsocket->address.type.sa.sa_family != sock->pf) { UNEXPECTED_ERROR(__FILE__, __LINE__, @@ -1713,10 +1699,11 @@ internal_accept(isc_task_t *me, isc_event_t *ev) { UNLOCK(&sock->lock); return; } - dev->newsocket->address.length = addrlen; - dev->newsocket->pf = sock->pf; } + dev->newsocket->address.length = addrlen; + dev->newsocket->pf = sock->pf; + /* * Pull off the done event. */