]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/sg_netChannel.cxx
Fix for HTTP/curl waiting on update
[simgear.git] / simgear / io / sg_netChannel.cxx
index e62e120ad173c3240e3a7a25151a03636b38fd25..3fe0decfa85ca0aaa1acc1183a5e739835cc7e11 100644 (file)
@@ -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) {