Skip to content

Commit

Permalink
only throw exception if there is indeed an error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Israel Peña committed Jul 27, 2013
1 parent 6fb96e3 commit 1e941d5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/net/listen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,14 @@ Listen::event_write() {

void
Listen::event_error() {
throw internal_error("Listener port received an error event.");
int socket = get_fd().get_fd();
int error = 0;
socklen_t errorLen = sizeof(error);

if (getsockopt(socket, SOL_SOCKET, SO_ERROR, &error, &errorLen) != -1 && error != 0) {
std::string errorMsg = std::string("Listener port received an error event: ") + strerror(error);
throw internal_error(errorMsg.c_str());
}
}

}

0 comments on commit 1e941d5

Please sign in to comment.