Skip to content

Commit

Permalink
Added flag for graceful exit of long-running operations (similar to 9…
Browse files Browse the repository at this point in the history
…5a2b736780bbe22108034bc179da65480c76715 but not installing signaling which I guess should be managed by the app running the lib).
  • Loading branch information
talaviram committed Nov 4, 2024
1 parent 59437dc commit 045f1b1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,10 @@ void mDNS::runMainLoop() {
FD_SET(sockets[isock], &readfs);
}

if (select(nfds, &readfs, 0, 0, 0) >= 0) {
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 100000;
if (select(nfds, &readfs, 0, 0, &timeout) >= 0) {
for (int isock = 0; isock < num_sockets; ++isock) {
if (FD_ISSET(sockets[isock], &readfs)) {
mdns_socket_listen(sockets[isock], buffer.get(), capacity, service_callback, &service_record);
Expand Down Expand Up @@ -902,7 +905,10 @@ void mDNS::runDumpMode(int *sockets, const int num_sockets) {
if (sockets[isock] >= nfds) nfds = sockets[isock] + 1;
FD_SET(sockets[isock], &readfs);
}
if (select(nfds, &readfs, 0, 0, 0) >= 0) {
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 100000;
if (select(nfds, &readfs, 0, 0, &timeout) >= 0) {
for (int isock = 0; isock < num_sockets; ++isock) {
if (FD_ISSET(sockets[isock], &readfs)) {
mdns_socket_listen(sockets[isock], buffer, capacity, dump_callback, 0);
Expand Down

0 comments on commit 045f1b1

Please sign in to comment.