[PATCH] Fix ThreadWeaver JobCollection deletion race
robertknight at gmail.com
Wed Mar 26 15:06:51 GMT 2008
The attached patch fixes a couple of problems with deleting
JobCollection / JobSequence jobs in threadweaver which were causing
sporadic failures in threadweaver's DeleteTest and in KDevelop after a
parsing job completed.
Each JobCollection starts a number of JobCollectionJobRunner sub-jobs
which are owned by the JobCollection. The last JobCollectionJobRunner
and collection Job finished after the JobCollection's done() signal had
been emitted. If the JobCollection was after its done() signal had been
emitted and before its child jobs had finished, it would also delete its
JobCollectionJobRunners and crash.
ThreadWeaver's API documentation does not make it clear when it is safe
to delete a Job. The ThreadWeaver tests assume that when the
ThreadWeaver instance emits a jobDone(Job*) signal then it is safe to
delete that job. KDevelop currently listens for a JobSequence's
done(Job*) signal and then starts a timer to delete the Job 100ms or so
in the future. On my system that was not long enough every 20 runs or
so a Job would be deleted while ThreadWeaver was still using it.
I suggest making it explicit that a Job can be safely deleted (with
respect to ThreadWeaver itself) as soon as it emits its done(Job*)
signal. With the attached patch ThreadWeaver conforms to these
Any comments? Okay to commit?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 6865 bytes
Desc: not available
More information about the kde-core-devel