summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:55:19 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:55:19 +0000
commitf93d1355dd915fd5c197293ba0e62292ec15cb2d (patch)
tree78be0c02ba0ec102282e26e1b611b6f0f9ab25e5
parent0b5c85b5c9edc8cbd9a3962d412810354398b095 (diff)
Reorderd error handling
Author: jgg Date: 1999-12-09 03:45:56 GMT Reorderd error handling
-rw-r--r--methods/ftp.cc8
-rw-r--r--methods/http.cc14
-rw-r--r--methods/http.h6
-rw-r--r--methods/rfc2553emu.cc4
4 files changed, 21 insertions, 11 deletions
diff --git a/methods/ftp.cc b/methods/ftp.cc
index b9f708d80..a7fa83233 100644
--- a/methods/ftp.cc
+++ b/methods/ftp.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: ftp.cc,v 1.16 1999/11/29 23:20:27 jgg Exp $
+// $Id: ftp.cc,v 1.17 1999/12/09 03:45:56 jgg Exp $
/* ######################################################################
HTTP Aquire Method - This is the FTP aquire method for APT.
@@ -285,8 +285,9 @@ bool FTPConn::ReadLine(string &Text)
int Res = read(ServerFd,Buffer + Len,sizeof(Buffer) - Len);
if (Res <= 0)
{
+ _error->Errno("read","Read error");
Close();
- return _error->Errno("read","Read error");
+ return false;
}
Len += Res;
}
@@ -392,8 +393,9 @@ bool FTPConn::WriteMsg(unsigned int &Ret,string &Text,const char *Fmt,...)
int Res = write(ServerFd,S + Start,Len);
if (Res <= 0)
{
+ _error->Errno("write","Write Error");
Close();
- return _error->Errno("write","Write Error");
+ return false;
}
Len -= Res;
diff --git a/methods/http.cc b/methods/http.cc
index 456e7146a..ee0d75ef8 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: http.cc,v 1.40 1999/11/29 23:20:27 jgg Exp $
+// $Id: http.cc,v 1.41 1999/12/09 03:45:56 jgg Exp $
/* ######################################################################
HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -934,8 +934,13 @@ bool HttpMethod::Fetch(FetchItem *)
// Queue the requests
int Depth = -1;
bool Tail = false;
- for (FetchItem *I = Queue; I != 0 && Depth < (signed)PipelineDepth; I = I->Next, Depth++)
+ for (FetchItem *I = Queue; I != 0 && Depth < (signed)PipelineDepth;
+ I = I->Next, Depth++)
{
+ // If pipelining is disabled, we only queue 1 request
+ if (Server->Pipeline == false && Depth >= 0)
+ break;
+
// Make sure we stick with the same server
if (Server->Comp(I->Uri) == false)
break;
@@ -946,7 +951,7 @@ bool HttpMethod::Fetch(FetchItem *)
QueueBack = I->Next;
SendReq(I,Server->Out);
continue;
- }
+ }
}
return true;
@@ -1041,7 +1046,8 @@ int HttpMethod::Loop()
FailCounter++;
_error->Discard();
Server->Close();
-
+ Server->Pipeline = false;
+
if (FailCounter >= 2)
{
Fail("Connection failed",true);
diff --git a/methods/http.h b/methods/http.h
index 700587048..2098fc832 100644
--- a/methods/http.h
+++ b/methods/http.h
@@ -1,5 +1,5 @@
// -*- mode: cpp; mode: fold -*-
-// Description /*{{{*/// $Id: http.h,v 1.6 1998/12/10 05:39:56 jgg Exp $
+// Description /*{{{*/// $Id: http.h,v 1.7 1999/12/09 03:45:56 jgg Exp $
/* ######################################################################
HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -87,6 +87,7 @@ struct ServerState
bool HaveContent;
enum {Chunked,Stream,Closes} Encoding;
enum {Header, Data} State;
+ bool Pipeline;
HttpMethod *Owner;
@@ -99,7 +100,8 @@ struct ServerState
bool HeaderLine(string Line);
bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
void Reset() {Major = 0; Minor = 0; Result = 0; Size = 0; StartPos = 0;
- Encoding = Closes; time(&Date); ServerFd = -1;};
+ Encoding = Closes; time(&Date); ServerFd = -1;
+ Pipeline = true;};
int RunHeaders();
bool RunData();
diff --git a/methods/rfc2553emu.cc b/methods/rfc2553emu.cc
index bd8d2236f..e363c68e2 100644
--- a/methods/rfc2553emu.cc
+++ b/methods/rfc2553emu.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: rfc2553emu.cc,v 1.3 1999/05/27 05:51:18 jgg Exp $
+// $Id: rfc2553emu.cc,v 1.4 1999/12/09 03:45:56 jgg Exp $
/* ######################################################################
RFC 2553 Emulation - Provides emulation for RFC 2553 getaddrinfo,
@@ -57,7 +57,7 @@ int getaddrinfo(const char *nodename, const char *servname,
Proto = hints->ai_socktype;
// Not a number, must be a name.
- if (End != servname + strlen(End))
+ if (End != servname + strlen(servname))
{
struct servent *Srv = 0;