]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
Add FrequentNetifUpdate option/directive (#482)
authorzdohnal <zdohnal@redhat.com>
Thu, 15 Sep 2022 14:14:29 +0000 (16:14 +0200)
committerGitHub <noreply@github.com>
Thu, 15 Sep 2022 14:14:29 +0000 (16:14 +0200)
configure.ac
utils/cups-browsed.c
utils/cups-browsed.conf.5
utils/cups-browsed.conf.in

index 0fd6fe7bb095e06355d39c5f18c53e9fcec69e39..5fcab1378b72ed6b7f92d97c37841fed299d7c0f 100644 (file)
@@ -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}
index 056463c89f5041fd3792056351b0e553ce061138..c80dda5584f904376edfa1d0223ab58bbe124bb4 100644 (file)
@@ -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;
index 263f08435c0fc9f8a7fc397485ade3e52e690d07..83c69d9ff81385d3d23fdeb7c06aff1cbb387b59 100644 (file)
@@ -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)
index ffdf83d66337ebb90dc7e50c6e6f4eec2110a75e..6c9612c11ecb3c40530bd0ddaec49077a46ed74c 100644 (file)
@@ -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