Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit dc4bbdd1 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

IMAP: Fix potential crash when Resource disconnects the SessionPool

When the Resource disconnects the SessionPool at a very specific time -
when the slot connected to SessioPool's connectDone() disconnects the
SessionPool we end up in an inconsistent state since the SessionPool
then proceeds to insert the session into the unusedPool, which
triggers an assert later as no sessions are allowed in internal pools
when SessionPool is offline.
parent 67100044
......@@ -234,6 +234,11 @@ void SessionPool::declareSessionReady(KIMAP::Session *session)
if (!m_initialConnectDone) {
m_initialConnectDone = true;
Q_EMIT connectDone();
// If the slot connected to connectDone() decided to disconnect the SessionPool
// then we must end here, because we expects the pools to be empty now!
if (!m_initialConnectDone) {
return;
}
}
m_connectingPool.removeAll(session);
......@@ -582,12 +587,22 @@ void SessionPool::onSessionDestroyed(QObject *object)
{
//Safety net for bugs that cause dangling session pointers
KIMAP::Session *session = static_cast<KIMAP::Session *>(object);
if (m_unusedPool.contains(session) || m_reservedPool.contains(session) || m_connectingPool.contains(session)) {
qCWarning(IMAPRESOURCE_LOG) << "Session destroyed while still in pool" << session;
bool sessionInPool = false;
if (m_unusedPool.contains(session)) {
qCWarning(IMAPRESOURCE_LOG) << "Session" << object << "destroyed while still in unused pool!";
m_unusedPool.removeAll(session);
sessionInPool = true;
}
if (m_reservedPool.contains(session)) {
qCWarning(IMAPRESOURCE_LOG) << "Session" << object << "destroyed while still in reserved pool!";
m_reservedPool.removeAll(session);
sessionInPool = true;
}
if (m_connectingPool.contains(session)) {
qCWarning(IMAPRESOURCE_LOG) << "Session" << object << "destroyed while still in connecting pool!";
m_connectingPool.removeAll(session);
Q_ASSERT(false);
sessionInPool = true;
}
Q_ASSERT(!sessionInPool);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment