libzypp 17.36.7

Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
zypp::media::multifetchworker Class Reference
Inheritance diagram for zypp::media::multifetchworker:

## Public Member Functions
| multifetchworker (int no, multifetchrequest &request, const Url &url)
| multifetchworker (const multifetchworker &)=delete
| multifetchworker (multifetchworker &&)=delete
multifetchworker & | operator= (const multifetchworker &)=delete
multifetchworker & | operator= (multifetchworker &&)=delete
| ~multifetchworker () override
void | nextjob ()
void | runjob ()
bool | continueJob ()
bool | recheckChecksum (off_t blockIdx)
void | disableCompetition ()
void | checkdns ()
void | adddnsfd (std::vector< GPollFD > &waitFds)
void | dnsevent (const std::vector< GPollFD > &waitFds)
Public Member Functions inherited from zyppng::CurlMultiPartDataReceiver
virtual | ~CurlMultiPartDataReceiver ()=default
virtual void | notifyErrorCodeChanged ()

## Public Attributes
const int | _workerno
MultiFetchWorkerState | _state = WORKER_STARTING
bool | _competing = false
std::vector< MultiByteHandler::Range > | _blocks
std::vector< off_t > | _rangeToStripeBlock
MultiByteHandler::ProtocolMode | _protocolMode = MultiByteHandler::ProtocolMode::Basic
std::unique_ptr< MultiByteHandler > | _multiByteHandler
off_t | _stripe = 0
size_t | _datasize = 0
double | _starttime = 0
size_t | _datareceived = 0
off_t | _received = 0
double | _avgspeed = 0
double | _maxspeed = 0
double | _sleepuntil = 0

## Private Member Functions
void | run ()
void | stealjob ()
bool | setupHandle ()
MultiByteHandler::Range | rangeFromBlock (off_t blockNo) const
size_t | writefunction (char *ptr, std::optional< off_t > offset, size_t bytes) override
size_t | headerfunction (char *ptr, size_t bytes) override
bool | beginRange (off_t range, std::string &cancelReason) override
bool | finishedRange (off_t range, bool validated, std::string &cancelReason) override
Private Member Functions inherited from zypp::media::MediaCurl
| ZYPP_DECLARE_FLAGS (RequestOptions, RequestOption)
| MediaCurl (const Url &url_r, const Pathname &attach_point_hint_r)
| ~MediaCurl () override
Url | clearQueryString (const Url &url) const
void | attachTo (bool next=false) override
| Call concrete handler to attach the media.
void | releaseFrom (const std::string &ejectDev) override
| Call concrete handler to release the media.
void | getFile (const OnMediaLocation &file) const override
| Call concrete handler to provide file below attach point.
void | getDir (const Pathname &dirname, bool recurse_r) const override
| Call concrete handler to provide directory content (not recursive!) below attach point.
void | getDirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const override
| Call concrete handler to provide a content list of directory on media via retlist.
void | getDirInfo (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const override
| Basically the same as getDirInfo above.
bool | getDoesFileExist (const Pathname &filename) const override
| Repeatedly calls doGetDoesFileExist() until it successfully returns, fails unexpectedly, or user cancels the operation.
virtual bool | doGetDoesFileExist (const Pathname &filename) const
void | disconnectFrom () override
void | getFileCopy (const OnMediaLocation &srcFile, const Pathname &targetFilename) const override
virtual void | doGetFileCopy (const OnMediaLocation &srcFile, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report, RequestOptions options=OPTION_NONE) const
bool | checkAttachPoint (const Pathname &apoint) const override
| Verify if the specified directory as attach point (root) as requires by the particular media handler implementation.
void | checkProtocol (const Url &url) const
| check the url is supported by the curl library
virtual void | setupEasy ()
| initializes the curl easy handle with the data from the url
void | evaluateCurlCode (const zypp::Pathname &filename, CURLcode code, bool timeout) const
| Evaluates a curl return code and throws the right MediaException `filename` Filename being downloaded `code` Code curl returnes `timeout` Whether we reached timeout, which we need to differentiate in case the codes aborted-by-callback or timeout are returned by curl Otherwise we can't differentiate abort from timeout.
void | doGetFileCopyFile (const OnMediaLocation &srcFile, const Pathname &dest, FILE *file, callback::SendReport< DownloadProgressReport > &report, RequestOptions options=OPTION_NONE) const
const char * | curlError () const
void | setCurlError (const char *error)
Private Member Functions inherited from zypp::media::MediaNetworkCommonHandler
| MediaNetworkCommonHandler (const Url &url_r, const Pathname &attach_point_r, const Pathname &urlpath_below_attachpoint_r, const bool does_download_r)
TransferSettings & | settings ()
Url | getFileUrl (const Pathname &filename) const
| concatenate the attach url and the filename to a complete download url
Private Member Functions inherited from zypp::media::MediaHandler
bool | dependsOnParent (MediaAccessId parentId, bool exactIdMatch)
| Check if the current media handler depends on an another handler specified by media access id.
bool | dependsOnParent ()
void | resetParentId ()
| Called in case, where the media manager takes over the destruction of the parent id (e.g.
Pathname | attachPoint () const
| Return the currently used attach point.
void | setAttachPoint (const Pathname &path, bool temp)
| Set a new attach point.
void | setAttachPoint (const AttachPointRef &ref)
| Set a (shared) attach point.
AttachPoint | attachPointHint () const
| Get the actual attach point hint.
void | attachPointHint (const Pathname &path, bool temp)
| Set the attach point hint as specified by the user.
Pathname | createAttachPoint () const
| Try to create a default / temporary attach point.
Pathname | createAttachPoint (const Pathname &attach_root) const
| Try to create a temporary attach point in specified root.
void | removeAttachPoint ()
| Remove unused attach point.
bool | isUseableAttachPoint (const Pathname &path, bool mtab=true) const
| Ask media manager, if the specified path is already used as attach point or if there are another attach points bellow of it.
std::string | mediaSourceName () const
| Get the media source name or an empty string.
void | setMediaSource (const MediaSourceRef &ref)
| Set new media source reference.
AttachedMedia | findAttachedMedia (const MediaSourceRef &media) const
| Ask the media manager if specified media source is already attached.
AttachedMedia | attachedMedia () const
| Returns the attached media.
bool | isSharedMedia () const
| Returns a hint if the media is shared or not.
bool | checkAttached (bool matchMountFs) const
| Check actual mediaSource attachment against the current mount table of the system.
void | forceRelaseAllMedia (bool matchMountFs)
| Call to this function will try to release all media matching the currenlty attached media source, that it is able to find in the mount table.
void | forceRelaseAllMedia (const MediaSourceRef &ref, bool matchMountFs)
| MediaHandler (Url url_r, const Pathname &attach_point_r, Pathname urlpath_below_attachpoint_r, const bool does_download_r)
| If the concrete media handler provides a nonempty attach_point, it must be an existing directory.
virtual | ~MediaHandler ()
| Contolling MediaAccess takes care, that attached media is released prior to deleting this.
bool | downloads () const
| Hint if files are downloaded or not.
std::string | protocol () const
| Protocol hint for MediaAccess.
Url | url () const
| Url used.
void | attach (bool next)
| Use concrete handler to attach the media.
virtual bool | isAttached () const
| True if media is attached.
Pathname | localRoot () const
| Return the local directory that corresponds to medias url, no matter if media isAttached or not.
Pathname | localPath (const Pathname &pathname) const
| Files provided will be available at 'localPath(filename)'.
void | disconnect ()
| Use concrete handler to isconnect media.
void | release (const std::string &ejectDev="")
| Use concrete handler to release the media.
void | provideFile (const OnMediaLocation &file) const
| Use concrete handler to provide file denoted by path below 'localRoot'.
void | provideFileCopy (const OnMediaLocation &srcFile, const Pathname &targetFilename) const
| Call concrete handler to provide a copy of a file under a different place in the file system (usually not under attach point) as a copy.
void | provideDir (const Pathname &dirname) const
| Use concrete handler to provide directory denoted by path below 'localRoot' (not recursive!).
void | provideDirTree (const Pathname &dirname) const
| Use concrete handler to provide directory tree denoted by path below 'localRoot' (recursive!
void | releaseFile (const Pathname &filename) const
| Remove filename below localRoot IFF handler downloads files to the local filesystem.
void | releaseDir (const Pathname &dirname) const
| Remove directory tree below localRoot IFF handler downloads files to the local filesystem.
void | releasePath (const Pathname &pathname) const
| Remove pathname below localRoot IFF handler downloads files to the local filesystem.
void | dirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
| Return content of directory on media via retlist.
void | dirInfo (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const
| Basically the same as dirInfo above.
bool | doesFileExist (const Pathname &filename) const
| check if a file exists
virtual bool | hasMoreDevices ()
| Check if the media has one more device available for attach(true).
virtual void | getDetectedDevices (std::vector< std::string > &devices, unsigned int &index) const
| Fill in a vector of detected ejectable devices and the index of the currently attached device within the vector.
virtual void | precacheFiles (const std::vector< OnMediaLocation > &files)
| Tries to fetch the given files and precaches them.
virtual void | forceEject (const std::string &device)
| Call concrete handler to physically eject the media (i.e.
void | getDirectoryYast (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
| Retrieve and if available scan dirname/directory.yast.
void | getDirectoryYast (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const
| Retrieve and if available scan dirname/directory.yast.

## Private Attributes
multifetchrequest * | _request = nullptr
int | _pass = 0
std::string | _urlbuf
pid_t | _pid = 0
int | _dnspipe = -1
Private Attributes inherited from zypp::media::MediaCurl
CURL * | _curl
curl_slist * | _customHeaders
Private Attributes inherited from zypp::media::MediaNetworkCommonHandler
TransferSettings | _settings
Url | _redirTarget
Private Attributes inherited from zypp::media::MediaHandler
const Url | _url
| Url to handle.
MediaAccessId | _parentId
| Access Id of media handler we depend on.

## Friends
class | multifetchrequest

## Additional Inherited Members
Private Types inherited from zypp::media::MediaCurl
enum | RequestOption { OPTION_NONE = 0x0 , OPTION_RANGE = 0x1 , OPTION_HEAD = 0x02 , OPTION_NO_IFMODSINCE = 0x04 , OPTION_NO_REPORT_START = 0x08 }
Private Types inherited from zypp::media::MediaHandler
using | Ptr = shared_ptr<MediaHandler>
using | constPtr = shared_ptr<const MediaHandler>
Static Private Member Functions inherited from zypp::media::MediaCurl
static void | setCookieFile (const Pathname &)
static int | aliveCallback (void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
| Callback sending just an alive trigger to the UI, without stats (e.g.
static int | progressCallback (void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
| Callback reporting download progress.
static CURL * | progressCallback_getcurl (void *clientp)
static void | resetExpectedFileSize (void *clientp, const ByteCount &expectedFileSize)
| MediaMultiCurl needs to reset the expected filesize in case a metalink file is downloaded otherwise this function should not be called.
Static Private Member Functions inherited from zypp::media::MediaNetworkCommonHandler
static const char * | anonymousIdHeader ()
static const char * | distributionFlavorHeader ()
static const char * | agentString ()
static zypp::Url | findGeoIPRedirect (const zypp::Url &url)
| Rewrites the baseURL to the geoIP target if one is found in the metadata cache, otherwise simply returns the url again.
Static Private Member Functions inherited from zypp::media::MediaHandler
static bool | setAttachPrefix (const Pathname &attach_prefix)
static std::string | getRealPath (const std::string &path)
static Pathname | getRealPath (const Pathname &path)
static bool | checkAttachPoint (const Pathname &apoint, bool empty_dir, bool writeable)
| Verify if the specified directory as attach point (root) using requested checks.

## Detailed Description

Definition at line 142 of file MediaMultiCurl.cc.

## Constructor & Destructor Documentation

## ◆ multifetchworker() [1/3]

zypp::media::multifetchworker::multifetchworker | ( | int | no,
|  | multifetchrequest & | request,
|  | const Url & | url )

Definition at line 442 of file MediaMultiCurl.cc.

## ◆ multifetchworker() [2/3]

zypp::media::multifetchworker::multifetchworker | ( | const multifetchworker & |  | ) |
| delete

## ◆ multifetchworker() [3/3]

zypp::media::multifetchworker::multifetchworker | ( | multifetchworker && |  | ) |
| delete

## ◆ ~multifetchworker()

zypp::media::multifetchworker::~multifetchworker | ( |  | ) |
| override

Definition at line 505 of file MediaMultiCurl.cc.

## Member Function Documentation

## ◆ operator=() [1/2]

multifetchworker & zypp::media::multifetchworker::operator= | ( | const multifetchworker & |  | ) |
| delete

## ◆ operator=() [2/2]

multifetchworker & zypp::media::multifetchworker::operator= | ( | multifetchworker && |  | ) |
| delete

## ◆ nextjob()

void zypp::media::multifetchworker::nextjob | ( |  | ) |

Fetches the next job from the parent request, then calls runjob to execute it

Definition at line 869 of file MediaMultiCurl.cc.

## ◆ runjob()

void zypp::media::multifetchworker::runjob | ( |  | ) |

Fetches all jobs from the currently claimed stripe or calls nextjob() if the current stripe has all blocks marked as FINALIZED

Definition at line 884 of file MediaMultiCurl.cc.

## ◆ continueJob()

bool zypp::media::multifetchworker::continueJob | ( |  | ) |

Continues a running job, only called by the dispatcher if the multibyte handler indicates it has more work to trigger fetching the next range batch

Definition at line 920 of file MediaMultiCurl.cc.

## ◆ recheckChecksum()

bool zypp::media::multifetchworker::recheckChecksum | ( | off_t | blockIdx | ) |

Rechecks the checksum of the given block at blockIdx. The index is relative to the workers blocklist

Definition at line 679 of file MediaMultiCurl.cc.

## ◆ disableCompetition()

void zypp::media::multifetchworker::disableCompetition | ( |  | ) |

Stop all competing workers and set them to WORKER_DISCARD

Definition at line 853 of file MediaMultiCurl.cc.

## ◆ checkdns()

void zypp::media::multifetchworker::checkdns | ( |  | ) |

Starts the dns check

Definition at line 551 of file MediaMultiCurl.cc.

## ◆ adddnsfd()

void zypp::media::multifetchworker::adddnsfd | ( | std::vector< GPollFD > & | waitFds | ) |

Definition at line 629 of file MediaMultiCurl.cc.

## ◆ dnsevent()

void zypp::media::multifetchworker::dnsevent | ( | const std::vector< GPollFD > & | waitFds | ) |

Definition at line 643 of file MediaMultiCurl.cc.

## ◆ run()

void zypp::media::multifetchworker::run | ( |  | ) |
| private

Definition at line 945 of file MediaMultiCurl.cc.

## ◆ stealjob()

void zypp::media::multifetchworker::stealjob | ( |  | ) |
| private

Definition at line 749 of file MediaMultiCurl.cc.

## ◆ setupHandle()

bool zypp::media::multifetchworker::setupHandle | ( |  | ) |
| private

Definition at line 467 of file MediaMultiCurl.cc.

## ◆ rangeFromBlock()

zyppng::CurlMultiPartHandler::Range zypp::media::multifetchworker::rangeFromBlock | ( | off_t | blkNo | ) | const
| private

Calculates the range information for the given blkNo ( actual block index in the request blocklist, NOT the stripe or worker index )

Definition at line 723 of file MediaMultiCurl.cc.

## ◆ writefunction()

size_t zypp::media::multifetchworker::writefunction | ( | char * | ptr,
|  | std::optional< off_t > | offset,
|  | size_t | bytes )
| override private virtual

Data callback func, this is called whenever there is actual data to be written to the file. If offset is set, usually when starting to write a new range, it means to continue to write on the current file pointer position, otherwise seek to the given one.

Implements zyppng::CurlMultiPartDataReceiver.

Definition at line 333 of file MediaMultiCurl.cc.

## ◆ headerfunction()

size_t zypp::media::multifetchworker::headerfunction | ( | char * | ptr,
|  | size_t | bytes )
| override private virtual

Called for all received header data, after it was processed by the CurlMultiPartHandler.

Implements zyppng::CurlMultiPartDataReceiver.

Definition at line 420 of file MediaMultiCurl.cc.

## ◆ beginRange()

bool zypp::media::multifetchworker::beginRange | ( | off_t | range,
|  | std::string & | cancelReason )
| override private virtual

Called everytime a new range is about to be written, returning false from the function will immediately cancel the request and not write anything to the file.

Parameters

  range | The index of the range that is to be started
  cancelReason | Set to indicate why the request was cancelled.

Reimplemented from zyppng::CurlMultiPartDataReceiver.

Definition at line 372 of file MediaMultiCurl.cc.

## ◆ finishedRange()

bool zypp::media::multifetchworker::finishedRange | ( | off_t | range,
|  | bool | validated,
|  | std::string & | cancelReason )
| override private virtual

Called everytime a range was finished, returning false from the function will cancel the request.

Note
  Normally CurlMultiPartHandler will try to finish all ranges before failing even if one of them can not be validated. If the code should cancel early do it via returning false here.

Parameters

  range | The index of the range that was finished
  validated | Indicates of the range data could be validated against its given checksum
  cancelReason | Set to indicate why the request was cancelled.

Reimplemented from zyppng::CurlMultiPartDataReceiver.

Definition at line 388 of file MediaMultiCurl.cc.

## Friends And Related Symbol Documentation

## ◆ multifetchrequest

friend class multifetchrequest
| friend

Definition at line 143 of file MediaMultiCurl.cc.

## Member Data Documentation

## ◆ _workerno

const int zypp::media::multifetchworker::_workerno

Definition at line 190 of file MediaMultiCurl.cc.

## ◆ _state

MultiFetchWorkerState zypp::media::multifetchworker::_state = WORKER_STARTING

Definition at line 192 of file MediaMultiCurl.cc.

## ◆ _competing

bool zypp::media::multifetchworker::_competing = false

Definition at line 193 of file MediaMultiCurl.cc.

## ◆ _blocks

std::vector<MultiByteHandler::Range> zypp::media::multifetchworker::_blocks

Definition at line 195 of file MediaMultiCurl.cc.

## ◆ _rangeToStripeBlock

std::vector<off_t> zypp::media::multifetchworker::_rangeToStripeBlock

Definition at line 196 of file MediaMultiCurl.cc.

## ◆ _protocolMode

MultiByteHandler::ProtocolMode zypp::media::multifetchworker::_protocolMode = MultiByteHandler::ProtocolMode::Basic

Definition at line 198 of file MediaMultiCurl.cc.

## ◆ _multiByteHandler

std::unique_ptr<MultiByteHandler> zypp::media::multifetchworker::_multiByteHandler

Definition at line 199 of file MediaMultiCurl.cc.

## ◆ _stripe

off_t zypp::media::multifetchworker::_stripe = 0

Definition at line 201 of file MediaMultiCurl.cc.

## ◆ _datasize

size_t zypp::media::multifetchworker::_datasize = 0

Definition at line 202 of file MediaMultiCurl.cc.

## ◆ _starttime

double zypp::media::multifetchworker::_starttime = 0

Definition at line 204 of file MediaMultiCurl.cc.

## ◆ _datareceived

size_t zypp::media::multifetchworker::_datareceived = 0

Definition at line 205 of file MediaMultiCurl.cc.

## ◆ _received

off_t zypp::media::multifetchworker::_received = 0

Definition at line 206 of file MediaMultiCurl.cc.

## ◆ _avgspeed

double zypp::media::multifetchworker::_avgspeed = 0

Definition at line 208 of file MediaMultiCurl.cc.

## ◆ _maxspeed

double zypp::media::multifetchworker::_maxspeed = 0

Definition at line 209 of file MediaMultiCurl.cc.

## ◆ _sleepuntil

double zypp::media::multifetchworker::_sleepuntil = 0

Definition at line 211 of file MediaMultiCurl.cc.

## ◆ _request

multifetchrequest* zypp::media::multifetchworker::_request = nullptr
| private

Definition at line 224 of file MediaMultiCurl.cc.

## ◆ _pass

int zypp::media::multifetchworker::_pass = 0
| private

Definition at line 225 of file MediaMultiCurl.cc.

## ◆ _urlbuf

std::string zypp::media::multifetchworker::_urlbuf
| private

Definition at line 226 of file MediaMultiCurl.cc.

## ◆ _pid

pid_t zypp::media::multifetchworker::_pid = 0
| private

Definition at line 228 of file MediaMultiCurl.cc.

## ◆ _dnspipe

int zypp::media::multifetchworker::_dnspipe = -1
| private

Definition at line 229 of file MediaMultiCurl.cc.

The documentation for this class was generated from the following file:

- zypp/media/MediaMultiCurl.cc