Blob Blame History Raw
diff --git a/configure.ac b/configure.ac
index c1b108f..e921820 100644
--- a/configure.ac
+++ b/configure.ac
@@ -902,6 +902,16 @@ AC_ARG_WITH([shell],
 )
 AC_DEFINE_UNQUOTED([SHELL], "$with_shell", [Path for a modern shell])
 
+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
 # =====================
@@ -978,6 +988,7 @@ Build configuration:
 	pclm:            ${enable_pclm}
 	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 9971209..79ece21 100644
--- a/utils/cups-browsed.c
+++ b/utils/cups-browsed.c
@@ -490,6 +490,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;
@@ -9700,7 +9705,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
@@ -10100,9 +10105,11 @@ static void resolve_callback(AvahiServiceResolver *r,
     strncpy(ifname, "Unknown", sizeof(ifname) - 1);
   }
 
+  if (FrequentNetifUpdate)
+    update_netifs(NULL);
+
   /* Ignore local queues of the cupsd we are serving for, identifying them
      via UUID */
-  update_netifs(NULL);
   if ((flags & AVAHI_LOOKUP_RESULT_LOCAL) || !strcasecmp(ifname, "lo") ||
       is_local_hostname(host_name)) {
     update_local_printers ();
@@ -11967,6 +11974,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 7e6ee3b..7f60168 100644
--- a/utils/cups-browsed.conf.5
+++ b/utils/cups-browsed.conf.5
@@ -1005,6 +1005,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 ee2f5bf..6866918 100644
--- a/utils/cups-browsed.conf.in
+++ b/utils/cups-browsed.conf.in
@@ -774,3 +774,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