debugs(50, 3, "comm_openex: Attempt open socket for: " << addr );
new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol);
- int xerrno = errno;
+ const auto firstErrNo = errno;
/* under IPv6 there is the possibility IPv6 is present but disabled. */
/* try again as IPv4-native if possible */
AI->ai_protocol = proto;
debugs(50, 3, "Attempt fallback open socket for: " << addr );
new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol);
+ // TODO: Report failures of this second socket() call.
+ // if both socket() calls fail, we use firstErrNo
debugs(50, 2, "attempt open " << note << " socket on: " << addr);
}
* are failing because the open file table is full. This
* limits the number of simultaneous clients */
- if (limitError(errno)) {
- debugs(50, DBG_IMPORTANT, MYNAME << "socket failure: " << xstrerr(xerrno));
+ if (limitError(firstErrNo)) {
+ debugs(50, DBG_IMPORTANT, MYNAME << "socket failure: " << xstrerr(firstErrNo));
fdAdjustReserved();
} else {
- debugs(50, DBG_CRITICAL, MYNAME << "socket failure: " << xstrerr(xerrno));
+ debugs(50, DBG_CRITICAL, MYNAME << "socket failure: " << xstrerr(firstErrNo));
}
Ip::Address::FreeAddr(AI);
- errno = xerrno; // restore for caller
+ errno = firstErrNo; // restore for caller
return -1;
}
// XXX transition only. prevent conn from closing the new FD on function exit.
conn->fd = -1;
- errno = xerrno; // restore for caller
+ // XXX: firstErrNo is not applicable here -- socket() calls succeeded above!
+ // TODO: Stop reporting error codes via errno.
+ errno = firstErrNo;
return new_socket;
}
// notify read/write handlers after canceling select reservations, if any
if (COMMIO_FD_WRITECB(fd)->active()) {
Comm::SetSelect(fd, COMM_SELECT_WRITE, nullptr, nullptr, 0);
- COMMIO_FD_WRITECB(fd)->finish(Comm::ERR_CLOSING, errno);
+ COMMIO_FD_WRITECB(fd)->finish(Comm::ERR_CLOSING, 0);
}
if (COMMIO_FD_READCB(fd)->active()) {
Comm::SetSelect(fd, COMM_SELECT_READ, nullptr, nullptr, 0);
- COMMIO_FD_READCB(fd)->finish(Comm::ERR_CLOSING, errno);
+ COMMIO_FD_READCB(fd)->finish(Comm::ERR_CLOSING, 0);
}
#if USE_DELAY_POOLS
len = FD_WRITE_METHOD(fd,
fdd->write_q->buf + fdd->write_q->buf_offset,
fdd->write_q->len - fdd->write_q->buf_offset);
+ const auto xerrno = errno;
debugs(6, 3, "diskHandleWrite: FD " << fd << " len = " << len);
fd_bytes(fd, len, FD_WRITE);
if (len < 0) {
- if (!ignoreErrno(errno)) {
- status = errno == ENOSPC ? DISK_NO_SPACE_LEFT : DISK_ERROR;
- int xerrno = errno;
+ if (!ignoreErrno(xerrno)) {
+ status = xerrno == ENOSPC ? DISK_NO_SPACE_LEFT : DISK_ERROR;
debugs(50, DBG_IMPORTANT, "ERROR: diskHandleWrite: FD " << fd << ": disk write failure: " << xstrerr(xerrno));
/*
return true;
int xerrno = errno;
- debugs(21, (errno == ENOENT ? 2 : DBG_IMPORTANT), "ERROR: Cannot rename " << from << " to " << to << ": " << xstrerr(xerrno));
+ debugs(21, (xerrno == ENOENT ? 2 : DBG_IMPORTANT), "ERROR: Cannot rename " << from << " to " << to << ": " << xstrerr(xerrno));
return false;
}