apt: apt-pkg/acquire-worker.h Source File

apt 3.1.4 commandline package manager

acquire-worker.h
Go to the documentation of this file.
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Acquire Worker - Worker process manager
6
7 Each worker class is associated with exactly one subprocess.
8
9 ##################################################################### */
10 /*}}}*/
11
17
18#ifndef PKGLIB_ACQUIRE_WORKER_H
19#define PKGLIB_ACQUIRE_WORKER_H
20
21#include <apt-pkg/acquire.h>
22#include <apt-pkg/weakptr.h>
23
24#include <string>
25#include <vector>
26#include <sys/types.h>
27
47 class APT_PUBLIC pkgAcquire::Worker : public WeakPointable
48{
50 void * const d;
51
52 friend class pkgAcquire;
53
54 protected:
55 friend class Queue;
56
61 Worker *NextQueue;
62
64 Worker *NextAcquire;
65
67 Queue *OwnerQ;
68
72 pkgAcquireStatus *Log;
73
78 MethodConfig *Config;
79
84 std::string Access;
85
87 pid_t Process;
88
94 int InFd;
95
101 int OutFd;
102
105 int PrivSepSocketFd;
106 int PrivSepSocketFdChild;
107
113 bool InReady;
114
120 bool OutReady;
121
123 bool Debug;
124
128 std::vector<std::string> MessageQueue;
129
134 std::string OutQueue;
135
142 void Construct();
143
154 bool ReadMessages();
155
165 bool RunMessages();
166
173 bool InFdReady();
174
182 bool OutFdReady();
183
193 bool Capabilities(std::string Message);
194
211 bool SendConfiguration();
212
224 bool MediaChange(std::string Message);
225
235 bool MethodFailure();
236
242 void ItemDone();
243
244 public:
245
247 pkgAcquire::Queue::QItem *CurrentItem;
248
252 std::string Status;
253
263 bool QueueItem(pkgAcquire::Queue::QItem *Item);
264 APT_HIDDEN bool ReplyAux(pkgAcquire::ItemDesc const &Item);
265
273 bool Start();
274
278 void Pulse();
279
281 inline const MethodConfig *GetConf() const {return Config;};
282
294 Worker(Queue *OwnerQ,MethodConfig *Config,pkgAcquireStatus *Log);
295
306 explicit Worker(MethodConfig *Config);
307
313 virtual ~Worker();
314
315private:
316 APT_HIDDEN void PrepareFiles(char const * const caller, pkgAcquire::Queue::QItem const * const Itm);
317 APT_HIDDEN void HandleFailure(std::vector<pkgAcquire::Item *> const &ItmOwners,
318 pkgAcquire::MethodConfig *const Config, pkgAcquireStatus *const Log,
319 std::string const &Message, bool const errTransient, bool const errAuthErr);
320};
321
323
324#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