From: Alex Rousskov Date: Thu, 15 Jul 2021 17:20:02 +0000 (-0400) Subject: fixup: Polished AsyncJob API changes X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eeccdaae5d51a1efadbb4133450b3bc59aefc7b9;p=thirdparty%2Fsquid.git fixup: Polished AsyncJob API changes --- diff --git a/src/Downloader.cc b/src/Downloader.cc index c53168aa47..de4038d36c 100644 --- a/src/Downloader.cc +++ b/src/Downloader.cc @@ -82,7 +82,7 @@ Downloader::swanSong() { debugs(33, 6, this); - if (callback_) // job-ending emergencies like noteAbort() or callException() + if (callback_) // job-ending emergencies like handleStopRequest() or callException() callBack(Http::scInternalServerError); if (context_) { diff --git a/src/base/AsyncJob.h b/src/base/AsyncJob.h index ec6fa0d560..db17297f3d 100644 --- a/src/base/AsyncJob.h +++ b/src/base/AsyncJob.h @@ -61,9 +61,11 @@ public: virtual void callEnd(); ///< called right after the called job method /// called when the job throws during an async call virtual void callException(const std::exception &e); - void noteAbort() { mustStop("externally aborted"); } - /// writes the job text representation - std::ostream &print(std::ostream &os) const { return os << id; } + + /// process external request to terminate now (i.e. during this async call) + void handleStopRequest() { mustStop("externally aborted"); } + + const InstanceId id; ///< job identifier protected: // external destruction prohibited to ensure swanSong() is called @@ -72,14 +74,7 @@ protected: const char *stopReason; ///< reason for forcing done() to be true const char *typeName; ///< kid (leaf) class name, for debugging AsyncCall::Pointer inCall; ///< the asynchronous call being handled, if any - const InstanceId id; ///< job identifier }; -inline -std::ostream &operator <<(std::ostream &os, const AsyncJob &job) -{ - return job.print(os); -} - #endif /* SQUID_ASYNC_JOB_H */ diff --git a/src/base/AsyncJobCalls.h b/src/base/AsyncJobCalls.h index 45bce77db1..4e1f303545 100644 --- a/src/base/AsyncJobCalls.h +++ b/src/base/AsyncJobCalls.h @@ -266,12 +266,14 @@ JobWait::cancel(const char *reason) { if (callback_) { callback_->cancel(reason); + // Instead of AsyncJob, the class parameter could be Job. That would // avoid runtime child-to-parent CbcPointer conversion overheads, but // complicate support for Jobs with virtual AsyncJob bases (GCC error: // "pointer to member conversion via virtual base AsyncJob") and also - // cache-log "Job::noteAbort()" which uses a non-existent class name. - CallJobHere(callback_->debugSection, callback_->debugLevel, job_, AsyncJob, noteAbort); + // cache-log "Job::handleStopRequest()" with a non-existent class name. + CallJobHere(callback_->debugSection, callback_->debugLevel, job_, AsyncJob, handleStopRequest); + clear(); } } @@ -284,7 +286,7 @@ JobWait::print(std::ostream &os) const if (callback_) os << callback_->id << "<-"; if (const auto rawJob = job_.get()) - os << *rawJob; // TODO: make AsyncJob::id public + os << rawJob->id; else os << job_; // raw pointer of a gone job may still be useful for triage return os; diff --git a/src/clients/HttpTunneler.cc b/src/clients/HttpTunneler.cc index f4ceb2d2e8..3c99987000 100644 --- a/src/clients/HttpTunneler.cc +++ b/src/clients/HttpTunneler.cc @@ -418,7 +418,7 @@ Http::Tunneler::swanSong() if (requestWritten && tunnelEstablished) { sendSuccess(); } else { - // job-ending emergencies like noteAbort() or callException() + // job-ending emergencies like handleStopRequest() or callException() bailWith(new ErrorState(ERR_GATEWAY_FAILURE, Http::scInternalServerError, request.getRaw(), al)); } assert(!callback);