summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorMichael Vogt <egon@tas>2007-02-01 12:32:50 +0100
committerMichael Vogt <egon@tas>2007-02-01 12:32:50 +0100
commit36280399db0ae203d3f1ae4d44b946f31e9a38ce (patch)
tree79cba67d2c395b54d2b2ff5863de00ffeab4fdda /methods
parent362d29343e5d25248bcd84300aa1b18effe891e7 (diff)
* commited the latest mirror failure detection code
Diffstat (limited to 'methods')
-rw-r--r--methods/connect.cc17
-rw-r--r--methods/mirror.cc45
-rw-r--r--methods/mirror.h1
3 files changed, 12 insertions, 51 deletions
diff --git a/methods/connect.cc b/methods/connect.cc
index 8c2ac6d56..4e227c3fd 100644
--- a/methods/connect.cc
+++ b/methods/connect.cc
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
+#include <sstream>
// Internet stuff
#include <netinet/in.h>
@@ -67,12 +68,10 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
wrong this will get tacked onto the end of the error message */
if (LastHostAddr->ai_next != 0)
{
- char Name2[NI_MAXHOST + NI_MAXSERV + 10];
- snprintf(Name2,sizeof(Name2),_("[IP: %s %s]"),Name,Service);
- Owner->SetFailExtraMsg(string(Name2));
- }
- else
- Owner->SetFailExtraMsg("");
+ std::stringstream ss;
+ ioprintf(ss, _("[IP: %s %s]"),Name,Service);
+ Owner->SetIP(ss.str());
+ }
// Get a socket
if ((Fd = socket(Addr->ai_family,Addr->ai_socktype,
@@ -89,7 +88,7 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
/* This implements a timeout for connect by opening the connection
nonblocking */
if (WaitFd(Fd,true,TimeOut) == false) {
- Owner->SetFailExtraMsg("\nFailReason: Timeout");
+ Owner->SetFailReason("Timeout");
return _error->Error(_("Could not connect to %s:%s (%s), "
"connection timed out"),Host.c_str(),Service,Name);
}
@@ -104,7 +103,7 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
{
errno = Err;
if(errno == ECONNREFUSED)
- Owner->SetFailExtraMsg("\nFailReason: ConnectionRefused");
+ Owner->SetFailReason("ConnectionRefused");
return _error->Errno("connect",_("Could not connect to %s:%s (%s)."),Host.c_str(),
Service,Name);
}
@@ -169,7 +168,7 @@ bool Connect(string Host,int Port,const char *Service,int DefPort,int &Fd,
if (Res == EAI_AGAIN)
{
- Owner->SetFailExtraMsg("\nFailReason: TmpResolveFailure");
+ Owner->SetFailReason("TmpResolveFailure");
return _error->Error(_("Temporary failure resolving '%s'"),
Host.c_str());
}
diff --git a/methods/mirror.cc b/methods/mirror.cc
index 8f9b8ed34..8ccfb8559 100644
--- a/methods/mirror.cc
+++ b/methods/mirror.cc
@@ -38,7 +38,7 @@ using namespace std;
*
* TODO:
* what about gpgv failures? this should call-out to the problem reporting
- script, but we need to know what mirror was used
+ script, but we need to know what mirror was used -> just run pkgAcquire::Item::ReportMirrorFailure()
* better standard format for errors to send back
* - implement failure reporting at the pkgAcquire::Item::Failed() level
but then we need to send back what uri exactly was failing
@@ -48,7 +48,7 @@ using namespace std;
* - deal with runing as non-root because we can't write to the lists
dir then -> use the cached mirror file
* - better method to download than having a pkgAcquire interface here
- * - magicmarker is (a bit) evil, maybe just use a similar approach as in
+ * - magicmarker is evil, maybe just use a similar approach as in
clean and read the sources.list and use the GetURI() method to find
the prefix?
* support more than http
@@ -191,6 +191,8 @@ bool MirrorMethod::SelectMirror()
getline(in, Mirror);
if(Debug)
cerr << "Using mirror: " << Mirror << endl;
+
+ UsedMirror = Mirror;
return true;
}
@@ -220,9 +222,6 @@ bool MirrorMethod::Fetch(FetchItem *Itm)
void MirrorMethod::Fail(string Err,bool Transient)
{
- // FIXME: queue next mirror?
- ReportMirrorFailure(Err);
-
if(Queue->Uri.find("http://") != string::npos)
Queue->Uri.replace(0,Mirror.size(), BaseUri);
pkgAcqMethod::Fail(Err, Transient);
@@ -237,47 +236,11 @@ void MirrorMethod::URIStart(FetchResult &Res)
void MirrorMethod::URIDone(FetchResult &Res,FetchResult *Alt)
{
- // FIXME: queue next mirror?
- if(Queue->ExpectedMD5 != "" && Res.MD5Sum != Queue->ExpectedMD5)
- ReportMirrorFailure("499 Hash mismatch");
-
if(Queue->Uri.find("http://") != string::npos)
Queue->Uri.replace(0,Mirror.size(), BaseUri);
pkgAcqMethod::URIDone(Res, Alt);
}
-void MirrorMethod::ReportMirrorFailure(string FailCode)
-{
- // report that Queue->Uri failed
-#if 0
- std::cerr << "\nReportMirrorFailure: "
- << Queue->Uri
- << " FailCode: "
- << FailCode << std::endl;
-#endif
- const char *Args[40];
- unsigned int i = 0;
- string report = _config->Find("Methods::Mirror::ProblemReporting",
- "/usr/lib/apt/report-mirror-failure");
- Args[i++] = report.c_str();
- Args[i++] = Queue->Uri.c_str();
- Args[i++] = FailCode.c_str();
- pid_t pid = ExecFork();
- if(pid < 0)
- {
- _error->Error("ReportMirrorFailure Fork failed");
- return;
- }
- else if(pid == 0)
- {
- execvp(report.c_str(), (char**)Args);
- }
- if(!ExecWait(pid, "report-mirror-failure"))
- {
- _error->Warning("Couldn't report problem to '%s'",
- _config->Find("Acquire::Mirror::ReportFailures").c_str());
- }
-}
int main()
{
diff --git a/methods/mirror.h b/methods/mirror.h
index 3ff9e1a96..798f5a9b5 100644
--- a/methods/mirror.h
+++ b/methods/mirror.h
@@ -35,7 +35,6 @@ class MirrorMethod : public HttpMethod
bool GetMirrorFile(string uri);
bool SelectMirror();
bool Clean(string dir);
- void ReportMirrorFailure(string FailCode);
// we need to overwrite those to transform the url back
virtual void Fail(string Why, bool Transient = false);