diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2012-04-11 13:25:28 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2012-04-11 13:25:28 +0200 |
commit | d68d65ad637526e46ea77ab83e07470d26df15fc (patch) | |
tree | 0873a85635b7940842fa4d31898895f3618155b8 /apt-pkg/acquire-worker.cc | |
parent | 3b4d8136e78b9f2a70431ece4c850861d90e8bb1 (diff) |
use a static FileFd::Write overload to reduce duplication of write()-retry code
Diffstat (limited to 'apt-pkg/acquire-worker.cc')
-rw-r--r-- | apt-pkg/acquire-worker.cc | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index d79b2b16d..77e2fc311 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -433,21 +433,7 @@ bool pkgAcquire::Worker::MediaChange(string Message) << endl; std::string const dlstatus = status.str(); - size_t done = 0; - size_t todo = dlstatus.size(); - errno = 0; - int res = 0; - do - { - res = write(status_fd, dlstatus.c_str() + done, todo); - if (res < 0 && errno == EINTR) - continue; - if (res < 0) - break; - done += res; - todo -= res; - } - while (res > 0 && todo > 0); + FileFd::Write(status_fd, dlstatus.c_str(), dlstatus.size()); } if (Log == 0 || Log->MediaChange(LookupTag(Message,"Media"), @@ -546,17 +532,10 @@ bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item) /* */ bool pkgAcquire::Worker::OutFdReady() { - int Res; - do - { - Res = write(OutFd,OutQueue.c_str(),OutQueue.length()); - } - while (Res < 0 && errno == EINTR); - - if (Res <= 0) + if (FileFd::Write(OutFd,OutQueue.c_str(),OutQueue.length()) == false) return MethodFailure(); - OutQueue.erase(0,Res); + OutQueue.clear(); if (OutQueue.empty() == true) OutReady = false; |