After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 653867 - dnssd backend can only find one service
dnssd backend can only find one service
Status: RESOLVED FIXED
Product: libdmapsharing
Classification: Other
Component: General
git master
Other Mac OS
: Normal major
: ---
Assigned To: W. Michael Petullo
W. Michael Petullo
Depends on:
Blocks:
 
 
Reported: 2011-07-02 16:08 UTC by Daniel Svensson
Modified: 2011-07-08 04:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
a hacky proof-of-concept implementation of described solution (12.47 KB, text/x-csrc)
2011-07-03 08:08 UTC, Daniel Svensson
Details

Description Daniel Svensson 2011-07-02 16:08:15 UTC
for some reason i haven't fully isolated yet it seems like the dnssd backend can't resolve anything other than the last service discovered:

** (abraca:74688): DEBUG: dns_service_browse_reply ():  success
** (abraca:74688): DEBUG: adding a service: pulstar
** (abraca:74688): DEBUG: dns_service_browse_reply ():  success
** (abraca:74688): DEBUG: adding a service: pulstar
** (abraca:74688): DEBUG: dns_service_browse_reply ():  success
** (abraca:74688): DEBUG: adding a service: kahless
** (abraca:74688): DEBUG: dns_service_browse_reply ():  success
** (abraca:74688): DEBUG: adding a service: neutronstar
** (abraca:74688): DEBUG: Success processing DNS-SD browse result
** (abraca:74688): DEBUG: dns_service_resolve_reply ():  success
** (abraca:74688): DEBUG: browser_add_service ()
** (abraca:74688): DEBUG: dmap_mdns_browser_resolve ()
** (abraca:74688): DEBUG: server_model.vala:42: neutronstar.local. 0

the last line is the only time the service_added signal is emited.. using dnssd from command line yields:

here's another run with another service being found last, and thus properly added:

** (abraca:74787): DEBUG: dns_service_browse_reply ():  success
** (abraca:74787): DEBUG: adding a service: pulstar
** (abraca:74787): DEBUG: dns_service_browse_reply ():  success
** (abraca:74787): DEBUG: adding a service: pulstar
** (abraca:74787): DEBUG: dns_service_browse_reply ():  success
** (abraca:74787): DEBUG: adding a service: neutronstar
** (abraca:74787): DEBUG: dns_service_browse_reply ():  success
** (abraca:74787): DEBUG: adding a service: kahless
** (abraca:74787): DEBUG: Success processing DNS-SD browse result
** (abraca:74787): DEBUG: dns_service_resolve_reply ():  success
** (abraca:74787): DEBUG: browser_add_service ()
** (abraca:74787): DEBUG: dmap_mdns_browser_resolve ()
** (abraca:74787): DEBUG: server_model.vala:42: kahless.local. 9667
Comment 1 Daniel Svensson 2011-07-02 16:36:16 UTC
It seems like the dnssd-backend processes all browse replies, overwriting the browse structure data with the latest service found each time callback during DNSServiceProcessResult is called. When DNSServiceProcessResult finishes it resolves the service found in the browse structure, which is naturally the last service found.
Comment 2 Daniel Svensson 2011-07-03 07:52:37 UTC
I solved this in my project by simply filling a GSList *backlog with what I call ServiceContext. This is a structure that is created in the browse-reply function and appended to the backlog-list. In the browse-available function this list is populated as the process-results is called. Once done all service contexts are dispatched as resolve-requests and deleted from the list. the requests get this context in their gio-function and the resolve-process-results is run to set the remaining data into the structure. once done each service found emits a signal in the glib main loop and any listener gets its data from the correct thread. Unfortunately my arm is in cast, and I'm short on time so I can't clean this up right now, but I'll attach my mutilated dnssd backend that implements what I described here.
Comment 3 Daniel Svensson 2011-07-03 08:08:10 UTC
Created attachment 191176 [details]
a hacky proof-of-concept implementation of described solution

if nobody adopts this in the near future i might come back in a couple of weeks and fix it good.
Comment 4 W. Michael Petullo 2011-07-04 00:51:13 UTC
The DNS-SD code that used Apple's API gets less attention than the Avahi code, especially on the client side. I would surely appreciate a clean solution.
Comment 5 W. Michael Petullo 2011-07-07 03:42:40 UTC
Okay, I installed Apple's dns_sd library so that I can help with this (I found that Avahi's Apple dns_sd compatibility library does not work quite right; so I went with the more invasive option of building and installing Apple's library). I went ahead and pushed the proposal from comment #3 to Git master after some quick testing. Hopefully I will find some time in the near future to look at this some more so that we can get it cleaned up.
Comment 6 Daniel Svensson 2011-07-07 07:35:17 UTC
Ouch, that wasn't really my idea. I thought the description "a hacky proof-of-concept" was enough to put you off :D

service_result_available_cb does for example leak, throw in a service_context_free at the end there.

Ok.. so now my shitty code is in the tree, with a reference to my name attached to it, so I guess I better start working on a proper version :D
Comment 7 W. Michael Petullo 2011-07-07 13:10:25 UTC
Well, this is Git master after all.
Comment 8 W. Michael Petullo 2011-07-08 04:24:37 UTC
Should be fixed in Git master now.