Review Request: Do not terminate threads
Albert Astals Cid
tsdgeos at terra.es
Thu Aug 11 10:23:11 BST 2011
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/102179/
-----------------------------------------------------------
(Updated Aug. 11, 2011, 9:23 a.m.)
Review request for kdelibs and Dawit Alemayehu.
Changes
-------
Add new patch based on dfaure and thiago's suggestions:
Thiago and I came up with a design like this:
* a single thread that makes async lookups. It's never blocked, it can always
almost immediately read new requests from a queue and start them.
* each request is encapsulated in a class that has the QString
but also a QSemaphore.
* the main thread can block using a timeout (QSemaphore::tryAcquire(timeout))
* the request class is stored using a shared pointer, so that it's only
deleted when neither the main thread nor the worker thread need it anymore
[otherwise the deletion is a problem, in the timeout case vs the normal case]
I hope i did what you guys had in mind :D
Summary
-------
Each time the terminate code triggers my Konqueror crashes, i'm substituting the terminate for just waiting the thread to finish and we just ignoring it.
The code has a race condition in which wait() returns false, then we switch to the thread and m_autoDelete is still not set and thus noone will delete the thread. I can add a mutex if you guys think this is unacceptable.
Diffs (updated)
-----
kio/kio/hostinfo.cpp 344b1d8
Diff: http://git.reviewboard.kde.org/r/102179/diff
Testing
-------
When the
kDebug() << "Name look up for" << hostName << "failed";
if triggers i do not get a crash anymore.
Thanks,
Albert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20110811/1fbca90e/attachment.htm>
More information about the kde-core-devel
mailing list