mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
1845. [bug] Improve error reporting to distingish between
accept()/fcntl() and socket()/fcntl() errors. [RT #13745]
This commit is contained in:
@@ -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(¤t_task,
|
||||
ISC_EVENT_PTR(&dev));
|
||||
ISC_EVENT_PTR(&dev));
|
||||
}
|
||||
|
||||
dev = next;
|
||||
|
Reference in New Issue
Block a user