]> git.saurik.com Git - apt.git/blobdiff - methods/connect.cc
test-indexes.sh: Add source related tests, which uncovers two regressions
[apt.git] / methods / connect.cc
index 355bd5c4d2253f3d88f8346a614ba3622958b032..2f6b4833e2e636ccf12e87ce8c6b3d5ab86796eb 100644 (file)
@@ -116,6 +116,9 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
       errno = Err;
       if(errno == ECONNREFUSED)
          Owner->SetFailExtraMsg("\nFailReason: ConnectionRefused");
       errno = Err;
       if(errno == ECONNREFUSED)
          Owner->SetFailExtraMsg("\nFailReason: ConnectionRefused");
+      else if (errno == ETIMEDOUT)
+        Owner->SetFailExtraMsg("\nFailReason: ConnectionTimedOut");
+      bad_addr.insert(bad_addr.begin(), string(Name));
       return _error->Errno("connect",_("Could not connect to %s:%s (%s)."),Host.c_str(),
                           Service,Name);
    }
       return _error->Errno("connect",_("Could not connect to %s:%s (%s)."),Host.c_str(),
                           Service,Name);
    }
@@ -158,6 +161,7 @@ bool Connect(string Host,int Port,const char *Service,int DefPort,int &Fd,
       struct addrinfo Hints;
       memset(&Hints,0,sizeof(Hints));
       Hints.ai_socktype = SOCK_STREAM;
       struct addrinfo Hints;
       memset(&Hints,0,sizeof(Hints));
       Hints.ai_socktype = SOCK_STREAM;
+      Hints.ai_flags = AI_ADDRCONFIG;
       Hints.ai_protocol = 0;
       
       // if we couldn't resolve the host before, we don't try now
       Hints.ai_protocol = 0;
       
       // if we couldn't resolve the host before, we don't try now
@@ -190,8 +194,8 @@ bool Connect(string Host,int Port,const char *Service,int DefPort,int &Fd,
               return _error->Error(_("Temporary failure resolving '%s'"),
                                    Host.c_str());
            }
               return _error->Error(_("Temporary failure resolving '%s'"),
                                    Host.c_str());
            }
-           return _error->Error(_("Something wicked happened resolving '%s:%s' (%i)"),
-                                Host.c_str(),ServStr,Res);
+           return _error->Error(_("Something wicked happened resolving '%s:%s' (%i - %s)"),
+                                Host.c_str(),ServStr,Res,gai_strerror(Res));
         }
         break;
       }
         }
         break;
       }
@@ -237,6 +241,6 @@ bool Connect(string Host,int Port,const char *Service,int DefPort,int &Fd,
 
    if (_error->PendingError() == true)
       return false;   
 
    if (_error->PendingError() == true)
       return false;   
-   return _error->Error(_("Unable to connect to %s %s:"),Host.c_str(),ServStr);
+   return _error->Error(_("Unable to connect to %s:%s:"),Host.c_str(),ServStr);
 }
                                                                        /*}}}*/
 }
                                                                        /*}}}*/