Changeset View
Changeset View
Standalone View
Standalone View
src/core/scheduler.cpp
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | 123 | for (; it != m_idleSlaves.end(); ++it) { | |||
---|---|---|---|---|---|
124 | if (it.value() == slave) { | 124 | if (it.value() == slave) { | ||
125 | m_idleSlaves.erase(it); | 125 | m_idleSlaves.erase(it); | ||
126 | return true; | 126 | return true; | ||
127 | } | 127 | } | ||
128 | } | 128 | } | ||
129 | return false; | 129 | return false; | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | void SlaveKeeper::clear() | ||||
133 | { | ||||
134 | m_idleSlaves.clear(); | ||||
135 | } | ||||
136 | | ||||
132 | QList<Slave *> SlaveKeeper::allSlaves() const | 137 | QList<Slave *> SlaveKeeper::allSlaves() const | ||
133 | { | 138 | { | ||
134 | return m_idleSlaves.values(); | 139 | return m_idleSlaves.values(); | ||
135 | } | 140 | } | ||
136 | 141 | | |||
137 | void SlaveKeeper::scheduleGrimReaper() | 142 | void SlaveKeeper::scheduleGrimReaper() | ||
138 | { | 143 | { | ||
139 | if (!m_grimTimer.isActive()) { | 144 | if (!m_grimTimer.isActive()) { | ||
▲ Show 20 Lines • Show All 259 Lines • ▼ Show 20 Line(s) | 401 | { | |||
399 | Q_ASSERT(m_maxConnectionsPerHost >= 1); | 404 | Q_ASSERT(m_maxConnectionsPerHost >= 1); | ||
400 | Q_ASSERT(maxSlaves >= maxSlavesPerHost); | 405 | Q_ASSERT(maxSlaves >= maxSlavesPerHost); | ||
401 | m_startJobTimer.setSingleShot(true); | 406 | m_startJobTimer.setSingleShot(true); | ||
402 | connect(&m_startJobTimer, SIGNAL(timeout()), SLOT(startAJob())); | 407 | connect(&m_startJobTimer, SIGNAL(timeout()), SLOT(startAJob())); | ||
403 | } | 408 | } | ||
404 | 409 | | |||
405 | ProtoQueue::~ProtoQueue() | 410 | ProtoQueue::~ProtoQueue() | ||
406 | { | 411 | { | ||
407 | Q_FOREACH (Slave *slave, allSlaves()) { | 412 | // Gather list of all slaves first | ||
413 | const QList<Slave *> slaves = allSlaves(); | ||||
414 | // Clear the idle slaves in the keeper to avoid dangling pointers | ||||
415 | m_slaveKeeper.clear(); | ||||
416 | for (Slave *slave : slaves) { | ||||
408 | // kill the slave process, then remove the interface in our process | 417 | // kill the slave process, then remove the interface in our process | ||
409 | slave->kill(); | 418 | slave->kill(); | ||
410 | slave->deref(); | 419 | slave->deref(); | ||
411 | } | 420 | } | ||
412 | } | 421 | } | ||
413 | 422 | | |||
414 | void ProtoQueue::queueJob(SimpleJob *job) | 423 | void ProtoQueue::queueJob(SimpleJob *job) | ||
415 | { | 424 | { | ||
▲ Show 20 Lines • Show All 702 Lines • ▼ Show 20 Line(s) | 1124 | if (pq) { | |||
1118 | } | 1127 | } | ||
1119 | // in case this was a connected slave... | 1128 | // in case this was a connected slave... | ||
1120 | pq->removeSlave(slave); | 1129 | pq->removeSlave(slave); | ||
1121 | } | 1130 | } | ||
1122 | if (slave == m_slaveOnHold) { | 1131 | if (slave == m_slaveOnHold) { | ||
1123 | m_slaveOnHold = nullptr; | 1132 | m_slaveOnHold = nullptr; | ||
1124 | m_urlOnHold.clear(); | 1133 | m_urlOnHold.clear(); | ||
1125 | } | 1134 | } | ||
1126 | slave->deref(); // Delete slave | 1135 | // can't use slave->deref() here because we need to use deleteLater | ||
1136 | slave->aboutToDelete(); | ||||
1137 | slave->deleteLater(); | ||||
1127 | } | 1138 | } | ||
1128 | 1139 | | |||
1129 | void SchedulerPrivate::putSlaveOnHold(KIO::SimpleJob *job, const QUrl &url) | 1140 | void SchedulerPrivate::putSlaveOnHold(KIO::SimpleJob *job, const QUrl &url) | ||
1130 | { | 1141 | { | ||
1131 | Slave *slave = jobSlave(job); | 1142 | Slave *slave = jobSlave(job); | ||
1132 | //qDebug() << job << url << slave; | 1143 | //qDebug() << job << url << slave; | ||
1133 | slave->disconnect(job); | 1144 | slave->disconnect(job); | ||
1134 | // prevent the fake death of the slave from trying to kill the job again; | 1145 | // prevent the fake death of the slave from trying to kill the job again; | ||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |