summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:51:53 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:51:53 +0000
commit5cb5d8dc4318227ca3ec8976f67e8cfd2302d1ff (patch)
tree026fae4811ede2b7fc28773a8f4ef3042007fab8
parentf01fe790891daf085b3a16ce8be3498fcc329d6e (diff)
HTTP pipelining
Author: jgg Date: 1998-12-05 04:19:01 GMT HTTP pipelining
-rw-r--r--apt-pkg/acquire-method.cc13
-rw-r--r--apt-pkg/acquire-method.h3
-rw-r--r--apt-pkg/acquire.cc13
-rw-r--r--methods/http.cc44
-rw-r--r--methods/http.h10
5 files changed, 67 insertions, 16 deletions
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index b0176d3cb..8b1de6fb3 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-method.cc,v 1.13 1998/12/05 01:45:19 jgg Exp $
+// $Id: acquire-method.cc,v 1.14 1998/12/05 04:19:01 jgg Exp $
/* ######################################################################
Acquire Method
@@ -47,8 +47,9 @@ pkgAcqMethod::pkgAcqMethod(const char *Ver,unsigned long Flags)
exit(100);
SetNonBlock(STDIN_FILENO,true);
-
+
Queue = 0;
+ QueueBack = 0;
}
/*}}}*/
// AcqMethod::Fail - A fetch has failed /*{{{*/
@@ -78,6 +79,8 @@ void pkgAcqMethod::Fail(string Err,bool Transient)
FetchItem *Tmp = Queue;
Queue = Queue->Next;
delete Tmp;
+ if (Tmp == QueueBack)
+ QueueBack = Queue;
}
else
snprintf(S,sizeof(S),"400 URI Failure\nURI: <UNKNOWN>\n"
@@ -183,6 +186,8 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
FetchItem *Tmp = Queue;
Queue = Queue->Next;
delete Tmp;
+ if (Tmp == QueueBack)
+ QueueBack = Queue;
}
/*}}}*/
// AcqMethod::MediaFail - Syncronous request for new media /*{{{*/
@@ -328,7 +333,9 @@ int pkgAcqMethod::Run(bool Single)
FetchItem **I = &Queue;
for (; *I != 0; I = &(*I)->Next);
*I = Tmp;
-
+ if (QueueBack == 0)
+ QueueBack = Tmp;
+
// Notify that this item is to be fetched.
if (Fetch(Tmp) == false)
Fail();
diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h
index 69ed28585..cefb60468 100644
--- a/apt-pkg/acquire-method.h
+++ b/apt-pkg/acquire-method.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-method.h,v 1.6 1998/12/04 22:56:51 jgg Exp $
+// $Id: acquire-method.h,v 1.7 1998/12/05 04:19:02 jgg Exp $
/* ######################################################################
Acquire Method - Method helper class + functions
@@ -48,6 +48,7 @@ class pkgAcqMethod
// State
vector<string> Messages;
FetchItem *Queue;
+ FetchItem *QueueBack;
// Handlers for messages
virtual bool Configuration(string Message);
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 54de9916e..b7ef818a1 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire.cc,v 1.19 1998/11/29 01:24:19 jgg Exp $
+// $Id: acquire.cc,v 1.20 1998/12/05 04:19:03 jgg Exp $
/* ######################################################################
Acquire - File Acquiration
@@ -514,6 +514,17 @@ bool pkgAcquire::Queue::Startup()
if (Workers->Start() == false)
return false;
+ /* When pipelining we commit 10 items. This needs to change when we
+ added other source retry to have cycle maintain a pipeline depth
+ on its own. */
+ if (Cnf->Pipeline == true)
+ {
+ bool Res = true;
+ for (int I = 0; I != 10 && Res == true; I++)
+ Res &= Cycle();
+ return Res;
+ }
+
return Cycle();
}
/*}}}*/
diff --git a/methods/http.cc b/methods/http.cc
index 29982e2d0..c52ddc458 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: http.cc,v 1.8 1998/11/28 20:50:10 jgg Exp $
+// $Id: http.cc,v 1.9 1998/12/05 04:19:05 jgg Exp $
/* ######################################################################
HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -880,6 +880,38 @@ void HttpMethod::SigTerm(int)
exit(100);
}
/*}}}*/
+// HttpMethod::Fetch - Fetch an item /*{{{*/
+// ---------------------------------------------------------------------
+/* This adds an item to the pipeline. We keep the pipeline at a fixed
+ depth. */
+bool HttpMethod::Fetch(FetchItem *)
+{
+ if (Server == 0)
+ return true;
+
+ // Queue the requests
+ int Depth = -1;
+ bool Tail = false;
+ for (FetchItem *I = Queue; I != 0 && Depth < 5; I = I->Next, Depth++)
+ {
+ // Make sure we stick with the same server
+ if (Server->Comp(I->Uri) == false)
+ break;
+
+ if (QueueBack == I)
+ Tail = true;
+ if (Tail == true)
+ {
+ Depth++;
+ QueueBack = I->Next;
+ SendReq(I,Server->Out);
+ continue;
+ }
+ }
+
+ return true;
+};
+ /*}}}*/
// HttpMethod::Loop - Main loop /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -888,7 +920,7 @@ int HttpMethod::Loop()
signal(SIGTERM,SigTerm);
signal(SIGINT,SigTerm);
- ServerState *Server = 0;
+ Server = 0;
int FailCounter = 0;
while (1)
@@ -926,10 +958,10 @@ int HttpMethod::Loop()
Fail();
continue;
}
-
- // Queue the request
- SendReq(Queue,Server->Out);
+ // Fill the pipeline.
+ Fetch(0);
+
// Fetch the next URL header data from the server.
switch (Server->RunHeaders())
{
@@ -954,7 +986,7 @@ int HttpMethod::Loop()
continue;
}
};
-
+
// Decide what to do.
FetchResult Res;
Res.Filename = Queue->DestFile;
diff --git a/methods/http.h b/methods/http.h
index 983904ffb..1a22c5ae5 100644
--- a/methods/http.h
+++ b/methods/http.h
@@ -1,6 +1,5 @@
// -*- mode: cpp; mode: fold -*-
-// Description /*{{{*/
-// $Id: http.h,v 1.4 1998/11/11 06:54:22 jgg Exp $
+// Description /*{{{*/// $Id: http.h,v 1.5 1998/12/05 04:19:06 jgg Exp $
/* ######################################################################
HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -118,6 +117,8 @@ class HttpMethod : public pkgAcqMethod
bool Flush(ServerState *Srv);
bool ServerDie(ServerState *Srv);
int DealWithHeaders(FetchResult &Res,ServerState *Srv);
+
+ bool Fetch(FetchItem *);
// In the event of a fatal signal this file will be closed and timestamped.
static string FailFile;
@@ -128,16 +129,15 @@ class HttpMethod : public pkgAcqMethod
public:
friend ServerState;
- int Depth;
FileFd *File;
+ ServerState *Server;
int Loop();
HttpMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig)
{
- Depth = 0;
File = 0;
- Depth = 0;
+ Server = 0;
};
};