From 7dc822e55421288a0c8a67ea8e85df5c5e50dace Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 2 Nov 2013 23:06:22 -0500 Subject: Remove botched transfer slave threading code This largely resolves Bug 1670 --- kget/slave.cpp | 61 +++++++++++++--------------------------------------------- 1 file changed, 13 insertions(+), 48 deletions(-) (limited to 'kget/slave.cpp') diff --git a/kget/slave.cpp b/kget/slave.cpp index 9aa91810..60933dcd 100644 --- a/kget/slave.cpp +++ b/kget/slave.cpp @@ -24,9 +24,7 @@ * ***************************************************************************/ - #include -#include #include "getfilejob.h" #include "slave.h" @@ -39,6 +37,10 @@ Slave::Slave(Transfer * _parent, const KURL & _src, const KURL & _dest) : TQObject(), TQThread() { + // FIXME + // KGet uses an unconventional threading model that relies on TDEIO slave execution from the main GUI thread + disableThreadPostedEvents(true); + mDebug << ">>>>Entering" << endl; copyjob = NULL; m_src = _src; @@ -57,8 +59,10 @@ void Slave::Op(SlaveCommand _cmd) { mDebugIn << " _cmd = " << _cmd << endl; - if ( !running() ) // start on demand + if ( !running() ) { // start on demand start(); + moveToThread(this); + } mutex.lock(); stack.push(_cmd); @@ -93,8 +97,6 @@ void Slave::InfoMessage(const TQString & _msg) mDebug << "Infor Msg:" << "_msg = " << _msg << endl; } - - void Slave::run() { mDebugIn << endl; @@ -102,89 +104,53 @@ void Slave::run() SlaveCommand cmd; bool running = true; - while (running) + while (running) { - if (!nPendingCommand) + if (!nPendingCommand) { worker.wait(); - switch (cmd = fetch_cmd()) + } + switch (cmd = fetch_cmd()) { case RESTART: - if (copyjob) { - copyjob->kill(true); - copyjob = 0L; - } // fall through case RETR: mDebug << " FETCHED COMMAND RETR" << endl; - assert(!copyjob); - TDEIO::Scheduler::checkSlaveOnHold( true ); - copyjob = new TDEIO::GetFileJob(m_src, m_dest); - Connect(); PostMessage(SLV_RESUMED); break; case RETR_CACHE: mDebug << " FETCHED COMMAND RETR_CACHE" << endl; - assert(!copyjob); - TDEIO::Scheduler::checkSlaveOnHold( true ); - copyjob = new TDEIO::GetFileJob(m_src, m_dest); - copyjob->addMetaData("cache", "cacheonly"); - Connect(); break; case PAUSE: mDebug << " FETCHED COMMAND PAUSE" << endl; - if (copyjob) { - copyjob->kill(true); - copyjob = 0L; - } PostMessage(SLV_PAUSED); break; case KILL: mDebug << " FETCHED COMMAND KILL" << endl; running = false; - if (copyjob) { - copyjob->kill(true); - copyjob = 0L; - } // no message posted break; - + case REMOVE: mDebug << " FETCHED COMMAND REMOVE" << endl; running = false; - if (copyjob) { - copyjob->kill(true); - copyjob = 0L; - } PostMessage(SLV_REMOVED); break; case SCHEDULE: mDebug << " FETCHED COMMAND SCHEDULE" << endl; - if (copyjob) { - copyjob->kill(true); - copyjob = 0L; - } PostMessage(SLV_SCHEDULED); break; case DELAY: mDebug << " FETCHED COMMAND DELAY" << endl; - if (copyjob) { - copyjob->kill(true); - copyjob = 0L; - } PostMessage(SLV_DELAYED); break; case NOOP: mDebug << "FETCHED COMMAND NOOP, i.e. empty stack" << endl; - if (copyjob) { - copyjob->kill(true); - copyjob = 0L; - } running = false; break; @@ -217,7 +183,6 @@ void Slave::Connect() { mDebugIn << endl; - connect(copyjob, TQT_SIGNAL(canceled(TDEIO::Job *)), TQT_SLOT(slotCanceled(TDEIO::Job *))); connect(copyjob, TQT_SIGNAL(connected(TDEIO::Job *)), TQT_SLOT(slotConnected(TDEIO::Job *))); connect(copyjob, TQT_SIGNAL(result(TDEIO::Job *)), TQT_SLOT(slotResult(TDEIO::Job *))); @@ -253,7 +218,7 @@ void Slave::slotConnected(TDEIO::Job *) void Slave::slotResult(TDEIO::Job * job) { mDebugIn << endl; - + assert(copyjob == job); copyjob=0L; TDEIO::Error error=TDEIO::Error(job->error()); -- cgit v1.2.1