Changes have been pushed for the repository "fawkesrobotics/fawkes".
Clone: https://github.com/fawkesrobotics/fawkes.git Gitweb: https://github.com/fawkesrobotics/fawkes The branch, thofmann/integration-tests has been updated to 3aea5221e1d45886e7e9dbadd28f5cb9191cdfbf (commit) from 47c0560e65c1cb89239d8f6fb9d46f67627e3f13 (commit) https://github.com/fawkesrobotics/fawkes/tree/thofmann/integration-tests Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - *Log* --------------------------------------------------------------- commit 3aea5221e1d45886e7e9dbadd28f5cb9191cdfbf Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> AuthorDate: Fri Mar 20 13:33:34 2020 +0100 Commit: Till Hofmann <hofm...@kbsg.rwth-aachen.de> CommitDate: Fri Mar 20 13:39:06 2020 +0100 netcomm: let avahi thread sleep for a while if creating a client fails Sometimes, creating a client fails, e.g., if the daemon is not available. In that case, instead of directly trying again in the next iteration, let the thread sleep for a while. This avoids the thread to run on 100% CPU because it continuously tries re-creating the client. Fixes #213. https://github.com/fawkesrobotics/fawkes/commit/3aea5221e - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *Summary* ----------------------------------------------------------- src/libs/netcomm/dns-sd/avahi_thread.cpp | 12 ++++++++++-- src/libs/netcomm/dns-sd/avahi_thread.h | 14 ++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) - *Diffs* ------------------------------------------------------------- - *commit* 3aea5221e1d45886e7e9dbadd28f5cb9191cdfbf - - - - - - - - - - Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> Date: Fri Mar 20 13:33:34 2020 +0100 Subject: netcomm: let avahi thread sleep for a while if creating a client fails src/libs/netcomm/dns-sd/avahi_thread.cpp | 12 ++++++++++-- src/libs/netcomm/dns-sd/avahi_thread.h | 14 ++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) _Diff for modified files_: diff --git a/src/libs/netcomm/dns-sd/avahi_thread.cpp b/src/libs/netcomm/dns-sd/avahi_thread.cpp index 94cc66f6b..f8dfb44f4 100644 --- a/src/libs/netcomm/dns-sd/avahi_thread.cpp +++ b/src/libs/netcomm/dns-sd/avahi_thread.cpp @@ -45,6 +45,7 @@ #include <cstdlib> #include <cstring> #include <netdb.h> +#include <thread> namespace fawkes { @@ -57,6 +58,9 @@ namespace fawkes { * @author Tim Niemueller */ +/** Time to wait if creating an avahi client fails. **/ +const std::chrono::seconds AvahiThread::wait_on_init_failure{5}; + /** Constructor. * You can choose whether to announce IPv4 or IPv6 only or both. * If you select both, new service will be created with the "unspecified" @@ -167,6 +171,10 @@ AvahiThread::loop() need_recover = false; avahi_simple_poll_iterate(simple_poll, -1); + } else { + // We failed to create a client, e.g., because the daemon is not running. + // Wait for a while and try again. + std::this_thread::sleep_for(wait_on_init_failure); } } @@ -823,8 +831,8 @@ AvahiThread::browse_callback(AvahiServiceBrowser * b, * the search */ void -AvahiThread::resolve_callback(AvahiServiceResolver *r, - AvahiIfIndex interface, +AvahiThread::resolve_callback(AvahiServiceResolver * r, + AvahiIfIndex interface, AVAHI_GCC_UNUSED AvahiProtocol protocol, AvahiResolverEvent event, const char * name, diff --git a/src/libs/netcomm/dns-sd/avahi_thread.h b/src/libs/netcomm/dns-sd/avahi_thread.h index 4bd5abb48..b9ba2d68e 100644 --- a/src/libs/netcomm/dns-sd/avahi_thread.h +++ b/src/libs/netcomm/dns-sd/avahi_thread.h @@ -33,6 +33,7 @@ #include <netcomm/service_discovery/service_publisher.h> #include <netinet/in.h> +#include <chrono> #include <string> #include <utility> @@ -96,8 +97,8 @@ private: AvahiLookupResultFlags flags, void * instance); - static void resolve_callback(AvahiServiceResolver *r, - AVAHI_GCC_UNUSED AvahiIfIndex interface, + static void resolve_callback(AvahiServiceResolver * r, + AVAHI_GCC_UNUSED AvahiIfIndex interface, AVAHI_GCC_UNUSED AvahiProtocol protocol, AvahiResolverEvent event, const char * name, @@ -185,10 +186,11 @@ private: bool do_erase_browsers; bool do_reset_groups; - AvahiSimplePoll *simple_poll; - AvahiClient * client; - AvahiClientState client_state; - AvahiProtocol service_protocol; + AvahiSimplePoll * simple_poll; + AvahiClient * client; + AvahiClientState client_state; + AvahiProtocol service_protocol; + const static std::chrono::seconds wait_on_init_failure; WaitCondition *init_wc; _______________________________________________ fawkes-commits mailing list fawkes-commits@lists.kbsg.rwth-aachen.de https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits