libzypp 17.37.10

provideworker.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9
10#include "provideworker.h"
11#include <zypp-core/base/DtorReset>
12#include <zypp-core/AutoDispose.h>
13#include <zypp-core/Url.h>
14#include <zypp-core/Date.h>
15#include <zypp-core/zyppng/pipelines/AsyncResult>
16#include <zypp-core/base/LogControl.h>
17#include <zypp-core/fs/PathInfo.h>
18#include <zypp-core/fs/TmpPath.h>
19#include <zypp-core/zyppng/base/private/threaddata_p.h>
20#include <zypp-core/zyppng/base/AutoDisconnect>
21#include <zypp-core/zyppng/base/EventDispatcher>
22#include <zypp-media/MediaConfig>
23#include <ostream>
24
25#include <zypp-media/ng/private/providedbg_p.h>
26
27#undef ZYPP_BASE_LOGGER_LOGGROUP
28#define ZYPP_BASE_LOGGER_LOGGROUP "ProvideWorker"
29
30 namespace zyppng::worker {
31
32 using namespace zyppng::operators;
33
34 RequestCancelException::RequestCancelException() : zypp::media::MediaException ("Request was cancelled")
35 { }
36
37 ProvideWorker::ProvideWorker(std::string_view workerName) : _workerName(workerName)
38 {
39 // do not change the order of these calls, otherwise showing the threadname does not work
40 // enableLogForwardingMode will initialize the log which would override the current thread name
41 zypp::base::LogControl::instance().enableLogForwardingMode( true );
42 ThreadData::current().setName( workerName );
43
44 // we use a singleshot timer that triggers message handling
45 connect( *_msgAvail, &Timer::sigExpired, *this, &ProvideWorker::messageLoop );
46 _msgAvail->setSingleShot(true);
47
48 // another timer to trigger a delayed shutdown
49 connectFunc( *_delayedShutdown, &Timer::sigExpired, [this]( zyppng::Timer & ) {
50 maybeDelayedShutdown();
51 }, *this );
52 _delayedShutdown->setSingleShot(true);
53 }
54
55 ProvideWorker::~ProvideWorker()
56 { }
57
58 StompFrameStreamRef ProvideWorker::messageStream() const
59 {
60 return _stream;
61 }
62
63 expected<void> ProvideWorker::run( int recv, int send )
64 {
65 // reentry not supported
66 assert ( !_isRunning );
67
68 zypp::DtorReset res( _isRunning );
69 _isRunning = true;
70
71 initLog();
72
73 zypp::OnScopeExit cleanup([&](){
74 _stream.reset();
75 _controlIO.reset();
76 _loop.reset();
77 });
78
79 _controlIO = AsyncDataSource::create();
80 if ( !_controlIO->openFds( { recv }, send ) ) {
81 return expected<void>::error( ZYPP_EXCPT_PTR(zypp::Exception("Failed to open control FDs")) );
82 }
83
84 connect( *_controlIO, &AsyncDataSource::sigReadFdClosed, *this, &ProvideWorker::readFdClosed );
85 connect( *_controlIO, &AsyncDataSource::sigWriteFdClosed, *this, &ProvideWorker::writeFdClosed );
86
87 _stream = StompFrameStream::create( _controlIO );
88
89 return executeHandshake () | and_then( [&]() {
90 AutoDisconnect disC[] = {
91 connect( *_stream, &StompFrameStream::sigMessageReceived, *this, &ProvideWorker::messageReceived ),
92 connect( *_stream, &StompFrameStream::sigInvalidMessageReceived, *this, &ProvideWorker::onInvalidMessageReceived )
93 };
94 _loop->run();
95 if ( _fatalError )
96 return expected<void>::error( _fatalError );
97 return expected<void>::success();
98 });
99 }
100
101 std::deque<ProvideWorkerItemRef> &ProvideWorker::requestQueue()
102 {
103 return _pendingProvides;
104 }
105
106 ProvideWorker::ProvideNotificatioMode ProvideWorker::provNotificationMode() const {
107 return _provNotificationMode;
108 }
109
110 void ProvideWorker::setProvNotificationMode( const ProvideNotificatioMode &provNotificationMode ) {
111 _provNotificationMode = provNotificationMode;
112 }
113
114 void ProvideWorker::initLog()
115 {
116 // by default we log to strErr, if user code wants to change that it can overload this function
117 zypp::base::LogControl::instance().logToStdErr();
118 }
119
120 ProvideWorkerItemRef ProvideWorker::makeItem( ProvideMessage &&spec )
121 {
122 return std::make_shared<ProvideWorkerItem>( std::move(spec) );
123 }
124
125 void ProvideWorker::provideStart(const uint32_t id, const zypp::Url &url, const zypp::filesystem::Pathname &localFile, const zypp::Pathname &stagingFile )
126 {
127 if ( !_stream->sendMessage( ProvideMessage::createProvideStarted ( id
128 , url
129 , localFile.empty () ? std::optional<std::string>() : localFile.asString ()
130 , stagingFile.empty () ? std::optional<std::string>() : stagingFile.asString ()
131 ) ) ) {
132 ERR << "Failed to send ProvideStart message" << std::endl;
133 }
134 }
135
136 void ProvideWorker::provideSuccess(const uint32_t id, bool cacheHit, const zypp::filesystem::Pathname &localFile, const HeaderValueMap extra )
137 {
138 MIL_PRV << "Sending provideSuccess for id " << id << " file " << localFile << std::endl;
139 auto msg = ProvideMessage::createProvideFinished( id ,localFile.asString() ,cacheHit);
140 for ( auto i = extra.beginList (); i != extra.endList(); i++ ) {
141 for ( const auto &val : i->second )
142 msg.addValue( i->first, val );
143 }
144 if ( !_stream->sendMessage( msg ) ) {
145 ERR << "Failed to send ProvideSuccess message" << std::endl;
146 }
147 }
148
149 void ProvideWorker::provideFailed(const uint32_t id, const ProvideMessage::Code code, const std::string &reason, const bool transient, const HeaderValueMap extra )
150 {
151 MIL_PRV << "Sending provideFailed for request " << id << " err: " << reason << std::endl;
152 auto msg = ProvideMessage::createErrorResponse ( id, code, reason, transient );
153 for ( auto i = extra.beginList (); i != extra.endList(); i++ ) {
154 for ( const auto &val : i->second )
155 msg.addValue( i->first, val );
156 }
157 if ( !_stream->sendMessage( msg ) ) {
158 ERR << "Failed to send ProvideFailed message" << std::endl;
159 }
160 }
161
162
163 void ProvideWorker::provideFailed ( const uint32_t id, const ProvideMessage::Code code, const bool transient, const zypp::Exception &e )
164 {
165 zyppng::HeaderValueMap extra;
166 if ( !e.historyEmpty() ) {
167 extra = { { std::string(zyppng::ErrMsgFields::History), { zyppng::HeaderValueMap::Value(e.historyAsString()) }} };
168 }
169 provideFailed( id
170 , code
171 , e.asUserString()
172 , transient
173 , extra );
174 }
175
176
177 void ProvideWorker::attachSuccess(const uint32_t id, const std::optional<std::string> &localMountPoint)
178 {
179 MIL_PRV << "Sending attachSuccess for request " << id << std::endl;
180 if ( !_stream->sendMessage( ProvideMessage::createAttachFinished ( id, localMountPoint ) ) ) {
181 ERR << "Failed to send AttachFinished message" << std::endl;
182 } else {
183 MIL << "Sent back attach success" << std::endl;
184 }
185 }
186
187 void ProvideWorker::detachSuccess(const uint32_t id)
188 {
189 MIL_PRV << "Sending detachSuccess for request " << id << std::endl;
190 if ( !_stream->sendMessage( ProvideMessage::createDetachFinished ( id ) ) ) {
191 ERR << "Failed to send DetachFinished message" << std::endl;
192 }
193 }
194
195 expected<ProvideMessage> ProvideWorker::sendAndWaitForResponse( const ProvideMessage &request , const std::vector<uint> &responseCodes )
196 {
197 // make sure immediateShutdown is not called while we are blocking here
198 zypp::DtorReset delayedReset( _inControllerRequest );
199 _inControllerRequest = true;
200
201 if ( !_stream->sendMessage( request ) )
202 return expected<ProvideMessage>::error( ZYPP_EXCPT_PTR(zypp::Exception("Failed to send message")) );
203
204 // flush the io device, this will block until all bytes are written
205 _controlIO->flush();
206
207 while ( !_fatalError ) {
208
209 const auto &msg = _stream->nextMessageWait() | [&]( auto &&nextMessage ) {
210 if ( !nextMessage ) {
211 if ( _fatalError )
212 return expected<zypp::PluginFrame>::error( _fatalError );
213 else
214 return expected<zypp::PluginFrame>::error( ZYPP_EXCPT_PTR(zypp::Exception("Failed to wait for response")) );
215 }
216 return expected<zypp::PluginFrame>::success( std::move(*nextMessage) );
217 } | and_then ( [&]( auto && m) {
218 return parseReceivedMessage(m);
219 } );
220
221 if ( !msg ) {
222 ERR << "Failed to receive message" << std::endl;
223 return msg;
224 }
225
226 if ( std::find( responseCodes.begin (), responseCodes.end(), msg->code() ) != responseCodes.end() ) {
227 return msg;
228 }
229
230 // remember other messages for later
231 MIL << "Remembering message for later: " << msg->code () << std::endl;
232 _pendingMessages.push_back(*msg);
233 _msgAvail->start(0);
234 }
235 return expected<ProvideMessage>::error( _fatalError );
236 }
237
238 ProvideWorker::MediaChangeRes ProvideWorker::requestMediaChange(const uint32_t id, const std::string &label, const int32_t mediaNr, const std::vector<std::string> &devices, const std::optional<std::string> &desc )
239 {
240 return sendAndWaitForResponse( ProvideMessage::createMediaChangeRequest ( id, label, mediaNr, devices, desc ), { ProvideMessage::Code::MediaChanged, ProvideMessage::Code::MediaChangeAbort, ProvideMessage::Code::MediaChangeSkip } )
241 | [&]( expected<ProvideMessage> &&m ) {
242 if ( !m ) {
243 MIL << "Failed to wait for message, aborting the request " << std::endl;
244 return ProvideWorker::MediaChangeRes::ABORT;
245 }
246 MIL << "Wait finished, with messages still pending: " << this->_pendingMessages.size() << " and provs still pending: " << this->_pendingProvides.size() << std::endl;
247 if ( m->code() == ProvideMessage::Code::MediaChanged )
248 return ProvideWorker::MediaChangeRes::SUCCESS;
249 else if ( m->code() == ProvideMessage::Code::MediaChangeSkip )
250 return ProvideWorker::MediaChangeRes::SKIP;
251 else
252 return ProvideWorker::MediaChangeRes::ABORT;
253 };
254 }
255
256 expected<AuthInfo> ProvideWorker::requireAuthorization( const uint32_t id, const zypp::Url &url, const std::string &lastTriedUsername, const int64_t lastTimestamp, const std::map<std::string, std::string> &extraFields )
257 {
258 return sendAndWaitForResponse( ProvideMessage::createAuthDataRequest( id, url, lastTriedUsername, lastTimestamp, extraFields ), { ProvideMessage::Code::AuthInfo, ProvideMessage::Code::NoAuthData } )
259 | and_then( [&]( ProvideMessage &&m ) {
260 if ( m.code() == ProvideMessage::Code::AuthInfo ) {
261
262 AuthInfo inf;
263 for( const auto &hdr : m.headers () ) {
264 if ( hdr.first == AuthInfoMsgFields::Username ) {
265 inf.username = hdr.second.asString();
266 } else if ( hdr.first == AuthInfoMsgFields::Password ) {
267 inf.password = hdr.second.asString();
268 } else if ( hdr.first == AuthInfoMsgFields::AuthTimestamp ) {
269 inf.last_auth_timestamp = hdr.second.asInt64();
270 } else {
271 if ( !hdr.second.isString() ) {
272 ERR << "Ignoring invalid extra value, " << hdr.first << " is not of type string" << std::endl;
273 }
274 inf.extraKeys[hdr.first] = hdr.second.asString();
275 }
276 }
277 return expected<AuthInfo>::success(inf);
278
279 }
280 return expected<AuthInfo>::error( ZYPP_EXCPT_PTR( zypp::media::MediaException("No Auth data")) );
281 });
282 }
283
284 AsyncDataSource &ProvideWorker::controlIO()
285 {
286 return *_controlIO.get();
287 }
288
289 expected<void> ProvideWorker::executeHandshake()
290 {
291 const auto &helo = _stream->nextMessageWait();
292 if ( !helo ) {
293 ERR << "Could not receive a handshake message, aborting" << std::endl;
294 return expected<void>::error( ZYPP_EXCPT_PTR(zypp::Exception("Failed to receive handshake message")) );;
295 }
296
297 auto exp = _stream->parseMessage<zyppng::worker::Configuration>( *helo );
298 if ( !exp ) {
299 invalidMessageReceived( exp.error() );
300 return expected<void>::error(exp.error());
301 }
302
303 return std::move(*exp) | [&]( auto conf ) {
304
305 _workerConf = std::move(conf);
306
307 auto &mediaConf = zypp::MediaConfig::instance();
308 for( const auto &[key,value] : _workerConf ) {
309 zypp::Url keyUrl( key );
310 if ( keyUrl.getScheme() == "zconfig" && keyUrl.getAuthority() == "main" ) {
311 mediaConf.setConfigValue( keyUrl.getAuthority(), zypp::Pathname(keyUrl.getPathName()).basename(), value );
312 }
313 }
314
315 return initialize( _workerConf ) | and_then([&]( WorkerCaps &&caps ){
316
317 caps.set_worker_name( _workerName.data() );
318
319 caps.set_cfg_flags ( WorkerCaps::Flags(caps.cfg_flags() | WorkerCaps::ZyppLogFormat) );
320 if ( !_stream->sendMessage ( caps ) ) {
321 return expected<void>::error( ZYPP_EXCPT_PTR(zypp::Exception("Failed to send capabilities")) );
322 }
323 return expected<void>::success ();
324 });
325 };
326 }
327
328 void ProvideWorker::messageLoop( Timer & )
329 {
330 if ( _fatalError )
331 return;
332
333 while ( _pendingMessages.size () ) {
334 auto m = _pendingMessages.front ();
335 _pendingMessages.pop_front ();
336 handleSingleMessage(m);
337 }
338
339 if ( !_fatalError && _pendingProvides.size() ) {
340 provide();
341 }
342
343 // keep poking until there are no provides anymore
344 if ( !_fatalError && ( _pendingMessages.size() || ( _pendingProvides.size () && _provNotificationMode == QUEUE_NOT_EMTPY ) ) ) {
345 _msgAvail->start(0);
346 }
347
348 }
349
350 void ProvideWorker::maybeDelayedShutdown()
351 {
352 if ( _inControllerRequest ) {
353 _delayedShutdown->start(0);
354 return;
355 }
356
357 immediateShutdown();
358 _loop->quit ();
359 }
360
361 void ProvideWorker::readFdClosed( uint, AsyncDataSource::ChannelCloseReason )
362 {
363 MIL << "Read FD closed, exiting." << std::endl;
364 maybeDelayedShutdown();
365 }
366
367 void ProvideWorker::writeFdClosed( AsyncDataSource::ChannelCloseReason )
368 {
369 MIL << "Write FD closed, exiting." << std::endl;
370 maybeDelayedShutdown();
371 }
372
373 void ProvideWorker::messageReceived()
374 {
375 while ( auto message = _stream->nextMessage() ) {
376 if ( _fatalError )
377 break;
378 pushSingleMessage(*message);
379 }
380 }
381
382 void ProvideWorker::onInvalidMessageReceived()
383 {
384 invalidMessageReceived( std::exception_ptr() );
385 }
386
387 void ProvideWorker::invalidMessageReceived( std::exception_ptr p )
388 {
389 ERR << "Received a invalid message on the input stream, aborting" << std::endl;
390 if ( p )
391 _fatalError = p;
392 else
393 _fatalError = ZYPP_EXCPT_PTR( InvalidMessageReceivedException() );
394 immediateShutdown();
395 _loop->quit();
396 }
397
398 void ProvideWorker::handleSingleMessage( const ProvideMessage &provide )
399 {
400 const auto code = provide.code();
401 // we only accept requests here
402 if ( code >= ProvideMessage::Code::FirstControllerCode && code <= ProvideMessage::Code::LastControllerCode ) {
403
404 MIL_PRV << "Received request: " << code << std::endl;
405
406 if ( code == ProvideMessage::Code::Cancel ) {
407 const auto &i = std::find_if( _pendingProvides.begin (), _pendingProvides.end(), [ id = provide.requestId() ]( const auto &it ){ return it->_spec.requestId() == id; } );
408 if ( i != _pendingProvides.end() ) {
409 switch ( (*i)->_state ) {
410 case ProvideWorkerItem::Pending:
411 _stream->sendMessage ( ProvideMessage::createErrorResponse ( provide.requestId (), ProvideMessage::Code::Cancelled, "Cancelled by user." ) );
412 _pendingProvides.erase(i);
413 break;
414 case ProvideWorkerItem::Running:
415 cancel(i);
416 break;
417 case ProvideWorkerItem::Finished:
418 break;
419 }
420 MIL << "Received Cancel for unknown request: " << provide.requestId() << ", ignoring!" << std::endl;
421 }
422 return;
423 }
424
425 _pendingProvides.push_back( makeItem (ProvideMessage(provide)) );
426 return;
427 }
428 ERR << "Unsupported request with code: " << code << " received!" << std::endl;
429 }
430
431 void ProvideWorker::pushSingleMessage( const zypp::PluginFrame &message )
432 {
433 const auto &handle = [&]( const zypp::PluginFrame &message ){
434 return parseReceivedMessage (message )
435 | and_then( [&]( ProvideMessage &&provide ){
436 _pendingMessages.push_back(provide);
437 _msgAvail->start(0);
438 return expected<void>::success();
439 })
440 | or_else( [&]( std::exception_ptr ) -> expected<void> {
441 return expected<void>::error( ZYPP_EXCPT_PTR( std::invalid_argument(zypp::str::Str()<<"Unknown message received: " << message.command() )) );
442 });
443 };
444
445 const auto &exp = handle( message );
446 if ( !exp ) {
447 try {
448 std::rethrow_exception ( exp.error () );
449 } catch ( const zypp::Exception &e ) {
450 ERR << "Catched exception during message handling: " << e << std::endl;
451 } catch ( const std::exception &e ) {
452 ERR << "Catched exception during message handling: " << e.what()<< std::endl;
453 } catch ( ... ) {
454 ERR << "Unknown Exception during message handling" << std::endl;
455 }
456 }
457 }
458
459 expected<ProvideMessage> ProvideWorker::parseReceivedMessage( const zypp::PluginFrame &m)
460 {
461 auto exp = ProvideMessage::create(m);
462 if ( !exp )
463 invalidMessageReceived( exp.error() );
464 return exp;
465 }
466}
zypp::DtorReset
Assign a vaiable a certain value when going out of scope.
Definition dtorreset.h:50
zypp::Exception
Base class for Exception.
Definition Exception.h:153
zypp::Exception::asUserString
std::string asUserString() const
Translated error message as string suitable for the user.
Definition Exception.cc:131
zypp::Exception::historyAsString
std::string historyAsString() const
The history as string.
Definition Exception.cc:195
zypp::Exception::what
const char * what() const override
Return message string.
Definition Exception.h:322
zypp::Exception::historyEmpty
bool historyEmpty() const
Whether the history list is empty.
Definition Exception.h:273
zypp::MediaConfig::instance
static MediaConfig & instance()
Definition mediaconfig.cc:46
zypp::PluginFrame
Command frame for communication with PluginScript.
Definition PluginFrame.h:42
zypp::PluginFrame::command
const std::string & command() const
Return the frame command.
Definition PluginFrame.cc:439
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::Url::getScheme
std::string getScheme() const
Returns the scheme name of the URL.
Definition Url.cc:551
zypp::Url::getAuthority
std::string getAuthority() const
Returns the encoded authority component of the URL.
Definition Url.cc:559
zypp::Url::getPathName
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
Definition Url.cc:622
zypp::base::LogControl::logToStdErr
void logToStdErr()
Log to std::err.
Definition LogControl.cc:918
zypp::base::LogControl::instance
static LogControl instance()
Singleton access.
Definition LogControl.h:102
zypp::base::LogControl::enableLogForwardingMode
void enableLogForwardingMode(bool enable=true)
Definition LogControl.cc:905
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::filesystem::Pathname::asString
const std::string & asString() const
String representation.
Definition Pathname.h:93
zypp::filesystem::Pathname::basename
std::string basename() const
Return the last component of this path.
Definition Pathname.h:130
zypp::filesystem::Pathname::empty
bool empty() const
Test for an empty path.
Definition Pathname.h:116
zypp::media::MediaException
Just inherits Exception to separate media exceptions.
Definition mediaexception.h:37
zypp::media::MediaException::MediaException
MediaException()
Ctor taking message.
Definition mediaexception.h:42
zyppng::AsyncDataSource
Definition asyncdatasource.h:12
zyppng::AsyncDataSource::sigReadFdClosed
SignalProxy< void(uint, AsyncDataSource::ChannelCloseReason)> sigReadFdClosed()
Definition asyncdatasource.cpp:358
zyppng::AsyncDataSource::create
static Ptr create()
Definition asyncdatasource.cpp:146
zyppng::AsyncDataSource::ChannelCloseReason
ChannelCloseReason
Definition asyncdatasource.h:16
zyppng::AsyncDataSource::sigWriteFdClosed
SignalProxy< void(AsyncDataSource::ChannelCloseReason)> sigWriteFdClosed()
Definition asyncdatasource.cpp:353
zyppng::Base::connectFunc
static auto connectFunc(typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)
Definition base.h:163
zyppng::Base::connect
static auto connect(typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
Definition base.h:142
zyppng::HeaderValueMap
Definition headervaluemap.h:67
zyppng::HeaderValueMap::Value
HeaderValue Value
Definition headervaluemap.h:69
zyppng::HeaderValueMap::beginList
ValueMap::iterator beginList()
Definition headervaluemap.h:164
zyppng::HeaderValueMap::endList
ValueMap::iterator endList()
Definition headervaluemap.h:167
zyppng::InvalidMessageReceivedException
Definition stompframestream.h:36
zyppng::ProvideMessage
Definition providemessage_p.h:521
zyppng::ProvideMessage::createProvideStarted
static ProvideMessage createProvideStarted(const uint32_t reqId, const zypp::Url &url, const std::optional< std::string > &localFilename={}, const std::optional< std::string > &stagingFilename={})
Definition providemessage.cc:458
zyppng::ProvideMessage::createProvideFinished
static ProvideMessage createProvideFinished(const uint32_t reqId, const std::string &localFilename, bool cacheHit)
Definition providemessage.cc:472
zyppng::ProvideMessage::Code
MessageCodes Code
Definition providemessage_p.h:523
zyppng::ProvideMessage::createMediaChangeRequest
static ProvideMessage createMediaChangeRequest(const uint32_t reqId, const std::string &label, int32_t mediaNr, const std::vector< std::string > &devices, const std::optional< std::string > &desc)
Definition providemessage.cc:632
zyppng::ProvideMessage::createAuthDataRequest
static ProvideMessage createAuthDataRequest(const uint32_t reqId, const zypp::Url &effectiveUrl, const std::string &lastTriedUser="", const std::optional< int64_t > &lastAuthTimestamp={}, const std::map< std::string, std::string > &extraValues={})
Definition providemessage.cc:618
zyppng::ProvideMessage::createErrorResponse
static ProvideMessage createErrorResponse(const uint32_t reqId, const Code code, const std::string &reason, bool transient=false)
Definition providemessage.cc:548
zyppng::ProvideMessage::createDetachFinished
static ProvideMessage createDetachFinished(const uint32_t reqId)
Definition providemessage.cc:495
zyppng::ProvideMessage::create
static expected< ProvideMessage > create(const zypp::PluginFrame &message)
Definition providemessage.cc:147
zyppng::ProvideMessage::createAttachFinished
static ProvideMessage createAttachFinished(const uint32_t reqId, const std::optional< std::string > &localMountPoint={})
Definition providemessage.cc:483
zyppng::StompFrameStream::sigInvalidMessageReceived
SignalProxy< void()> sigInvalidMessageReceived()
Definition stompframestream.cc:315
zyppng::StompFrameStream::sigMessageReceived
SignalProxy< void()> sigMessageReceived()
Definition stompframestream.cc:310
zyppng::StompFrameStream::create
static Ptr create(IODevice::Ptr iostr)
Definition stompframestream.h:105
zyppng::Timer
The Timer class provides repetitive and single-shot timers.
Definition timer.h:45
zyppng::Timer::sigExpired
SignalProxy< void(Timer &t)> sigExpired()
This signal is always emitted when the timer expires.
Definition timer.cc:120
zyppng::WorkerCaps::Flags
Flags
Definition providemessage_p.h:387
zyppng::WorkerCaps::ZyppLogFormat
@ ZyppLogFormat
Definition providemessage_p.h:391
zyppng::expected
Definition expected.h:27
zyppng::expected::success
static expected success(ConsParams &&...params)
Definition expected.h:115
zyppng::expected::error
E & error()
Definition expected.h:225
zyppng::worker::ProvideWorkerItem::Pending
@ Pending
Definition provideworker.h:54
zyppng::worker::ProvideWorkerItem::Finished
@ Finished
Definition provideworker.h:56
zyppng::worker::ProvideWorkerItem::Running
@ Running
Definition provideworker.h:55
zyppng::worker::ProvideWorker::_workerName
std::string_view _workerName
Definition provideworker.h:199
zyppng::worker::ProvideWorker::detachSuccess
void detachSuccess(const uint32_t id)
Definition provideworker.cc:187
zyppng::worker::ProvideWorker::immediateShutdown
virtual void immediateShutdown()
Definition provideworker.h:85
zyppng::worker::ProvideWorker::_pendingProvides
std::deque< ProvideWorkerItemRef > _pendingProvides
Definition provideworker.h:210
zyppng::worker::ProvideWorker::handleSingleMessage
void handleSingleMessage(const ProvideMessage &provide)
Definition provideworker.cc:398
zyppng::worker::ProvideWorker::requestMediaChange
MediaChangeRes requestMediaChange(const uint32_t id, const std::string &label, const int32_t mediaNr, const std::vector< std::string > &devices, const std::optional< std::string > &desc={})
Definition provideworker.cc:238
zyppng::worker::ProvideWorker::controlIO
AsyncDataSource & controlIO()
Definition provideworker.cc:284
zyppng::worker::ProvideWorker::ProvideNotificatioMode
ProvideNotificatioMode
Definition provideworker.h:69
zyppng::worker::ProvideWorker::QUEUE_NOT_EMTPY
@ QUEUE_NOT_EMTPY
Definition provideworker.h:71
zyppng::worker::ProvideWorker::messageLoop
void messageLoop(Timer &)
Definition provideworker.cc:328
zyppng::worker::ProvideWorker::attachSuccess
void attachSuccess(const uint32_t id, const std::optional< std::string > &localMountPoint={})
Definition provideworker.cc:177
zyppng::worker::ProvideWorker::_loop
EventLoop::Ptr _loop
Definition provideworker.h:200
zyppng::worker::ProvideWorker::ProvideWorker
ProvideWorker(std::string_view workerName)
Definition provideworker.cc:37
zyppng::worker::ProvideWorker::executeHandshake
expected< void > executeHandshake()
Definition provideworker.cc:289
zyppng::worker::ProvideWorker::_controlIO
AsyncDataSource::Ptr _controlIO
Definition provideworker.h:203
zyppng::worker::ProvideWorker::onInvalidMessageReceived
void onInvalidMessageReceived()
Definition provideworker.cc:382
zyppng::worker::ProvideWorker::provideStart
void provideStart(const uint32_t id, const zypp::Url &url, const zypp::Pathname &localFile, const zypp::Pathname &stagingFile={})
Definition provideworker.cc:125
zyppng::worker::ProvideWorker::messageStream
StompFrameStreamRef messageStream() const
Definition provideworker.cc:58
zyppng::worker::ProvideWorker::cancel
virtual void cancel(const std::deque< ProvideWorkerItemRef >::iterator &request)=0
zyppng::worker::ProvideWorker::_pendingMessages
std::deque< ProvideMessage > _pendingMessages
Definition provideworker.h:209
zyppng::worker::ProvideWorker::writeFdClosed
void writeFdClosed(AsyncDataSource::ChannelCloseReason)
Definition provideworker.cc:367
zyppng::worker::ProvideWorker::MediaChangeRes
MediaChangeRes
Definition provideworker.h:91
zyppng::worker::ProvideWorker::ABORT
@ ABORT
Definition provideworker.h:93
zyppng::worker::ProvideWorker::SKIP
@ SKIP
Definition provideworker.h:94
zyppng::worker::ProvideWorker::SUCCESS
@ SUCCESS
Definition provideworker.h:92
zyppng::worker::ProvideWorker::~ProvideWorker
virtual ~ProvideWorker()
Definition provideworker.cc:55
zyppng::worker::ProvideWorker::pushSingleMessage
void pushSingleMessage(const zypp::PluginFrame &msg)
Definition provideworker.cc:431
zyppng::worker::ProvideWorker::parseReceivedMessage
expected< ProvideMessage > parseReceivedMessage(const zypp::PluginFrame &m)
Definition provideworker.cc:459
zyppng::worker::ProvideWorker::_delayedShutdown
Timer::Ptr _delayedShutdown
Definition provideworker.h:202
zyppng::worker::ProvideWorker::messageReceived
void messageReceived()
Definition provideworker.cc:373
zyppng::worker::ProvideWorker::maybeDelayedShutdown
void maybeDelayedShutdown()
Definition provideworker.cc:350
zyppng::worker::ProvideWorker::_isRunning
bool _isRunning
Definition provideworker.h:198
zyppng::worker::ProvideWorker::provideSuccess
void provideSuccess(const uint32_t id, bool cacheHit, const zypp::Pathname &localFile, const HeaderValueMap extra={})
Definition provideworker.cc:136
zyppng::worker::ProvideWorker::provNotificationMode
ProvideNotificatioMode provNotificationMode() const
Definition provideworker.cc:106
zyppng::worker::ProvideWorker::initLog
virtual void initLog()
Definition provideworker.cc:114
zyppng::worker::ProvideWorker::run
expected< void > run(int recv=STDIN_FILENO, int send=STDOUT_FILENO)
Definition provideworker.cc:63
zyppng::worker::ProvideWorker::makeItem
virtual ProvideWorkerItemRef makeItem(ProvideMessage &&spec)
Definition provideworker.cc:120
zyppng::worker::ProvideWorker::_msgAvail
Timer::Ptr _msgAvail
Definition provideworker.h:201
zyppng::worker::ProvideWorker::setProvNotificationMode
void setProvNotificationMode(const ProvideNotificatioMode &provNotificationMode)
Definition provideworker.cc:110
zyppng::worker::ProvideWorker::_workerConf
ProviderConfiguration _workerConf
Definition provideworker.h:205
zyppng::worker::ProvideWorker::provide
virtual void provide()=0
zyppng::worker::ProvideWorker::provideFailed
void provideFailed(const uint32_t id, const ProvideMessage::Code code, const std::string &reason, const bool transient, const HeaderValueMap extra={})
Definition provideworker.cc:149
zyppng::worker::ProvideWorker::initialize
virtual expected< WorkerCaps > initialize(const Configuration &conf)=0
zyppng::worker::ProvideWorker::readFdClosed
void readFdClosed(uint, AsyncDataSource::ChannelCloseReason)
Definition provideworker.cc:361
zyppng::worker::ProvideWorker::_stream
StompFrameStreamRef _stream
Definition provideworker.h:204
zyppng::worker::ProvideWorker::requestQueue
std::deque< ProvideWorkerItemRef > & requestQueue()
Definition provideworker.cc:101
zyppng::worker::ProvideWorker::_provNotificationMode
ProvideNotificatioMode _provNotificationMode
Definition provideworker.h:196
zyppng::worker::ProvideWorker::_inControllerRequest
bool _inControllerRequest
Definition provideworker.h:197
zyppng::worker::ProvideWorker::requireAuthorization
expected< AuthInfo > requireAuthorization(const uint32_t id, const zypp::Url &url, const std::string &lastTriedUsername="", const int64_t lastTimestamp=-1, const std::map< std::string, std::string > &extraFields={})
Definition provideworker.cc:256
zyppng::worker::ProvideWorker::invalidMessageReceived
void invalidMessageReceived(std::exception_ptr p)
Definition provideworker.cc:387
zyppng::worker::ProvideWorker::sendAndWaitForResponse
expected< ProvideMessage > sendAndWaitForResponse(const ProvideMessage &request, const std::vector< uint > &responseCodes)
Definition provideworker.cc:195
zyppng::worker::ProvideWorker::_fatalError
std::exception_ptr _fatalError
Definition provideworker.h:207
zyppng::worker::RequestCancelException::RequestCancelException
RequestCancelException()
Definition provideworker.cc:34
zypp::media
Definition MediaNetworkRequestExecutor.h:22
zypp::url
Url details namespace.
Definition UrlBase.cc:58
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::OnScopeExit
AutoDispose< void > OnScopeExit
Definition AutoDispose.h:276
zyppng::AuthInfoMsgFields::Password
constexpr std::string_view Password("password")
zyppng::AuthInfoMsgFields::Username
constexpr std::string_view Username("username")
zyppng::AuthInfoMsgFields::AuthTimestamp
constexpr std::string_view AuthTimestamp("auth_timestamp")
zyppng::ErrMsgFields::History
constexpr std::string_view History("history")
zyppng::operators
Definition asyncresult.h:279
zyppng::operators::or_else
auto or_else(Fun &&function)
Definition expected.h:630
zyppng::operators::and_then
auto and_then(Fun &&function)
Definition expected.h:623
zyppng::worker
Definition devicedriver.cc:23
zyppng::worker::Configuration
zyppng::ProviderConfiguration Configuration
Definition provideworker.h:31
zyppng::worker::WorkerCaps
zyppng::WorkerCaps WorkerCaps
Definition provideworker.h:29
providedbg_p.h
MIL_PRV
#define MIL_PRV
Definition providedbg_p.h:35
provideworker.h
zypp::str::Str
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition String.h:213
zyppng::AutoDisconnect
Definition autodisconnect.h:24
zyppng::ThreadData::setName
void setName(T &&name)
Definition threaddata_p.h:18
zyppng::ThreadData::current
static ZYPP_API ThreadData & current()
Definition threaddata.cc:16
zyppng::worker::AuthInfo
Definition provideworker.h:34
zyppng::worker::AuthInfo::username
std::string username
Definition provideworker.h:35
zyppng::worker::AuthInfo::last_auth_timestamp
int64_t last_auth_timestamp
Definition provideworker.h:37
zyppng::worker::AuthInfo::extraKeys
std::map< std::string, std::string > extraKeys
Definition provideworker.h:38
zyppng::worker::AuthInfo::password
std::string password
Definition provideworker.h:36
threaddata_p.h
AutoDispose.h
Date.h
Url.h
ZYPP_EXCPT_PTR
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
Definition Exception.h:463
LogControl.h
MIL
#define MIL
Definition Logger.h:100
ERR
#define ERR
Definition Logger.h:102
PathInfo.h
TmpPath.h