[akonadi/Applications/18.08] src/core: JobTracker: publish all jobs in the session when first connecting

David Faure null at kde.org
Mon Aug 20 00:31:18 BST 2018


Git commit 2be7318b1e9529d9194cb2c02881c15939e04ac0 by David Faure.
Committed on 19/08/2018 at 23:29.
Pushed by dfaure into branch 'Applications/18.08'.

JobTracker: publish all jobs in the session when first connecting

This way we can use akonadiconsole to track a job being stuck,
which prevents other jobs from executing.

CCMAIL: kde-pim at kde.org, dvratil at kde.org

M  +6    -0    src/core/jobs/job.cpp
M  +1    -0    src/core/jobs/job_p.h
M  +17   -0    src/core/session.cpp
M  +2    -0    src/core/session_p.h

https://commits.kde.org/akonadi/2be7318b1e9529d9194cb2c02881c15939e04ac0

diff --git a/src/core/jobs/job.cpp b/src/core/jobs/job.cpp
index 1270cebca..944c22b9f 100644
--- a/src/core/jobs/job.cpp
+++ b/src/core/jobs/job.cpp
@@ -104,7 +104,12 @@ void JobPrivate::init(QObject *parent)
     } else {
         mParentJob->addSubjob(q);
     }
+    publishJob();
+}
 
+void JobPrivate::publishJob()
+{
+    Q_Q(Job);
     // if there's a job tracker running, tell it about the new job
     if (!s_jobtracker) {
         // Let's only check for the debugging console every 3 seconds, otherwise every single job
@@ -120,6 +125,7 @@ void JobPrivate::init(QObject *parent)
                                                   QStringLiteral("/jobtracker"),
                                                   QStringLiteral("org.freedesktop.Akonadi.JobTracker"),
                                                   KDBusConnectionPool::threadConnection(), nullptr);
+                mSession->d->publishOtherJobs(q);
             } else {
                 s_lastTime.restart();
             }
diff --git a/src/core/jobs/job_p.h b/src/core/jobs/job_p.h
index 31fa4c0e6..4e7231ada 100644
--- a/src/core/jobs/job_p.h
+++ b/src/core/jobs/job_p.h
@@ -56,6 +56,7 @@ public:
     void signalCreationToJobTracker();
     void signalStartedToJobTracker();
     void delayedEmitResult();
+    void publishJob();
     /*
       Returns a string to display in akonadi console's job tracker. E.g. item ID.
      */
diff --git a/src/core/session.cpp b/src/core/session.cpp
index 1466452c8..458bfef75 100644
--- a/src/core/session.cpp
+++ b/src/core/session.cpp
@@ -246,6 +246,23 @@ void SessionPrivate::addJob(Job *job)
     startNext();
 }
 
+void SessionPrivate::publishOtherJobs(Job *thanThisJob)
+{
+    int count = 0;
+    for (const auto& job : queue) {
+        if (job != thanThisJob) {
+            job->d_ptr->publishJob();
+            ++count;
+        }
+    }
+    if (count > 0) {
+        qCDebug(AKONADICORE_LOG) << "published" << count << "pending jobs to the job tracker";
+    }
+    if (currentJob && currentJob != thanThisJob) {
+        currentJob->d_ptr->signalStartedToJobTracker();
+    }
+}
+
 qint64 SessionPrivate::nextTag()
 {
     return theNextTag++;
diff --git a/src/core/session_p.h b/src/core/session_p.h
index fd26ce1a1..1eed74d66 100644
--- a/src/core/session_p.h
+++ b/src/core/session_p.h
@@ -127,6 +127,8 @@ public:
 
     void clear(bool forceReconnect);
 
+    void publishOtherJobs(Job *thanThisJob);
+
     Session *mParent = nullptr;
     SessionThread *mSessionThread = nullptr;
     Connection *connection = nullptr;



More information about the kde-pim mailing list