Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock happens when listing devices #299

Closed
tangyanli opened this issue Oct 24, 2023 · 1 comment
Closed

Deadlock happens when listing devices #299

tangyanli opened this issue Oct 24, 2023 · 1 comment

Comments

@tangyanli
Copy link

Hi, Michael:

Describe the bug
This is a rare case. And I discovered it by accident.
When the avahi-daemon is stopped, deadlock happens when listing devices.

To Reproduce
Steps to reproduce the behavior:

  1. Stop avahi-daemon. (I am investigation how the avahi-socket activate the avahi-daemon, so I stop it firstly.)
  2. Run the command "legacy-printer-app devices" for the first time, only the SNMP devices are listed.
  3. Run the command "legacy-printer-app devices" for the second time, deadlock happens.

System Information:

  • OS: Ubuntu22.10
  • Browser: firefox
  • Version: pappl 1.4.x

Additional context
I debug the code, when the avahi-daemon is stopped, the function pappl_dnssd_list() exited without invoking the `_papplDNSSDUnlock'.

_papplDNSSDLock();            ★ get lock

#  ifdef HAVE_MDNSRESPONDER
  pdl_ref = _papplDNSSDInit(NULL);

  _PAPPL_DEBUG("pappl_dnssd_find: pdl_ref=%p (before)\n", pdl_ref);

  if ((error = DNSServiceBrowse(&pdl_ref, kDNSServiceFlagsShareConnection, 0, "_pdl-datastream._tcp", NULL, (DNSServiceBrowseReply)pappl_dnssd_browse_cb, devices)) != kDNSServiceErr_NoError)
  {
    _papplDeviceError(err_cb, err_data, "Unable to create service browser: %s (%d).", _papplDNSSDStrError(error), error);
    cupsArrayDelete(devices);
    return (ret);
  }

  _PAPPL_DEBUG("pappl_dnssd_find: pdl_ref=%p (after)\n", pdl_ref);

#  else
  if ((pdl_ref = avahi_service_browser_new(_papplDNSSDInit(NULL), AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_pdl-datastream._tcp", NULL, 0, pappl_dnssd_browse_cb, devices)) == NULL)
  {
    _papplDeviceError(err_cb, err_data, "Unable to create service browser.");
    cupsArrayDelete(devices);
    return (ret);           ★ exit directly
  }
#  endif // HAVE_MDNSRESPONDER

  _papplDNSSDUnlock();     ☆ Unlock doesn't run
@michaelrsweet
Copy link
Owner

[v1.4.x 7188d72] Add missing unlock to DNS-SD code (Issue #299)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants