acquire-worker.h
Go to the documentation of this file.
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
/* ######################################################################
Acquire Worker - Worker process manager
Each worker class is associated with exactly one subprocess.
##################################################################### */
/*}}}*/
#ifndef PKGLIB_ACQUIRE_WORKER_H
#define PKGLIB_ACQUIRE_WORKER_H
#include <apt-pkg/acquire.h>
#include <apt-pkg/weakptr.h>
#include <string>
#include <vector>
#include <sys/types.h>
class APT_PUBLIC pkgAcquire::Worker : public WeakPointable
{
void * const d;
friend class pkgAcquire;
protected:
friend class Queue;
Worker *NextQueue;
Worker *NextAcquire;
Queue *OwnerQ;
pkgAcquireStatus *Log;
MethodConfig *Config;
std::string Access;
pid_t Process;
int InFd;
int OutFd;
int PrivSepSocketFd;
int PrivSepSocketFdChild;
bool InReady;
bool OutReady;
bool Debug;
std::vector<std::string> MessageQueue;
std::string OutQueue;
void Construct();
bool ReadMessages();
bool RunMessages();
bool InFdReady();
bool OutFdReady();
bool Capabilities(std::string Message);
bool SendConfiguration();
bool MediaChange(std::string Message);
bool MethodFailure();
void ItemDone();
public:
pkgAcquire::Queue::QItem *CurrentItem;
std::string Status;
bool QueueItem(pkgAcquire::Queue::QItem *Item);
APT_HIDDEN bool ReplyAux(pkgAcquire::ItemDesc const &Item);
bool Start();
void Pulse();
inline const MethodConfig *GetConf() const {return Config;};
Worker(Queue *OwnerQ,MethodConfig *Config,pkgAcquireStatus *Log);
explicit Worker(MethodConfig *Config);
virtual ~Worker();
private:
APT_HIDDEN void PrepareFiles(char const * const caller, pkgAcquire::Queue::QItem const * const Itm);
APT_HIDDEN void HandleFailure(std::vector<pkgAcquire::Item *> const &ItmOwners,
pkgAcquire::MethodConfig *const Config, pkgAcquireStatus *const Log,
std::string const &Message, bool const errTransient, bool const errAuthErr);
};
#endif
acquire.h
WeakPointable
Definition weakptr.h:34
pkgAcquireStatus
A monitor object for downloads controlled by the pkgAcquire class. {{{.
Definition acquire.h:711
pkgAcquire::Item
Represents the process by which a pkgAcquire object should retrieve a file or a collection of files.
Definition acquire-item.h:59
pkgAcquire::Queue
A single download queue in a pkgAcquire object. {{{.
Definition acquire.h:407
pkgAcquire::Worker::Access
std::string Access
The access method to be used by this worker.
Definition acquire-worker.h:84
pkgAcquire::Worker::OutReady
bool OutReady
Set to true if the worker is in a state in which it is legal to send commands to it.
Definition acquire-worker.h:120
pkgAcquire::Worker::ReadMessages
bool ReadMessages()
Retrieve any available messages from the subprocess.
Definition acquire-worker.cc:184
pkgAcquire::Worker::RunMessages
bool RunMessages()
Parse and dispatch pending messages.
Definition acquire-worker.cc:250
pkgAcquire::Worker::OutQueue
std::string OutQueue
Buffers pending writes to the subprocess.
Definition acquire-worker.h:134
pkgAcquire::Worker::OutFdReady
bool OutFdReady()
Send any pending commands to the subprocess.
Definition acquire-worker.cc:985
pkgAcquire::Worker::InFd
int InFd
A file descriptor connected to the standard output of the subprocess.
Definition acquire-worker.h:94
pkgAcquire::Worker::Config
MethodConfig * Config
The configuration of this method. On startup, the target of this pointer is filled in with basic data...
Definition acquire-worker.h:78
pkgAcquire::Worker::QueueItem
bool QueueItem(pkgAcquire::Queue::QItem *Item)
Tell the subprocess to download the given item.
Definition acquire-worker.cc:878
pkgAcquire::Worker::NextAcquire
Worker * NextAcquire
The next link on the Acquire list.
Definition acquire-worker.h:64
pkgAcquire::Worker::Process
pid_t Process
The PID of the subprocess.
Definition acquire-worker.h:87
pkgAcquire::Worker::InFdReady
bool InFdReady()
Read and dispatch any pending messages from the subprocess.
Definition acquire-worker.cc:1007
pkgAcquire::Worker::MediaChange
bool MediaChange(std::string Message)
Handle a 403 Media Change message.
Definition acquire-worker.cc:804
pkgAcquire::Worker::ItemDone
void ItemDone()
Invoked when a fetch job is completed, either successfully or unsuccessfully.
Definition acquire-worker.cc:1055
pkgAcquire::Worker::~Worker
virtual ~Worker()
Clean up this worker.
Definition acquire-worker.cc:76
pkgAcquire::Worker::NextQueue
Worker * NextQueue
The next link on the Queue list.
Definition acquire-worker.h:61
pkgAcquire::Worker::InReady
bool InReady
Set to true if the worker is in a state in which it might generate data or command responses.
Definition acquire-worker.h:113
pkgAcquire::Worker::MethodFailure
bool MethodFailure()
Invoked when the worked process dies unexpectedly.
Definition acquire-worker.cc:1019
pkgAcquire::Worker::OwnerQ
Queue * OwnerQ
The Queue with which this worker is associated.
Definition acquire-worker.h:67
pkgAcquire::Worker::Construct
void Construct()
Common code for the constructor.
Definition acquire-worker.cc:61
pkgAcquire::Worker::Capabilities
bool Capabilities(std::string Message)
Handle a 100 Capabilities response from the subprocess.
Definition acquire-worker.cc:771
pkgAcquire::Worker::Start
bool Start()
Start up the worker and fill in Config.
Definition acquire-worker.cc:94
pkgAcquire::Worker::Log
pkgAcquireStatus * Log
The download progress indicator to which progress messages should be sent.
Definition acquire-worker.h:72
pkgAcquire::Worker::Worker
Worker(Queue *OwnerQ, MethodConfig *Config, pkgAcquireStatus *Log)
Create a new Worker to download files.
Definition acquire-worker.cc:46
pkgAcquire::Worker::GetConf
const MethodConfig * GetConf() const
Definition acquire-worker.h:281
pkgAcquire::Worker::Debug
bool Debug
Definition acquire-worker.h:123
pkgAcquire::Worker::MessageQueue
std::vector< std::string > MessageQueue
The raw text values of messages received from the worker, in sequence.
Definition acquire-worker.h:128
pkgAcquire::Worker::PrivSepSocketFd
int PrivSepSocketFd
The socket to send SCM_RIGHTS message through.
Definition acquire-worker.h:105
pkgAcquire::Worker::CurrentItem
pkgAcquire::Queue::QItem * CurrentItem
The queue entry that is currently being downloaded.
Definition acquire-worker.h:247
pkgAcquire::Worker::Status
std::string Status
The most recent status string received from the subprocess.
Definition acquire-worker.h:252
pkgAcquire::Worker::Pulse
void Pulse()
Update the worker statistics (CurrentSize, TotalSize, etc).
Definition acquire-worker.cc:1041
pkgAcquire::Worker::OutFd
int OutFd
A file descriptor connected to the standard input of the subprocess.
Definition acquire-worker.h:101
pkgAcquire::Worker::SendConfiguration
bool SendConfiguration()
Send a 601 Configuration message (containing the APT configuration) to the subprocess.
Definition acquire-worker.cc:850
pkgAcquire::Log
pkgAcquireStatus * Log
The progress indicator for this download.
Definition acquire.h:155
pkgAcquire::ItemDesc
Represents a single download source from which an item should be downloaded.
Definition acquire.h:391
pkgAcquire::MethodConfig
Information about the properties of a single acquire method. {{{.
Definition acquire.h:644
pkgAcquire::Queue::QItem
A single item placed in this queue.
Definition acquire.h:422