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

Allow control over running it in a separate thread #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ABeltramo
Copy link

First off, thanks for this brilliant library!

A user recently introduced this library into my open source project wolf and everything seems to be working, expect for when it doesn't 😅

A user reported the following exception:

mDNS: Local IPv4 address: 192.168.178.25
mDNS: Local IPv6 address: fd30:854e:2d95:0:e9d:92ff:fe84:f3a9
mDNS: Error: Failed to open any client sockets

I'm not sure what's causing it (any help in debugging that?) but when you throw from your thread I have no way to catch those exceptions from the main thread.
So I've added a simple bool flag to avoid starting that thread automatically and instead do something like:

  std::thread([]() {
    logs::log(logs::info, "Starting mDNS service");
    try {
      // ...
      mdns.startService(false);
    } catch (const std::exception &e) {
      logs::log(logs::error, "mDNS error: {}", e.what());
    }
  }).detach();

To avoid crashing the main application when that fails.

Let me know what you think!

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

Successfully merging this pull request may close these issues.

1 participant