Review Request: Do not terminate threads

David Faure faure at kde.org
Thu Aug 11 10:41:13 BST 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/102179/#review5623
-----------------------------------------------------------


Good job, this is tricky code indeed. Some comments below.


kio/kio/hostinfo.cpp
<http://git.reviewboard.kde.org/r/102179/#comment5034>

    The interesting question is, what if hostname was already in the m_lookups map?
    
    Either we want to detect this upfront and not create a second request, or we need a "list of requests for a given hostname" in the map.



kio/kio/hostinfo.cpp
<http://git.reviewboard.kde.org/r/102179/#comment5033>

    reviewboard is highlighting quite a number of lines with trailing whitespace



kio/kio/hostinfo.cpp
<http://git.reviewboard.kde.org/r/102179/#comment5035>

    You could also just create the worker on the stack here.



kio/kio/hostinfo.cpp
<http://git.reviewboard.kde.org/r/102179/#comment5036>

    Maybe move nameLookupThread as a member of hostInfoAgentPrivate, to avoid multiplying the global statics (and therefore have more control over order of destruction)? Or does this make no sense?



kio/kio/hostinfo.cpp
<http://git.reviewboard.kde.org/r/102179/#comment5037>

    Ouch, a busy loop.
    
    The standard solution is to use ... yes ... a semaphore :-) I love semaphores.
    
    Acquire the semaphore here, release it in the thread once the worker object has been created.


- David


On Aug. 11, 2011, 9:23 a.m., Albert Astals Cid wrote:
> 
> -----------------------------------------------------------
> 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.
> 
> 
> 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
> -----
> 
>   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/ed4d5f72/attachment.htm>


More information about the kde-core-devel mailing list