]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1845. [bug] Improve error reporting to distingish between
authorMark Andrews <marka@isc.org>
Thu, 19 May 2005 02:42:42 +0000 (02:42 +0000)
committerMark Andrews <marka@isc.org>
Thu, 19 May 2005 02:42:42 +0000 (02:42 +0000)
                        accept()/fcntl() and socket()/fcntl() errors.
                        [RT #13745]

CHANGES
doc/private/branches
lib/isc/unix/socket.c

diff --git a/CHANGES b/CHANGES
index fd74ff49d9d0e65a2689330e7e1402933be6b3ac..886a5901021220a96edf2752c505542a24990967 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -39,7 +39,9 @@
 1846.  [contrib]       query-loc-0.3.0 from Stephane Bortzmeyer
                        <bortzmeyer@nic.fr>.
 
-1845.  [placeholder]   rt13745
+1845.  [bug]           Improve error reporting to distingish between
+                       accept()/fcntl() and socket()/fcntl() errors.
+                       [RT #13745]
 
 1844.  [bug]           inet_pton() accepted more that 4 hexadecimal digits
                        for each 16 bit piece of the IPv6 address.  The text
index fc6b1e150785da14395f3739cb53bc41ae431c40..139b0c909199708dd01f8459adad87199984ae66 100644 (file)
@@ -34,7 +34,7 @@ rt13662                               new
 rt13694                                new     
 rt13707                                new     
 rt13714                                new     
-rt13745                                new     
+rt13745                                closed  
 rt13753                                new     
 rt13754                                new     
 rt13771                                new     
index 265150277026327a900ac65c722137c8f9bd19b2..e8bee8c046cd13919d907fa1fcee469fe0058e10 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.249 2005/04/27 04:57:23 sra Exp $ */
+/* $Id: socket.c,v 1.250 2005/05/19 02:42:42 marka Exp $ */
 
 /*! \file */
 
@@ -369,7 +369,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__,
@@ -1358,6 +1358,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);
@@ -1380,23 +1381,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");
@@ -1426,7 +1428,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,
@@ -1778,6 +1780,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);
 
@@ -1831,17 +1834,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) {
@@ -1870,7 +1874,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,
@@ -2211,7 +2215,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",
@@ -3447,7 +3451,7 @@ 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);
+                       ERROR_MATCH(ECONNRESET, ISC_R_CONNECTIONRESET);
 #undef ERROR_MATCH
                default:
                        dev->result = ISC_R_UNEXPECTED;
@@ -3618,7 +3622,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;