]>
git.saurik.com Git - apt.git/blob - apt-pkg/acquire.cc
d83d80fac155d14b68e25e19ecb246f844731abf
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: acquire.cc,v 1.50 2004/03/17 05:17:11 mdz Exp $
4 /* ######################################################################
6 Acquire - File Acquiration
8 The core element for the schedual system is the concept of a named
9 queue. Each queue is unique and each queue has a name derived from the
10 URI. The degree of paralization can be controled by how the queue
11 name is derived from the URI.
13 ##################################################################### */
15 // Include Files /*{{{*/
16 #include <apt-pkg/acquire.h>
17 #include <apt-pkg/acquire-item.h>
18 #include <apt-pkg/acquire-worker.h>
19 #include <apt-pkg/configuration.h>
20 #include <apt-pkg/error.h>
21 #include <apt-pkg/strutl.h>
22 #include <apt-pkg/fileutl.h>
37 // Acquire::pkgAcquire - Constructor /*{{{*/
38 // ---------------------------------------------------------------------
39 /* We grab some runtime state from the configuration space */
40 pkgAcquire::pkgAcquire() : Queues(0), Workers(0), Configs(0), Log(NULL
), ToFetch(0),
41 Debug(_config
->FindB("Debug::pkgAcquire",false)),
42 Running(false), LockFD(-1)
44 string
const Mode
= _config
->Find("Acquire::Queue-Mode","host");
45 if (strcasecmp(Mode
.c_str(),"host") == 0)
46 QueueMode
= QueueHost
;
47 if (strcasecmp(Mode
.c_str(),"access") == 0)
48 QueueMode
= QueueAccess
;
50 pkgAcquire::pkgAcquire(pkgAcquireStatus
*Progress
) : Queues(0), Workers(0),
51 Configs(0), Log(Progress
), ToFetch(0),
52 Debug(_config
->FindB("Debug::pkgAcquire",false)),
53 Running(false), LockFD(-1)
55 string
const Mode
= _config
->Find("Acquire::Queue-Mode","host");
56 if (strcasecmp(Mode
.c_str(),"host") == 0)
57 QueueMode
= QueueHost
;
58 if (strcasecmp(Mode
.c_str(),"access") == 0)
59 QueueMode
= QueueAccess
;
63 // Acquire::Setup - Delayed Constructor /*{{{*/
64 // ---------------------------------------------------------------------
65 /* Do everything needed to be a complete Acquire object and report the
66 success (or failure) back so the user knows that something is wrong… */
67 bool pkgAcquire::Setup(pkgAcquireStatus
*Progress
, string
const &Lock
)
71 // check for existence and possibly create auxiliary directories
72 if (CheckDirectory(_config
->FindDir("Dir::State"), _config
->FindDir("Dir::State::lists") + "partial/") == false ||
73 CheckDirectory(_config
->FindDir("Dir::Cache"), _config
->FindDir("Dir::Cache::Archives") + "partial/") == false)
76 if (Lock
.empty() == true || _config
->FindB("Debug::NoLocking", false) == true)
79 // Lock the directory this acquire object will work in
80 LockFD
= GetLock(flCombine(Lock
, "lock"));
82 return _error
->Error(_("Unable to lock directory %s"), Lock
.c_str());
87 // Acquire::CheckDirectory - ensure that the given directory exists /*{{{*/
88 // ---------------------------------------------------------------------
89 /* a small wrapper around CreateDirectory to check if it exists and to
90 remove the trailing "/apt/" from the parent directory if needed */
91 bool pkgAcquire::CheckDirectory(string
const &Parent
, string
const &Path
) const
93 if (DirectoryExists(Path
) == true)
96 size_t const len
= Parent
.size();
97 if (len
> 5 && Parent
.find("/apt/", len
- 6, 5) != len
- 5)
99 if (CreateDirectory(Parent
.substr(0,len
-5), Path
) == true)
102 else if (CreateDirectory(Parent
, Path
) == true)
105 return _error
->Errno("Acquire", _("Directory %s can't be created."), Path
.c_str());
108 // Acquire::~pkgAcquire - Destructor /*{{{*/
109 // ---------------------------------------------------------------------
110 /* Free our memory, clean up the queues (destroy the workers) */
111 pkgAcquire::~pkgAcquire()
120 MethodConfig
*Jnk
= Configs
;
121 Configs
= Configs
->Next
;
126 // Acquire::Shutdown - Clean out the acquire object /*{{{*/
127 // ---------------------------------------------------------------------
129 void pkgAcquire::Shutdown()
131 while (Items
.size() != 0)
133 if (Items
[0]->Status
== Item::StatFetching
)
134 Items
[0]->Status
= Item::StatError
;
141 Queues
= Queues
->Next
;
146 // Acquire::Add - Add a new item /*{{{*/
147 // ---------------------------------------------------------------------
148 /* This puts an item on the acquire list. This list is mainly for tracking
150 void pkgAcquire::Add(Item
*Itm
)
152 Items
.push_back(Itm
);
155 // Acquire::Remove - Remove a item /*{{{*/
156 // ---------------------------------------------------------------------
157 /* Remove an item from the acquire list. This is usually not used.. */
158 void pkgAcquire::Remove(Item
*Itm
)
162 for (ItemIterator I
= Items
.begin(); I
!= Items
.end();)
174 // Acquire::Add - Add a worker /*{{{*/
175 // ---------------------------------------------------------------------
176 /* A list of workers is kept so that the select loop can direct their FD
178 void pkgAcquire::Add(Worker
*Work
)
180 Work
->NextAcquire
= Workers
;
184 // Acquire::Remove - Remove a worker /*{{{*/
185 // ---------------------------------------------------------------------
186 /* A worker has died. This can not be done while the select loop is running
187 as it would require that RunFds could handling a changing list state and
189 void pkgAcquire::Remove(Worker
*Work
)
194 Worker
**I
= &Workers
;
198 *I
= (*I
)->NextAcquire
;
200 I
= &(*I
)->NextAcquire
;
204 // Acquire::Enqueue - Queue an URI for fetching /*{{{*/
205 // ---------------------------------------------------------------------
206 /* This is the entry point for an item. An item calls this function when
207 it is constructed which creates a queue (based on the current queue
208 mode) and puts the item in that queue. If the system is running then
209 the queue might be started. */
210 void pkgAcquire::Enqueue(ItemDesc
&Item
)
212 // Determine which queue to put the item in
213 const MethodConfig
*Config
;
214 string Name
= QueueName(Item
.URI
,Config
);
215 if (Name
.empty() == true)
218 // Find the queue structure
220 for (; I
!= 0 && I
->Name
!= Name
; I
= I
->Next
);
223 I
= new Queue(Name
,this);
231 // See if this is a local only URI
232 if (Config
->LocalOnly
== true && Item
.Owner
->Complete
== false)
233 Item
.Owner
->Local
= true;
234 Item
.Owner
->Status
= Item::StatIdle
;
236 // Queue it into the named queue
243 clog
<< "Fetching " << Item
.URI
<< endl
;
244 clog
<< " to " << Item
.Owner
->DestFile
<< endl
;
245 clog
<< " Queue is: " << Name
<< endl
;
249 // Acquire::Dequeue - Remove an item from all queues /*{{{*/
250 // ---------------------------------------------------------------------
251 /* This is called when an item is finished being fetched. It removes it
252 from all the queues */
253 void pkgAcquire::Dequeue(Item
*Itm
)
257 for (; I
!= 0; I
= I
->Next
)
258 Res
|= I
->Dequeue(Itm
);
261 clog
<< "Dequeuing " << Itm
->DestFile
<< endl
;
266 // Acquire::QueueName - Return the name of the queue for this URI /*{{{*/
267 // ---------------------------------------------------------------------
268 /* The string returned depends on the configuration settings and the
269 method parameters. Given something like http://foo.org/bar it can
270 return http://foo.org or http */
271 string
pkgAcquire::QueueName(string Uri
,MethodConfig
const *&Config
)
275 Config
= GetConfig(U
.Access
);
279 /* Single-Instance methods get exactly one queue per URI. This is
280 also used for the Access queue method */
281 if (Config
->SingleInstance
== true || QueueMode
== QueueAccess
)
284 return U
.Access
+ ':' + U
.Host
;
287 // Acquire::GetConfig - Fetch the configuration information /*{{{*/
288 // ---------------------------------------------------------------------
289 /* This locates the configuration structure for an access method. If
290 a config structure cannot be found a Worker will be created to
292 pkgAcquire::MethodConfig
*pkgAcquire::GetConfig(string Access
)
294 // Search for an existing config
296 for (Conf
= Configs
; Conf
!= 0; Conf
= Conf
->Next
)
297 if (Conf
->Access
== Access
)
300 // Create the new config class
301 Conf
= new MethodConfig
;
302 Conf
->Access
= Access
;
303 Conf
->Next
= Configs
;
306 // Create the worker to fetch the configuration
308 if (Work
.Start() == false)
311 /* if a method uses DownloadLimit, we switch to SingleInstance mode */
312 if(_config
->FindI("Acquire::"+Access
+"::Dl-Limit",0) > 0)
313 Conf
->SingleInstance
= true;
318 // Acquire::SetFds - Deal with readable FDs /*{{{*/
319 // ---------------------------------------------------------------------
320 /* Collect FDs that have activity monitors into the fd sets */
321 void pkgAcquire::SetFds(int &Fd
,fd_set
*RSet
,fd_set
*WSet
)
323 for (Worker
*I
= Workers
; I
!= 0; I
= I
->NextAcquire
)
325 if (I
->InReady
== true && I
->InFd
>= 0)
329 FD_SET(I
->InFd
,RSet
);
331 if (I
->OutReady
== true && I
->OutFd
>= 0)
335 FD_SET(I
->OutFd
,WSet
);
340 // Acquire::RunFds - Deal with active FDs /*{{{*/
341 // ---------------------------------------------------------------------
342 /* Dispatch active FDs over to the proper workers. It is very important
343 that a worker never be erased while this is running! The queue class
344 should never erase a worker except during shutdown processing. */
345 void pkgAcquire::RunFds(fd_set
*RSet
,fd_set
*WSet
)
347 for (Worker
*I
= Workers
; I
!= 0; I
= I
->NextAcquire
)
349 if (I
->InFd
>= 0 && FD_ISSET(I
->InFd
,RSet
) != 0)
351 if (I
->OutFd
>= 0 && FD_ISSET(I
->OutFd
,WSet
) != 0)
356 // Acquire::Run - Run the fetch sequence /*{{{*/
357 // ---------------------------------------------------------------------
358 /* This runs the queues. It manages a select loop for all of the
359 Worker tasks. The workers interact with the queues and items to
360 manage the actual fetch. */
361 pkgAcquire::RunResult
pkgAcquire::Run(int PulseIntervall
)
365 for (Queue
*I
= Queues
; I
!= 0; I
= I
->Next
)
371 bool WasCancelled
= false;
373 // Run till all things have been acquired
376 tv
.tv_usec
= PulseIntervall
;
384 SetFds(Highest
,&RFds
,&WFds
);
389 Res
= select(Highest
+1,&RFds
,&WFds
,0,&tv
);
391 while (Res
< 0 && errno
== EINTR
);
395 _error
->Errno("select","Select has failed");
400 if (_error
->PendingError() == true)
403 // Timeout, notify the log class
404 if (Res
== 0 || (Log
!= 0 && Log
->Update
== true))
406 tv
.tv_usec
= PulseIntervall
;
407 for (Worker
*I
= Workers
; I
!= 0; I
= I
->NextAcquire
)
409 if (Log
!= 0 && Log
->Pulse(this) == false)
420 // Shut down the acquire bits
422 for (Queue
*I
= Queues
; I
!= 0; I
= I
->Next
)
425 // Shut down the items
426 for (ItemIterator I
= Items
.begin(); I
!= Items
.end(); I
++)
429 if (_error
->PendingError())
436 // Acquire::Bump - Called when an item is dequeued /*{{{*/
437 // ---------------------------------------------------------------------
438 /* This routine bumps idle queues in hopes that they will be able to fetch
440 void pkgAcquire::Bump()
442 for (Queue
*I
= Queues
; I
!= 0; I
= I
->Next
)
446 // Acquire::WorkerStep - Step to the next worker /*{{{*/
447 // ---------------------------------------------------------------------
448 /* Not inlined to advoid including acquire-worker.h */
449 pkgAcquire::Worker
*pkgAcquire::WorkerStep(Worker
*I
)
451 return I
->NextAcquire
;
454 // Acquire::Clean - Cleans a directory /*{{{*/
455 // ---------------------------------------------------------------------
456 /* This is a bit simplistic, it looks at every file in the dir and sees
457 if it is part of the download set. */
458 bool pkgAcquire::Clean(string Dir
)
460 DIR *D
= opendir(Dir
.c_str());
462 return _error
->Errno("opendir",_("Unable to read %s"),Dir
.c_str());
464 string StartDir
= SafeGetCWD();
465 if (chdir(Dir
.c_str()) != 0)
468 return _error
->Errno("chdir",_("Unable to change to %s"),Dir
.c_str());
471 for (struct dirent
*Dir
= readdir(D
); Dir
!= 0; Dir
= readdir(D
))
474 if (strcmp(Dir
->d_name
,"lock") == 0 ||
475 strcmp(Dir
->d_name
,"partial") == 0 ||
476 strcmp(Dir
->d_name
,".") == 0 ||
477 strcmp(Dir
->d_name
,"..") == 0)
480 // Look in the get list
481 ItemCIterator I
= Items
.begin();
482 for (; I
!= Items
.end(); I
++)
483 if (flNotDir((*I
)->DestFile
) == Dir
->d_name
)
486 // Nothing found, nuke it
487 if (I
== Items
.end())
492 if (chdir(StartDir
.c_str()) != 0)
493 return _error
->Errno("chdir",_("Unable to change to %s"),StartDir
.c_str());
497 // Acquire::TotalNeeded - Number of bytes to fetch /*{{{*/
498 // ---------------------------------------------------------------------
499 /* This is the total number of bytes needed */
500 double pkgAcquire::TotalNeeded()
503 for (ItemCIterator I
= ItemsBegin(); I
!= ItemsEnd(); I
++)
504 Total
+= (*I
)->FileSize
;
508 // Acquire::FetchNeeded - Number of bytes needed to get /*{{{*/
509 // ---------------------------------------------------------------------
510 /* This is the number of bytes that is not local */
511 double pkgAcquire::FetchNeeded()
514 for (ItemCIterator I
= ItemsBegin(); I
!= ItemsEnd(); I
++)
515 if ((*I
)->Local
== false)
516 Total
+= (*I
)->FileSize
;
520 // Acquire::PartialPresent - Number of partial bytes we already have /*{{{*/
521 // ---------------------------------------------------------------------
522 /* This is the number of bytes that is not local */
523 double pkgAcquire::PartialPresent()
526 for (ItemCIterator I
= ItemsBegin(); I
!= ItemsEnd(); I
++)
527 if ((*I
)->Local
== false)
528 Total
+= (*I
)->PartialSize
;
532 // Acquire::UriBegin - Start iterator for the uri list /*{{{*/
533 // ---------------------------------------------------------------------
535 pkgAcquire::UriIterator
pkgAcquire::UriBegin()
537 return UriIterator(Queues
);
540 // Acquire::UriEnd - End iterator for the uri list /*{{{*/
541 // ---------------------------------------------------------------------
543 pkgAcquire::UriIterator
pkgAcquire::UriEnd()
545 return UriIterator(0);
548 // Acquire::MethodConfig::MethodConfig - Constructor /*{{{*/
549 // ---------------------------------------------------------------------
551 pkgAcquire::MethodConfig::MethodConfig()
553 SingleInstance
= false;
561 // Queue::Queue - Constructor /*{{{*/
562 // ---------------------------------------------------------------------
564 pkgAcquire::Queue::Queue(string Name
,pkgAcquire
*Owner
) : Name(Name
),
574 // Queue::~Queue - Destructor /*{{{*/
575 // ---------------------------------------------------------------------
577 pkgAcquire::Queue::~Queue()
589 // Queue::Enqueue - Queue an item to the queue /*{{{*/
590 // ---------------------------------------------------------------------
592 bool pkgAcquire::Queue::Enqueue(ItemDesc
&Item
)
595 // move to the end of the queue and check for duplicates here
596 for (; *I
!= 0; I
= &(*I
)->Next
)
597 if (Item
.URI
== (*I
)->URI
)
599 Item
.Owner
->Status
= Item::StatDone
;
604 QItem
*Itm
= new QItem
;
609 Item
.Owner
->QueueCounter
++;
610 if (Items
->Next
== 0)
615 // Queue::Dequeue - Remove an item from the queue /*{{{*/
616 // ---------------------------------------------------------------------
617 /* We return true if we hit something */
618 bool pkgAcquire::Queue::Dequeue(Item
*Owner
)
620 if (Owner
->Status
== pkgAcquire::Item::StatFetching
)
621 return _error
->Error("Tried to dequeue a fetching object");
628 if ((*I
)->Owner
== Owner
)
632 Owner
->QueueCounter
--;
643 // Queue::Startup - Start the worker processes /*{{{*/
644 // ---------------------------------------------------------------------
645 /* It is possible for this to be called with a pre-existing set of
647 bool pkgAcquire::Queue::Startup()
652 pkgAcquire::MethodConfig
*Cnf
= Owner
->GetConfig(U
.Access
);
656 Workers
= new Worker(this,Cnf
,Owner
->Log
);
658 if (Workers
->Start() == false)
661 /* When pipelining we commit 10 items. This needs to change when we
662 added other source retry to have cycle maintain a pipeline depth
664 if (Cnf
->Pipeline
== true)
665 MaxPipeDepth
= _config
->FindI("Acquire::Max-Pipeline-Depth",10);
673 // Queue::Shutdown - Shutdown the worker processes /*{{{*/
674 // ---------------------------------------------------------------------
675 /* If final is true then all workers are eliminated, otherwise only workers
676 that do not need cleanup are removed */
677 bool pkgAcquire::Queue::Shutdown(bool Final
)
679 // Delete all of the workers
680 pkgAcquire::Worker
**Cur
= &Workers
;
683 pkgAcquire::Worker
*Jnk
= *Cur
;
684 if (Final
== true || Jnk
->GetConf()->NeedsCleanup
== false)
686 *Cur
= Jnk
->NextQueue
;
691 Cur
= &(*Cur
)->NextQueue
;
697 // Queue::FindItem - Find a URI in the item list /*{{{*/
698 // ---------------------------------------------------------------------
700 pkgAcquire::Queue::QItem
*pkgAcquire::Queue::FindItem(string URI
,pkgAcquire::Worker
*Owner
)
702 for (QItem
*I
= Items
; I
!= 0; I
= I
->Next
)
703 if (I
->URI
== URI
&& I
->Worker
== Owner
)
708 // Queue::ItemDone - Item has been completed /*{{{*/
709 // ---------------------------------------------------------------------
710 /* The worker signals this which causes the item to be removed from the
711 queue. If this is the last queue instance then it is removed from the
713 bool pkgAcquire::Queue::ItemDone(QItem
*Itm
)
716 if (Itm
->Owner
->Status
== pkgAcquire::Item::StatFetching
)
717 Itm
->Owner
->Status
= pkgAcquire::Item::StatDone
;
719 if (Itm
->Owner
->QueueCounter
<= 1)
720 Owner
->Dequeue(Itm
->Owner
);
730 // Queue::Cycle - Queue new items into the method /*{{{*/
731 // ---------------------------------------------------------------------
732 /* This locates a new idle item and sends it to the worker. If pipelining
733 is enabled then it keeps the pipe full. */
734 bool pkgAcquire::Queue::Cycle()
736 if (Items
== 0 || Workers
== 0)
740 return _error
->Error("Pipedepth failure");
742 // Look for a queable item
744 while (PipeDepth
< (signed)MaxPipeDepth
)
746 for (; I
!= 0; I
= I
->Next
)
747 if (I
->Owner
->Status
== pkgAcquire::Item::StatIdle
)
750 // Nothing to do, queue is idle.
755 I
->Owner
->Status
= pkgAcquire::Item::StatFetching
;
757 if (Workers
->QueueItem(I
) == false)
764 // Queue::Bump - Fetch any pending objects if we are idle /*{{{*/
765 // ---------------------------------------------------------------------
766 /* This is called when an item in multiple queues is dequeued */
767 void pkgAcquire::Queue::Bump()
772 // AcquireStatus::pkgAcquireStatus - Constructor /*{{{*/
773 // ---------------------------------------------------------------------
775 pkgAcquireStatus::pkgAcquireStatus() : Update(true), MorePulses(false)
780 // AcquireStatus::Pulse - Called periodically /*{{{*/
781 // ---------------------------------------------------------------------
782 /* This computes some internal state variables for the derived classes to
783 use. It generates the current downloaded bytes and total bytes to download
784 as well as the current CPS estimate. */
785 bool pkgAcquireStatus::Pulse(pkgAcquire
*Owner
)
792 // Compute the total number of bytes to fetch
793 unsigned int Unknown
= 0;
794 unsigned int Count
= 0;
795 for (pkgAcquire::ItemCIterator I
= Owner
->ItemsBegin(); I
!= Owner
->ItemsEnd();
799 if ((*I
)->Status
== pkgAcquire::Item::StatDone
)
802 // Totally ignore local items
803 if ((*I
)->Local
== true)
806 TotalBytes
+= (*I
)->FileSize
;
807 if ((*I
)->Complete
== true)
808 CurrentBytes
+= (*I
)->FileSize
;
809 if ((*I
)->FileSize
== 0 && (*I
)->Complete
== false)
813 // Compute the current completion
814 unsigned long ResumeSize
= 0;
815 for (pkgAcquire::Worker
*I
= Owner
->WorkersBegin(); I
!= 0;
816 I
= Owner
->WorkerStep(I
))
817 if (I
->CurrentItem
!= 0 && I
->CurrentItem
->Owner
->Complete
== false)
819 CurrentBytes
+= I
->CurrentSize
;
820 ResumeSize
+= I
->ResumePoint
;
822 // Files with unknown size always have 100% completion
823 if (I
->CurrentItem
->Owner
->FileSize
== 0 &&
824 I
->CurrentItem
->Owner
->Complete
== false)
825 TotalBytes
+= I
->CurrentSize
;
828 // Normalize the figures and account for unknown size downloads
831 if (Unknown
== Count
)
832 TotalBytes
= Unknown
;
834 // Wha?! Is not supposed to happen.
835 if (CurrentBytes
> TotalBytes
)
836 CurrentBytes
= TotalBytes
;
839 struct timeval NewTime
;
840 gettimeofday(&NewTime
,0);
841 if ((NewTime
.tv_sec
- Time
.tv_sec
== 6 && NewTime
.tv_usec
> Time
.tv_usec
) ||
842 NewTime
.tv_sec
- Time
.tv_sec
> 6)
844 double Delta
= NewTime
.tv_sec
- Time
.tv_sec
+
845 (NewTime
.tv_usec
- Time
.tv_usec
)/1000000.0;
847 // Compute the CPS value
851 CurrentCPS
= ((CurrentBytes
- ResumeSize
) - LastBytes
)/Delta
;
852 LastBytes
= CurrentBytes
- ResumeSize
;
853 ElapsedTime
= (unsigned long)Delta
;
857 int fd
= _config
->FindI("APT::Status-Fd",-1);
860 ostringstream status
;
863 long i
= CurrentItems
< TotalItems
? CurrentItems
+ 1 : CurrentItems
;
865 (unsigned long)((TotalBytes
- CurrentBytes
) / CurrentCPS
);
867 // only show the ETA if it makes sense
868 if (ETA
> 0 && ETA
< 172800 /* two days */ )
869 snprintf(msg
,sizeof(msg
), _("Retrieving file %li of %li (%s remaining)"), i
, TotalItems
, TimeToStr(ETA
).c_str());
871 snprintf(msg
,sizeof(msg
), _("Retrieving file %li of %li"), i
, TotalItems
);
875 // build the status str
876 status
<< "dlstatus:" << i
877 << ":" << (CurrentBytes
/float(TotalBytes
)*100.0)
880 write(fd
, status
.str().c_str(), status
.str().size());
886 // AcquireStatus::Start - Called when the download is started /*{{{*/
887 // ---------------------------------------------------------------------
888 /* We just reset the counters */
889 void pkgAcquireStatus::Start()
891 gettimeofday(&Time
,0);
892 gettimeofday(&StartTime
,0);
903 // AcquireStatus::Stop - Finished downloading /*{{{*/
904 // ---------------------------------------------------------------------
905 /* This accurately computes the elapsed time and the total overall CPS. */
906 void pkgAcquireStatus::Stop()
908 // Compute the CPS and elapsed time
909 struct timeval NewTime
;
910 gettimeofday(&NewTime
,0);
912 double Delta
= NewTime
.tv_sec
- StartTime
.tv_sec
+
913 (NewTime
.tv_usec
- StartTime
.tv_usec
)/1000000.0;
915 // Compute the CPS value
919 CurrentCPS
= FetchedBytes
/Delta
;
920 LastBytes
= CurrentBytes
;
921 ElapsedTime
= (unsigned int)Delta
;
924 // AcquireStatus::Fetched - Called when a byte set has been fetched /*{{{*/
925 // ---------------------------------------------------------------------
926 /* This is used to get accurate final transfer rate reporting. */
927 void pkgAcquireStatus::Fetched(unsigned long Size
,unsigned long Resume
)
929 FetchedBytes
+= Size
- Resume
;