<table><tr><td style="">jpalecek created this revision.<br />Herald added a project: Kopete.<br />Herald added a subscriber: kopete-devel.<br />jpalecek requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D18444">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>The code of the BonjourAccount class in Kopete uses synchronous<br />
(blocking) forms of the KDNSSD functions, which is a bad thing. It<br />
would be bad enough in itself, however, in case of these functions it<br />
is even worse because these execute an event loop inside them, which<br />
can itself invoke slots of bonjourAccount, possibly invoking<br />
something non-reentrant, like the disconnect code that deletes KDNSSD<br />
objects (whose functions may still be running up in the call<br />
chain). This can be seen in the backtraces of bugs 216021 265440<br />
301743 304338. You can see the functions<br />
(ie. <tt style="background: #ebebeb; font-size: 13px;">ServiceBrowserPrivate::gotRemoveService</tt>) several times in<br />
them.</p>
<p>Moreover these nested calls can freeze the GUI.</p>
<p>I considered making KDNSSD more robust, since it's the KDNSSD code<br />
that usually crashes, but that would still mean the (possibly)<br />
non-reentrant code of Kopete could run nested so this couldn't help<br />
much. This is describe in<br />
<a href="https://bugs.kde.org/show_bug.cgi?id=216021#c7" class="remarkup-link" target="_blank" rel="noreferrer">comment in
Bugzilla</a>. Still, it is a possibility.</p>
<p>The easiest approach is to change BonjourAccount code to use<br />
asynchronous versions of those calls. That way confers several<br />
advantages:</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">no nested event loops</li>
<li class="remarkup-list-item">no GUI freezes</li>
<li class="remarkup-list-item">safe against deletion of the objects involved. The signal-slot connections cease to exist when the objects in question are deleted.</li>
<li class="remarkup-list-item">the async service resolver continues to work after the service is resolved, listening to potential changes (ie. in user name or status)</li>
</ul>
<p>FIXES: 216021<br />
FIXES: 265440<br />
FIXES: 301743<br />
FIXES: 304338</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R434 Kopete</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D18444">https://phabricator.kde.org/D18444</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>protocols/bonjour/bonjouraccount.cpp<br />
protocols/bonjour/bonjouraccount.h</div></div></div><br /><div><strong>To: </strong>jpalecek<br /><strong>Cc: </strong>kopete-devel, himanshuvishwakarma, cochise<br /></div>