Akonadi: fix racy code in (MimeType|Resource)::retrieveByNameOrCreate
Summary: If two threads (TA and TB) would call retrieveByNameOrCreate() with a *different* argument (say A and B), TA might acquire the lock to create A, and meanwhile TB will fail the tryLock() and never create B. Solution: lock around lookup+creation, don't use tryLock, simplify code by using QMutexLocker. I found this by reading the code, but indirectly this seems to also fix akonadiserver locking up in mysql queries during akonaditest startup (sometimes), probably because it reduces concurrent querying a bit... Test Plan: ctest, the "Resource synchronization timed out for akonadi_knut_resource_0" errors (that happened approx 30% of the time) are gone. Reviewers: dvratil Reviewed By: dvratil Subscribers: mlaurent, vkrause, kde-pim Tags: #kde_pim Differential Revision: https://phabricator.kde.org/D18888
parent
ff5c5c79
Please register or sign in to comment