A fetch subprocess.
More...
#include <acquire-worker.h>
|
void * | d |
| dpointer placeholder (for later in case we need it) More...
|
|
A fetch subprocess.
A worker process is responsible for one stage of the fetch. This class encapsulates the communications protocol between the master process and the worker, from the master end.
Each worker is intrinsically placed on two linked lists. The Queue list (maintained in the NextQueue variable) is maintained by the pkgAcquire::Queue class; it represents the set of workers assigned to a particular queue. The Acquire list (maintained in the NextAcquire variable) is maintained by the pkgAcquire class; it represents the set of active workers for a particular pkgAcquire object.
- Todo:
- Like everything else in the Acquire system, this has way too many protected items.
- See Also
- pkgAcqMethod, pkgAcquire::Item, pkgAcquire
Create a new Worker to download files.
- Parameters
-
OwnerQ | The queue into which this worker should be placed. |
Config | A location in which to store information about the fetch method. |
Log | The download progress indicator that should be used to report the progress of this worker. |
Create a new Worker that should just retrieve information about the fetch method.
Nothing in particular forces you to refrain from actually downloading stuff, but the various status callbacks won't be invoked.
- Parameters
-
Config | A location in which to store information about the fetch method. |
virtual pkgAcquire::Worker::~Worker |
( |
| ) |
|
|
virtual |
Clean up this worker.
Closes the file descriptors; if MethodConfig::NeedsCleanup is false, also rudely interrupts the worker with a SIGINT.
bool pkgAcquire::Worker::Capabilities |
( |
std::string |
Message | ) |
|
|
protected |
Handle a 100 Capabilities response from the subprocess.
- Parameters
-
Message | the raw text of the message from the subprocess. |
The message will be parsed and its contents used to fill Config. If Config is NULL, this routine is a NOP.
- Returns
- true.
void pkgAcquire::Worker::Construct |
( |
| ) |
|
|
protected |
Common code for the constructor.
Initializes NextQueue and NextAcquire to NULL; Process, InFd, and OutFd to -1, OutReady and InReady to false, and Debug from _config.
- Returns
- The fetch method configuration.
References Config.
bool pkgAcquire::Worker::InFdReady |
( |
| ) |
|
|
protected |
Read and dispatch any pending messages from the subprocess.
- Returns
- false if the subprocess died unexpectedly while a message was being transmitted.
void pkgAcquire::Worker::ItemDone |
( |
| ) |
|
|
protected |
Invoked when a fetch job is completed, either successfully or unsuccessfully.
Resets the status information for the worker process.
bool pkgAcquire::Worker::MediaChange |
( |
std::string |
Message | ) |
|
|
protected |
Handle a 403 Media Change message.
- Parameters
-
Message | the raw text of the message; the Media field indicates what type of media should be changed, and the Drive field indicates where the media is located. |
Invokes pkgAcquireStatus::MediaChange(Media, Drive) to ask the user to swap disks; informs the subprocess of the result (via 603 Media Changed, with the Failed field set to true if the user cancelled the media change).
bool pkgAcquire::Worker::MethodFailure |
( |
| ) |
|
|
protected |
Invoked when the worked process dies unexpectedly.
Waits for the subprocess to terminate and generates an error if it terminated abnormally, then closes and blanks out all file descriptors. Discards all pending messages from the subprocess.
- Returns
- false.
bool pkgAcquire::Worker::OutFdReady |
( |
| ) |
|
|
protected |
Send any pending commands to the subprocess.
This method will fail if there is no pending output.
- Returns
- true if all commands were succeeded, false if an error occurred (in which case MethodFailure() will be invoked).
void pkgAcquire::Worker::Pulse |
( |
| ) |
|
Update the worker statistics (CurrentSize, TotalSize, etc).
Tell the subprocess to download the given item.
- Parameters
-
Item | the item to queue up. |
- Returns
- true if the item was successfully enqueued.
Queues up a 600 URI Acquire message for the given item to be sent at the next possible moment. Does not flush the output queue.
bool pkgAcquire::Worker::ReadMessages |
( |
| ) |
|
|
protected |
Retrieve any available messages from the subprocess.
The messages are retrieved as in ReadMessages(), and MessageFailure() is invoked if an error occurs; in particular, if the pipe to the subprocess dies unexpectedly while a message is being read.
- Returns
- true if the messages were successfully read, false otherwise.
void WeakPointable::RemoveWeakPointer |
( |
WeakPointable ** |
weakptr | ) |
|
|
inlineinherited |
bool pkgAcquire::Worker::RunMessages |
( |
| ) |
|
|
protected |
bool pkgAcquire::Worker::SendConfiguration |
( |
| ) |
|
|
protected |
Send a 601 Configuration message (containing the APT configuration) to the subprocess.
The APT configuration will be send to the subprocess in a message of the following form:
601 Configuration
Config-Item: Fully-Qualified-Item=Val
Config-Item: Fully-Qualified-Item=Val
...
- Returns
- true if the command was successfully sent, false otherwise.
bool pkgAcquire::Worker::Start |
( |
| ) |
|
Start up the worker and fill in Config.
Reads the first message from the worker, which is assumed to be a 100 Capabilities message.
- Returns
- true if all operations completed successfully.
std::string pkgAcquire::Worker::Access |
|
protected |
The access method to be used by this worker.
- Todo:
- Doesn't this duplicate Config->Access?
The configuration of this method.
On startup, the target of this pointer is filled in with basic data about the method, as reported by the worker.
Referenced by GetConf().
The queue entry that is currently being downloaded.
unsigned long long pkgAcquire::Worker::CurrentSize |
How many bytes of the file have been downloaded.
Zero if the current progress of the file cannot be determined.
void* pkgAcquire::Worker::d |
|
private |
dpointer placeholder (for later in case we need it)
bool pkgAcquire::Worker::Debug |
|
protected |
If true, debugging output will be sent to std::clog.
int pkgAcquire::Worker::InFd |
|
protected |
A file descriptor connected to the standard output of the subprocess.
Used to read messages and data from the subprocess.
bool pkgAcquire::Worker::InReady |
|
protected |
Set to true if the worker is in a state in which it might generate data or command responses.
- Todo:
- Is this right? It's a guess.
The download progress indicator to which progress messages should be sent.
std::vector<std::string> pkgAcquire::Worker::MessageQueue |
|
protected |
The raw text values of messages received from the worker, in sequence.
Worker* pkgAcquire::Worker::NextAcquire |
|
protected |
The next link on the Acquire list.
Worker* pkgAcquire::Worker::NextQueue |
|
protected |
The next link on the Queue list.
- Todo:
- This is always NULL; is it just for future use?
int pkgAcquire::Worker::OutFd |
|
protected |
A file descriptor connected to the standard input of the subprocess.
Used to send commands and configuration data to the subprocess.
std::string pkgAcquire::Worker::OutQueue |
|
protected |
Buffers pending writes to the subprocess.
- Todo:
- Wouldn't a std::dequeue be more appropriate?
bool pkgAcquire::Worker::OutReady |
|
protected |
Set to true if the worker is in a state in which it is legal to send commands to it.
- Todo:
- Is this right?
Queue* pkgAcquire::Worker::OwnerQ |
|
protected |
The Queue with which this worker is associated.
pid_t pkgAcquire::Worker::Process |
|
protected |
The PID of the subprocess.
unsigned long long pkgAcquire::Worker::ResumePoint |
How much of the file was already downloaded prior to starting this worker.
std::string pkgAcquire::Worker::Status |
The most recent status string received from the subprocess.
unsigned long long pkgAcquire::Worker::TotalSize |
The total number of bytes to be downloaded.
Zero if the total size of the final is unknown.
The documentation for this class was generated from the following file: