]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
fixup: Polished AsyncJob API changes
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 15 Jul 2021 17:20:02 +0000 (13:20 -0400)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 16 Jul 2021 17:33:09 +0000 (13:33 -0400)
src/Downloader.cc
src/base/AsyncJob.h
src/base/AsyncJobCalls.h
src/clients/HttpTunneler.cc

index c53168aa4795d55317e9728c225130f4e2c66146..de4038d36ca13e8985488ba362df8b7dc885b8f3 100644 (file)
@@ -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_) {
index ec6fa0d560ff5c6a7e84256db4683dd418396d89..db17297f3d7616e7a69b5678406e08c7c753fbb9 100644 (file)
@@ -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<AsyncJob> 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<AsyncJob> id; ///< job identifier
 };
 
-inline
-std::ostream &operator <<(std::ostream &os, const AsyncJob &job)
-{
-    return job.print(os);
-}
-
 #endif /* SQUID_ASYNC_JOB_H */
 
index 45bce77db11cee56aae91308c1ced1d7e7b3ce65..4e1f3035451b42d33e9a43f98831a6224255d75c 100644 (file)
@@ -266,12 +266,14 @@ JobWait<Job>::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<Job>::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;
index f4ceb2d2e8ebbcff7aaeda3e102f6f9740baec39..3c9998700043da0689ea692bc749856645d08aa9 100644 (file)
@@ -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);