]> git.mxchange.org Git - simgear.git/commitdiff
Notify all requests on name lookup failures.
authorJames Turner <jmt@Bishop.local>
Sat, 29 Dec 2012 14:36:38 +0000 (14:36 +0000)
committerJames Turner <jmt@Bishop.local>
Sat, 29 Dec 2012 14:36:38 +0000 (14:36 +0000)
Since there's no active request during a name lookup failure, explicitly fail all sent and queued requests, so the Request subclasses can take regular failure action.

simgear/io/HTTPClient.cxx

index ec25011f49ae1aa36624ed452499f21f2d6a5b6f..71f03e372405a70bcab1a92c1f47f4b4e89b7255 100644 (file)
@@ -88,13 +88,24 @@ public:
     virtual void handleError(int error)
     {
         if (error == ENOENT) {
-            // name lookup failure, abandon all requests on this connection
+        // name lookup failure
+            // we won't have an active request yet, so the logic below won't
+            // fire to actually call setFailure. Let's fail all of the requests
+            BOOST_FOREACH(Request_ptr req, sentRequests) {
+                req->setFailure(error, "hostname lookup failure");
+            }
+            
+            BOOST_FOREACH(Request_ptr req, queuedRequests) {
+                req->setFailure(error, "hostname lookup failure");
+            }
+            
+        // name lookup failure, abandon all requests on this connection
             sentRequests.clear();
             queuedRequests.clear();
         }
         
         NetChat::handleError(error);
-        if (activeRequest) {
+        if (activeRequest) {            
             SG_LOG(SG_IO, SG_INFO, "HTTP socket error");
             activeRequest->setFailure(error, "socket error");
             activeRequest = NULL;