From 5cb5d8dc4318227ca3ec8976f67e8cfd2302d1ff Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 16:51:53 +0000 Subject: HTTP pipelining Author: jgg Date: 1998-12-05 04:19:01 GMT HTTP pipelining --- methods/http.cc | 44 ++++++++++++++++++++++++++++++++++++++------ methods/http.h | 10 +++++----- 2 files changed, 43 insertions(+), 11 deletions(-) (limited to 'methods') 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; }; }; -- cgit v1.2.3