Skip to content

Device enumeration results incomplete #1328

@dl5mlo

Description

@dl5mlo

In a networked system with multiple ADALM Plutos (some original, some Chinese clones) runing the tezuka firmware
variant, I had problems finding and enumerating all the devices.

Debugging the issue, I found (on libiio-0.25, but 1.0 seems to use similar code) that the interaction with AVAHI was not handled correctly.
In particular, some responses would only arrive after the avahi poll loop had already been quit and where thus missing.

The problem is that while you wait in a for loop for a second for responses, any responses arriving to the current thread
will not be processed and thus do not show up in the results.

The following patch removes that wait loop and the avahi_simple_poll_quit from avahi_browser_cb
and puts it into avahi_resolver_cb instead.

This seems to fix the issue, but probably it should be looked into more closely as it changes the poll loop termination/timeout logic

Best regards,

Mario

--- dns_sd_avahi.c.orig 2025-04-18 13:15:38.089359137 +0200
+++ dns_sd_avahi.c 2025-04-18 13:22:44.442737333 +0200
@@ -146,6 +146,13 @@
}
}
avahi_service_resolver_free(resolver);
+

  •   // If all resolved, terminate main loop.
    
  •   if (adata->d->resolved == adata->d->found) {
    
  •            prm_dbg(params, "Avahi Resolver: All resolved, terminating loop\n");
    
  •            avahi_simple_poll_quit(adata->d->poll);
    
  •    }
    

}

static void avahi_host_resolver(AvahiHostNameResolver *resolver,
@@ -224,11 +231,16 @@
IIO_DEBUG("Avahi Browser : ALL_FOR_NOW Browser : %d, Resolved : %d\n",
ddata->found, ddata->resolved);

  •           /* 200 * 5ms = wait 1 second */
    
  •           /* Removed. You cannot quit the poll loop, resolver
    
  •            * messages may be outstanding and be processed in _this_
    
  •            * thread so nanosleep wont help
    
  •            *200 * 5ms = wait 1 second 
              for (i = 0; ddata->found != ddata->resolved && i <= 200; i++)
                      nanosleep(&ts, NULL);
    
              avahi_simple_poll_quit(ddata->poll);
    
  •           */
              break;
      case AVAHI_BROWSER_FAILURE:
              IIO_DEBUG("Avahi Browser : FAILURE\n");
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions