X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2Fsg_netChannel.cxx;h=3fe0decfa85ca0aaa1acc1183a5e739835cc7e11;hb=84e5142195f5d3b2bf40b11119991457d7f8558b;hp=e62e120ad173c3240e3a7a25151a03636b38fd25;hpb=6edb0f66d53b34097146f2ec00f50d2a847b04c3;p=simgear.git diff --git a/simgear/io/sg_netChannel.cxx b/simgear/io/sg_netChannel.cxx index e62e120a..3fe0decf 100644 --- a/simgear/io/sg_netChannel.cxx +++ b/simgear/io/sg_netChannel.cxx @@ -114,7 +114,7 @@ NetChannel::send (const void * buffer, int size, int flags) write_blocked = true ; return 0; } else { - this->handleError (result); + this->handleError (errorNumber()); close(); return -1; } @@ -134,7 +134,7 @@ NetChannel::recv (void * buffer, int size, int flags) } else if (isNonBlockingError ()) { return 0; } else { - this->handleError (result); + this->handleError (errorNumber()); close(); return -1; } @@ -207,7 +207,7 @@ NetChannel::handleResolve() return 0; } else { // some other error condition - handleError (result); + handleError (errorNumber()); close(); return -1; } @@ -227,6 +227,13 @@ void NetChannel::handleAccept (void) { void NetChannel::handleError (int error) { + if (error == EINPROGRESS) { + // this shoudl never happen, because we should use isNonBlocking to check + // such error codes. + SG_LOG(SG_IO, SG_WARN, "Got EINPROGRESS at NetChannel::handleError: suggests broken logic somewhere else"); + return; // not an actual error, don't warn + } + // warn about address lookup failures seperately, don't warn again. // (and we (ab-)use ENOENT to mean 'name not found'. if (error != ENOENT) { @@ -251,6 +258,11 @@ NetChannelPoller::removeChannel(NetChannel* channel) assert(channel->poller == this); channel->poller = NULL; + // portability: MSVC throws assertion failure when empty + if (channels.empty()) { + return; + } + ChannelList::iterator it = channels.begin(); for (; it != channels.end(); ++it) { if (*it == channel) {