From 69de02b94c808973751b26ac6eaada8009ddaeaa Mon Sep 17 00:00:00 2001 From: zdohnal Date: Thu, 15 Sep 2022 16:14:29 +0200 Subject: [PATCH] Add FrequentNetifUpdate option/directive (#482) --- configure.ac | 14 ++++++++++++++ utils/cups-browsed.c | 17 +++++++++++++++-- utils/cups-browsed.conf.5 | 12 ++++++++++++ utils/cups-browsed.conf.in | 9 +++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 0fd6fe7bb..5fcab1378 100644 --- a/configure.ac +++ b/configure.ac @@ -962,6 +962,19 @@ if test x$enable_debug_guards = xyes; then CXXFLAGS="$CXXFLAGS -DDEBUG_GUARDS" fi +# ========================================================= +# Turn on/off network interface updates for each found entry +# ========================================================== +AC_ARG_ENABLE([frequent_netif_update], + [AS_HELP_STRING([--enable-frequent-netif-update], [Enable network interface update after each found entry to prevent network issues])], + [FREQUENT_NETIF_UPDATE=$enableval], + [FREQUENT_NETIF_UPDATE=yes] +) + +AS_IF([test "x$FREQUENT_NETIF_UPDATE" != "xno"], + [AC_DEFINE([FREQUENT_NETIF_UPDATE], [1], [Define whether we want network interface update after each found entry])] +) + # ===================== # Prepare all .in files # ===================== @@ -1044,6 +1057,7 @@ Build configuration: ppdc utilities: ${enable_ppdc_utils} local queue naming for remote CUPS queues: ${REMOTE_CUPS_LOCAL_QUEUE_NAMING} keep generated queues during shutdown: ${SAVING_CREATED_QUEUES} + update network interfaces after each found entry: ${FREQUENT_NETIF_UPDATE} all ipp printer auto-setup: ${enable_auto_setup_all} only driverless auto-setup: ${enable_auto_setup_driverless_only} only local auto-setup: ${enable_auto_setup_local_only} diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c index 056463c89..c80dda558 100644 --- a/utils/cups-browsed.c +++ b/utils/cups-browsed.c @@ -508,6 +508,11 @@ static autoshutdown_inactivity_type_t autoshutdown_on = NO_QUEUES; static guint autoshutdown_exec_id = 0; static const char *default_printer = NULL; static unsigned int notify_lease_duration = 86400; +#ifdef FREQUENT_NETIF_UPDATE +static int FrequentNetifUpdate = 1; +#else +static int FrequentNetifUpdate = 0; +#endif static int debug_stderr = 0; static int debug_logfile = 0; @@ -9625,7 +9630,7 @@ examine_discovered_printer_record(const char *host, or legacy CUPS, needed for the is_local_hostname() function calls. During DNS-SD discovery the update is already done by the Avahi event handler function. */ - if (type == NULL || type[0] == '\0') + if (FrequentNetifUpdate && (type == NULL || type[0] == '\0')) update_netifs(NULL); /* Check if we have already created a queue for the discovered @@ -10032,7 +10037,8 @@ static void resolve_callback(void* arg) { via UUID */ pthread_rwlock_wrlock(&resolvelock); - update_netifs(NULL); + if (FrequentNetifUpdate) + update_netifs(NULL); if ((flags & AVAHI_LOOKUP_RESULT_LOCAL) || !strcasecmp(ifname, "lo") || is_local_hostname(host_name)) { @@ -11980,6 +11986,13 @@ read_configuration (const char *filename) else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") || !strcasecmp(value, "off") || !strcasecmp(value, "0")) AutoClustering = 0; + } else if (!strcasecmp(line, "FrequentNetifUpdate") && value) { + if (!strcasecmp(value, "yes") || !strcasecmp(value, "true") || + !strcasecmp(value, "on") || !strcasecmp(value, "1")) + FrequentNetifUpdate = 1; + else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") || + !strcasecmp(value, "off") || !strcasecmp(value, "0")) + FrequentNetifUpdate = 0; } else if (!strcasecmp(line, "Cluster") && value) { ptr = value; ptr2 = NULL; diff --git a/utils/cups-browsed.conf.5 b/utils/cups-browsed.conf.5 index 263f08435..83c69d9ff 100644 --- a/utils/cups-browsed.conf.5 +++ b/utils/cups-browsed.conf.5 @@ -977,6 +977,18 @@ and doing specific actions when a D-BUS notification comes. NotifLeaseDuration 86400 .fam T .fi +FrequentNetifUpdate turns on/off the network interface update routines +which happen for each found entry, which can slow up cups-browsed significantly +if we are on a network with many shared printers or if we use BrowsePoll to a server +with many queues. Network interface updates after receiving D-BUS notification +from NetworkManager won't be turned off with the directive. The default value +is 'Yes'. +.PP +.nf +.fam C + FrequentNetifUpdate Yes +.fam T +.fi .SH SEE ALSO \fBcups-browsed\fP(8) diff --git a/utils/cups-browsed.conf.in b/utils/cups-browsed.conf.in index ffdf83d66..6c9612c11 100644 --- a/utils/cups-browsed.conf.in +++ b/utils/cups-browsed.conf.in @@ -749,3 +749,12 @@ BrowseRemoteProtocols @BROWSEREMOTEPROTOCOLS@ # and doing specific actions when a D-BUS notification comes. # NotifLeaseDuration 86400 + +# FrequentNetifUpdate turns on/off the network interface update routines +# which happen for each found entry, which can slow up cups-browsed significantly +# if we are on a network with many shared printers or if we use BrowsePoll to a server +# with many queues. Network interface updates after receiving D-BUS notification +# from NetworkManager won't be turned off with the directive. The default value +# is 'Yes'. +# +# FrequentNetifUpdate Yes -- 2.47.3