<table><tr><td style="">jpalecek created this revision.<br />Herald added a project: Frameworks.<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/D19514">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>This is a first take at tackling a problem caused by avahi going out of service -- usually its restart during an upgrade. In the current state, these things happen:</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">kdnssd holds dbus paths of avahi objects that no longer exist. Eventually, it calls methods on those paths, which might or might not exist or designate different objects</li>
<li class="remarkup-list-item">the client won't discover that published addresses/browsing addresses etc. don't work anymore. Ironically (this happens with kopete), the client will get some error message in the moment avahi comes <em>alive</em> again, not when it's going dead</li>
<li class="remarkup-list-item">KDNSSD objects used with this avahi instance stop working, and are unusable in the future
<br /><br />
In this diff, mostly the first problem is tackled. I add a new singleton class, <tt style="background: #ebebeb; font-size: 13px;">AvahiDisconnectListener</tt>, which will provide a signal when avahi goes away. Every KDNSSD object would listen for that signal and perform the necessary cleanup. This means, in this diff, mostly deleting dbus objects and clearing dbus addresses. On top of that, the <tt style="background: #ebebeb; font-size: 13px;">PublicService</tt> class is changed that it reports failure to publish with a <tt style="background: #ebebeb; font-size: 13px;">published(false)</tt> signal, and a <tt style="background: #ebebeb; font-size: 13px;">RemoteService</tt> reports failure with <tt style="background: #ebebeb; font-size: 13px;">resolved(false)</tt>. The latter should be able to restart when convienient with <tt style="background: #ebebeb; font-size: 13px;">resolveAsync</tt>. Other objects are simply left in a consistent, but nonworking state and can't be used anymore, because they lack the signals to signal error, and methods to restart their operations. Looking forward, this patch could be extended by adding aforementioned error signals, or even, providing a much better user experience, automatically restarting normal operation when avahi comes on again. That information is doable in the client, but is tedious and error prone, as it needs listening for DBus <tt style="background: #ebebeb; font-size: 13px;">NameOwnerChanged</tt>, and then correctly wait because Avahi isn't ready for business right away. Also, you need to manage all the race conditions.</li>
</ul></div></div><br /><div><strong>TEST PLAN</strong><div><p>Launch kopete with an (online) Bonjour Account and run</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">WARNING: this stops avahi
# systemctl mask avahi-daemon.socket; systemctl stop avahi-daemon;</pre></div>
<p>kopete should notice immediately that Bonjour isn't online anymore. Ideally, when you restart avahi with</p>
<ol class="remarkup-list">
<li class="remarkup-list-item">systemctl unmask avahi-daemon.socket; systemctl start avahi-daemon
<br /><br />
kopete should make Bonjour online immediately, however that neds more work</li>
</ol></div></div><br /><div><strong>REPOSITORY</strong><div><div>R272 KDNSSD</div></div></div><br /><div><strong>BRANCH</strong><div><div>wip-merged</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D19514">https://phabricator.kde.org/D19514</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/CMakeLists.txt<br />
src/avahi-disconn-handler.cpp<br />
src/avahi-disconn-handler.h<br />
src/avahi-domainbrowser.cpp<br />
src/avahi-publicservice.cpp<br />
src/avahi-publicservice_p.h<br />
src/avahi-remoteservice.cpp<br />
src/avahi-servicebrowser.cpp<br />
src/avahi-servicebrowser_p.h<br />
src/avahi-servicetypebrowser.cpp<br />
src/avahi_listener.cpp<br />
src/avahi_listener_p.h</div></div></div><br /><div><strong>To: </strong>jpalecek<br /><strong>Cc: </strong>kde-frameworks-devel, michaelh, ngraham, bruns<br /></div>