Commit d73541ea authored by Mark Andrews's avatar Mark Andrews
Browse files

1845. [bug] Improve error reporting to distingish between

                        accept()/fcntl() and socket()/fcntl() errors.
                        [RT #13745]
parent 092f7679
......@@ -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
......
......@@ -34,7 +34,7 @@ rt13662 new
rt13694 new
rt13707 new
rt13714 new
rt13745 new
rt13745 closed
rt13753 new
rt13754 new
rt13771 new
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment