errno = 0;
if (fcntl(s.socket_, F_GETFD) < 0 && (errno == EBADF)) {
s.unusable_ = true;
- } else if (!s.unusable_) {
- // Add this socket to listening set
- fd_event_handler_->add(s.socket_);
+ isc_throw(SocketFDError, "unexpected state (closed) for fd: " << s.socket_);
}
+ // Add this socket to listening set
+ fd_event_handler_->add(s.socket_);
}
}
}
if (errno == EINTR) {
isc_throw(SignalInterruptOnSelect, strerror(errno));
} else if (errno == EBADF) {
- isc_throw(SocketFDError, strerror(errno));
+ isc_throw(SocketFDError, "interrupted by one invalid sockets with error: "
+ << strerror(errno));
} else {
isc_throw(SocketReadError, strerror(errno));
}
// Let's find out which external socket has the data
SocketCallbackInfo ex_sock;
bool found = false;
- bool fd_error = false;
{
std::lock_guard<std::mutex> lock(callbacks_mutex_);
for (SocketCallbackInfo& s : callbacks_) {
- if (fd_event_handler_->hasError(s.socket_)) {
- fd_error = true;
+ if (fd_event_handler_->readReady(s.socket_)) {
+ found = true;
+
+ // something received over external socket
+ if (s.callback_) {
+ // Note the external socket to call its callback without
+ // the lock taken so it can be deleted.
+ ex_sock = s;
+ break;
+ }
+ } else if (fd_event_handler_->hasError(s.socket_)) {
errno = 0;
if (fcntl(s.socket_, F_GETFD) < 0 && (errno == EBADF)) {
s.unusable_ = true;
+ isc_throw(SocketFDError, "unexpected state (closed) for fd: " << s.socket_);
}
- break;
- }
- if (!fd_event_handler_->readReady(s.socket_)) {
- continue;
- }
- found = true;
-
- // something received over external socket
- if (s.callback_) {
- // Note the external socket to call its callback without
- // the lock taken so it can be deleted.
- ex_sock = s;
- break;
+ isc_throw(SocketFDError, "unexpected socket error: " << strerror(errno));
}
}
}
- if (fd_error) {
- isc_throw(SocketFDError, strerror(errno));
- }
if (ex_sock.callback_) {
// Calling the external socket's callback provides its service
errno = 0;
if (fcntl(s.socket_, F_GETFD) < 0 && (errno == EBADF)) {
s.unusable_ = true;
- } else if (!s.unusable_) {
- // Add this socket to listening set
- fd_event_handler_->add(s.socket_);
+ isc_throw(SocketFDError, "unexpected state (closed) for fd: " << s.socket_);
}
+ // Add this socket to listening set
+ fd_event_handler_->add(s.socket_);
}
}
}
if (errno == EINTR) {
isc_throw(SignalInterruptOnSelect, strerror(errno));
} else if (errno == EBADF) {
- isc_throw(SocketFDError, strerror(errno));
+ isc_throw(SocketFDError, "interrupted by one invalid sockets with error: "
+ << strerror(errno));
} else {
isc_throw(SocketReadError, strerror(errno));
}
// Let's find out which socket has the data
SocketCallbackInfo ex_sock;
bool found = false;
- bool fd_error = false;
{
std::lock_guard<std::mutex> lock(callbacks_mutex_);
for (SocketCallbackInfo& s : callbacks_) {
- if (fd_event_handler_->hasError(s.socket_)) {
- fd_error = true;
+ if (fd_event_handler_->readReady(s.socket_)) {
+ found = true;
+
+ // something received over external socket
+ if (s.callback_) {
+ // Note the external socket to call its callback without
+ // the lock taken so it can be deleted.
+ ex_sock = s;
+ break;
+ }
+ } else if (fd_event_handler_->hasError(s.socket_)) {
errno = 0;
if (fcntl(s.socket_, F_GETFD) < 0 && (errno == EBADF)) {
s.unusable_ = true;
+ isc_throw(SocketFDError, "unexpected state (closed) for fd: " << s.socket_);
}
- break;
- }
- if (!fd_event_handler_->readReady(s.socket_)) {
- continue;
- }
- found = true;
-
- // something received over external socket
- if (s.callback_) {
- // Note the external socket to call its callback without
- // the lock taken so it can be deleted.
- ex_sock = s;
- break;
+ isc_throw(SocketFDError, "unexpected socket error: " << strerror(errno));
}
}
}
- if (fd_error) {
- isc_throw(SocketFDError, strerror(errno));
- }
if (ex_sock.callback_) {
// Calling the external socket's callback provides its service
errno = 0;
if (fcntl(s.socket_, F_GETFD) < 0 && (errno == EBADF)) {
s.unusable_ = true;
- } else if (!s.unusable_) {
- // Add this socket to listening set
- fd_event_handler_->add(s.socket_);
+ isc_throw(SocketFDError, "unexpected state (closed) for fd: " << s.socket_);
}
+ // Add this socket to listening set
+ fd_event_handler_->add(s.socket_);
}
}
}
if (errno == EINTR) {
isc_throw(SignalInterruptOnSelect, strerror(errno));
} else if (errno == EBADF) {
- isc_throw(SocketFDError, strerror(errno));
+ isc_throw(SocketFDError, "interrupted by one invalid sockets with error: "
+ << strerror(errno));
} else {
isc_throw(SocketReadError, strerror(errno));
}
// Let's find out which socket has the data
SocketCallbackInfo ex_sock;
bool found = false;
- bool fd_error = false;
{
std::lock_guard<std::mutex> lock(callbacks_mutex_);
for (SocketCallbackInfo& s : callbacks_) {
- if (fd_event_handler_->hasError(s.socket_)) {
- fd_error = true;
+ if (fd_event_handler_->readReady(s.socket_)) {
+ found = true;
+
+ // something received over external socket
+ if (s.callback_) {
+ // Note the external socket to call its callback without
+ // the lock taken so it can be deleted.
+ ex_sock = s;
+ break;
+ }
+ } else if (fd_event_handler_->hasError(s.socket_)) {
errno = 0;
if (fcntl(s.socket_, F_GETFD) < 0 && (errno == EBADF)) {
s.unusable_ = true;
+ isc_throw(SocketFDError, "unexpected state (closed) for fd: " << s.socket_);
}
- break;
- }
- if (!fd_event_handler_->readReady(s.socket_)) {
- continue;
- }
- found = true;
-
- // something received over external socket
- if (s.callback_) {
- // Note the external socket to call its callback without
- // the lock taken so it can be deleted.
- ex_sock = s;
- break;
+ isc_throw(SocketFDError, "unexpected socket error: " << strerror(errno));
}
}
}
- if (fd_error) {
- isc_throw(SocketFDError, strerror(errno));
- }
if (ex_sock.callback_) {
// Calling the external socket's callback provides its service
errno = 0;
if (fcntl(s.socket_, F_GETFD) < 0 && (errno == EBADF)) {
s.unusable_ = true;
- } else if (!s.unusable_) {
- // Add this socket to listening set
- fd_event_handler_->add(s.socket_);
+ isc_throw(SocketFDError, "unexpected state (closed) for fd: " << s.socket_);
}
+ // Add this socket to listening set
+ fd_event_handler_->add(s.socket_);
}
}
}
if (errno == EINTR) {
isc_throw(SignalInterruptOnSelect, strerror(errno));
} else if (errno == EBADF) {
- isc_throw(SocketFDError, strerror(errno));
+ isc_throw(SocketFDError, "interrupted by one invalid sockets with error: "
+ << strerror(errno));
} else {
isc_throw(SocketReadError, strerror(errno));
}
// Let's find out which external socket has the data
SocketCallbackInfo ex_sock;
bool found = false;
- bool fd_error = false;
{
std::lock_guard<std::mutex> lock(callbacks_mutex_);
for (SocketCallbackInfo& s : callbacks_) {
- if (fd_event_handler_->hasError(s.socket_)) {
- fd_error = true;
+ if (fd_event_handler_->readReady(s.socket_)) {
+ found = true;
+
+ // something received over external socket
+ if (s.callback_) {
+ // Note the external socket to call its callback without
+ // the lock taken so it can be deleted.
+ ex_sock = s;
+ break;
+ }
+ } else if (fd_event_handler_->hasError(s.socket_)) {
errno = 0;
if (fcntl(s.socket_, F_GETFD) < 0 && (errno == EBADF)) {
s.unusable_ = true;
+ isc_throw(SocketFDError, "unexpected state (closed) for fd: " << s.socket_);
}
- break;
- }
- if (!fd_event_handler_->readReady(s.socket_)) {
- continue;
- }
- found = true;
-
- // something received over external socket
- if (s.callback_) {
- // Note the external socket to call its callback without
- // the lock taken so it can be deleted.
- ex_sock = s;
- break;
+ isc_throw(SocketFDError, "unexpected socket error: " << strerror(errno));
}
}
}
- if (fd_error) {
- isc_throw(SocketFDError, strerror(errno));
- }
if (ex_sock.callback_) {
// Calling the external socket's callback provides its service