]> git.saurik.com Git - apt.git/blobdiff - methods/connect.cc
* merged from mainline
[apt.git] / methods / connect.cc
index 23961d83b13fa015cf1b22f2215d37c289188e7d..8c2ac6d56dab4451b41ba0208297cad60c40fbe1 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: connect.cc,v 1.10 2003/02/10 07:34:41 doogie Exp $
+// $Id: connect.cc,v 1.10.2.1 2004/01/16 18:58:50 mdz Exp $
 /* ######################################################################
 
    Connect - Replacement connect call
 /* ######################################################################
 
    Connect - Replacement connect call
@@ -11,7 +11,6 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#include <apti18n.h>
 #include "connect.h"
 #include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
 #include "connect.h"
 #include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
@@ -27,6 +26,7 @@
 #include <netdb.h>
 
 #include "rfc2553emu.h"
 #include <netdb.h>
 
 #include "rfc2553emu.h"
+#include <apti18n.h>
                                                                        /*}}}*/
 
 static string LastHost;
                                                                        /*}}}*/
 
 static string LastHost;
@@ -88,9 +88,11 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
    
    /* This implements a timeout for connect by opening the connection
       nonblocking */
    
    /* This implements a timeout for connect by opening the connection
       nonblocking */
-   if (WaitFd(Fd,true,TimeOut) == false)
+   if (WaitFd(Fd,true,TimeOut) == false) {
+      Owner->SetFailExtraMsg("\nFailReason: Timeout");
       return _error->Error(_("Could not connect to %s:%s (%s), "
                           "connection timed out"),Host.c_str(),Service,Name);
       return _error->Error(_("Could not connect to %s:%s (%s), "
                           "connection timed out"),Host.c_str(),Service,Name);
+   }
 
    // Check the socket for an error condition
    unsigned int Err;
 
    // Check the socket for an error condition
    unsigned int Err;
@@ -101,6 +103,8 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
    if (Err != 0)
    {
       errno = Err;
    if (Err != 0)
    {
       errno = Err;
+      if(errno == ECONNREFUSED)
+         Owner->SetFailExtraMsg("\nFailReason: ConnectionRefused");
       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);
    }
@@ -164,8 +168,11 @@ bool Connect(string Host,int Port,const char *Service,int DefPort,int &Fd,
            }
            
            if (Res == EAI_AGAIN)
            }
            
            if (Res == EAI_AGAIN)
+           {
+              Owner->SetFailExtraMsg("\nFailReason: TmpResolveFailure");
               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)"),
                                 Host.c_str(),ServStr,Res);
         }