summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire.cc
diff options
context:
space:
mode:
authorMichael Vogt <egon@debian-devbox>2012-04-16 19:24:07 +0200
committerMichael Vogt <egon@debian-devbox>2012-04-16 19:24:07 +0200
commit443f5e8a3205162ec6933529c5ca0c95ad3f6941 (patch)
tree3e2da22dcecc8eeaabc1ac5ceac0407a8e3cc25f /apt-pkg/acquire.cc
parent96273866174c54bdb25813633891f29668d43848 (diff)
parentf352743312edeebf666e1c8304cdc4baf457469f (diff)
merge from the expermental2 branch
Diffstat (limited to 'apt-pkg/acquire.cc')
-rw-r--r--apt-pkg/acquire.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index ef120d8e9..5e1419056 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -13,6 +13,8 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#include <config.h>
+
#include <apt-pkg/acquire.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/acquire-worker.h>
@@ -21,8 +23,6 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
-#include <apti18n.h>
-
#include <iostream>
#include <sstream>
#include <stdio.h>
@@ -30,6 +30,8 @@
#include <dirent.h>
#include <sys/time.h>
#include <errno.h>
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
@@ -37,9 +39,9 @@ using namespace std;
// Acquire::pkgAcquire - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* We grab some runtime state from the configuration space */
-pkgAcquire::pkgAcquire() : Queues(0), Workers(0), Configs(0), Log(NULL), ToFetch(0),
+pkgAcquire::pkgAcquire() : LockFD(-1), Queues(0), Workers(0), Configs(0), Log(NULL), ToFetch(0),
Debug(_config->FindB("Debug::pkgAcquire",false)),
- Running(false), LockFD(-1)
+ Running(false)
{
string const Mode = _config->Find("Acquire::Queue-Mode","host");
if (strcasecmp(Mode.c_str(),"host") == 0)
@@ -47,10 +49,10 @@ pkgAcquire::pkgAcquire() : Queues(0), Workers(0), Configs(0), Log(NULL), ToFetch
if (strcasecmp(Mode.c_str(),"access") == 0)
QueueMode = QueueAccess;
}
-pkgAcquire::pkgAcquire(pkgAcquireStatus *Progress) : Queues(0), Workers(0),
+pkgAcquire::pkgAcquire(pkgAcquireStatus *Progress) : LockFD(-1), Queues(0), Workers(0),
Configs(0), Log(Progress), ToFetch(0),
Debug(_config->FindB("Debug::pkgAcquire",false)),
- Running(false), LockFD(-1)
+ Running(false)
{
string const Mode = _config->Find("Acquire::Queue-Mode","host");
if (strcasecmp(Mode.c_str(),"host") == 0)
@@ -764,7 +766,7 @@ void pkgAcquire::Queue::Bump()
// AcquireStatus::pkgAcquireStatus - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgAcquireStatus::pkgAcquireStatus() : Update(true), MorePulses(false)
+pkgAcquireStatus::pkgAcquireStatus() : d(NULL), Update(true), MorePulses(false)
{
Start();
}
@@ -803,7 +805,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
}
// Compute the current completion
- unsigned long ResumeSize = 0;
+ unsigned long long ResumeSize = 0;
for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0;
I = Owner->WorkerStep(I))
if (I->CurrentItem != 0 && I->CurrentItem->Owner->Complete == false)
@@ -842,7 +844,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
else
CurrentCPS = ((CurrentBytes - ResumeSize) - LastBytes)/Delta;
LastBytes = CurrentBytes - ResumeSize;
- ElapsedTime = (unsigned long)Delta;
+ ElapsedTime = (unsigned long long)Delta;
Time = NewTime;
}
@@ -853,8 +855,9 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
char msg[200];
long i = CurrentItems < TotalItems ? CurrentItems + 1 : CurrentItems;
- unsigned long ETA =
- (unsigned long)((TotalBytes - CurrentBytes) / CurrentCPS);
+ unsigned long long ETA = 0;
+ if(CurrentCPS > 0)
+ ETA = (TotalBytes - CurrentBytes) / CurrentCPS;
// only show the ETA if it makes sense
if (ETA > 0 && ETA < 172800 /* two days */ )
@@ -869,7 +872,9 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
<< ":" << (CurrentBytes/float(TotalBytes)*100.0)
<< ":" << msg
<< endl;
- write(fd, status.str().c_str(), status.str().size());
+
+ std::string const dlstatus = status.str();
+ FileFd::Write(fd, dlstatus.c_str(), dlstatus.size());
}
return true;
@@ -910,13 +915,13 @@ void pkgAcquireStatus::Stop()
else
CurrentCPS = FetchedBytes/Delta;
LastBytes = CurrentBytes;
- ElapsedTime = (unsigned int)Delta;
+ ElapsedTime = (unsigned long long)Delta;
}
/*}}}*/
// AcquireStatus::Fetched - Called when a byte set has been fetched /*{{{*/
// ---------------------------------------------------------------------
/* This is used to get accurate final transfer rate reporting. */
-void pkgAcquireStatus::Fetched(unsigned long Size,unsigned long Resume)
+void pkgAcquireStatus::Fetched(unsigned long long Size,unsigned long long Resume)
{
FetchedBytes += Size - Resume;
}