Blob Blame History Raw
From 9c1dcee087eee3c57937a223df76757a61dfd046 Mon Sep 17 00:00:00 2001
From: Michael R Sweet <msweet@msweet.org>
Date: Sat, 14 Nov 2020 09:58:12 -0500
Subject: [PATCH] Add --enable-sync-on-close configure option (Issue #37)

---
 CHANGES-OPENPRINTING.md         |  1 +
 conf/cups-files.conf.in         |  2 +-
 config-scripts/cups-defaults.m4 | 10 ++++++++++
 config.h.in                     |  7 +++++++
 configure                       | 17 +++++++++++++++++
 man/cups-files.conf.5           |  3 +--
 scheduler/conf.c                |  4 ++++
 vcnet/config.h                  |  7 +++++++
 xcode/config.h                  |  7 +++++++
 9 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/conf/cups-files.conf.in b/conf/cups-files.conf.in
index 4a78ba615..af11fcce6 100644
--- a/conf/cups-files.conf.in
+++ b/conf/cups-files.conf.in
@@ -7,7 +7,7 @@
 #FatalErrors @CUPS_FATAL_ERRORS@
 
 # Do we call fsync() after writing configuration or status files?
-#SyncOnClose No
+#SyncOnClose @CUPS_SYNC_ON_CLOSE@
 
 # Default user and group for filters/backends/helper programs; this cannot be
 # any user or group that resolves to ID 0 for security reasons...
diff --git a/config-scripts/cups-defaults.m4 b/config-scripts/cups-defaults.m4
index b6051778d..df386b822 100644
--- a/config-scripts/cups-defaults.m4
+++ b/config-scripts/cups-defaults.m4
@@ -137,6 +137,16 @@ else
 fi
 AC_SUBST(CUPS_PAGE_LOG_FORMAT)
 
+dnl Default SyncOnClose
+AC_ARG_ENABLE(sync_on_close, [  --enable-sync-on-close  enable SyncOnClose (off by default)])
+if test "x$enable_sync_on_close" = xyes; then
+	CUPS_SYNC_ON_CLOSE="Yes"
+	AC_DEFINE(CUPS_DEFAULT_SYNC_ON_CLOSE)
+else
+	CUPS_SYNC_ON_CLOSE="No"
+fi
+AC_SUBST(CUPS_SYNC_ON_CLOSE)
+
 dnl Default Browsing
 AC_ARG_ENABLE(browsing, [  --disable-browsing      disable Browsing by default])
 if test "x$enable_browsing" = xno; then
diff --git a/config.h.in b/config.h.in
index 6a197ecc5..6343e6dd0 100644
--- a/config.h.in
+++ b/config.h.in
@@ -101,6 +101,13 @@
 #define CUPS_DEFAULT_MAX_COPIES	9999
 
 
+/*
+ * Default SyncOnClose value...
+ */
+
+#undef CUPS_DEFAULT_SYNC_ON_CLOSE
+
+
 /*
  * Do we have domain socket support, and if so what is the default one?
  */
diff --git a/configure b/configure
index a7e7a825e..ee25f1f24 100755
--- a/configure
+++ b/configure
@@ -642,6 +642,7 @@ CUPS_USER
 CUPS_DEFAULT_SHARED
 CUPS_BROWSE_LOCAL_PROTOCOLS
 CUPS_BROWSING
+CUPS_SYNC_ON_CLOSE
 CUPS_PAGE_LOG_FORMAT
 CUPS_ACCESS_LOG_LEVEL
 CUPS_LOG_LEVEL
@@ -903,6 +904,7 @@ with_fatal_errors
 with_log_level
 with_access_log_level
 enable_page_logging
+enable_sync_on_close
 enable_browsing
 with_local_protocols
 enable_default_shared
@@ -1573,6 +1575,7 @@ Optional Features:
   --disable-systemd       disable systemd support
   --enable-upstart        enable upstart support
   --enable-page-logging   enable page_log by default
+  --enable-sync-on-close  enable SyncOnClose (off by default)
   --disable-browsing      disable Browsing by default
   --disable-default-shared
 			  disable DefaultShared by default
@@ -9459,6 +9462,20 @@ else
 fi
 
 
+# Check whether --enable-sync_on_close was given.
+if test "${enable_sync_on_close+set}" = set; then :
+  enableval=$enable_sync_on_close;
+fi
+
+if test "x$enable_sync_on_close" = xyes; then
+	CUPS_SYNC_ON_CLOSE="Yes"
+	$as_echo "#define CUPS_DEFAULT_SYNC_ON_CLOSE 1" >>confdefs.h
+
+else
+	CUPS_SYNC_ON_CLOSE="No"
+fi
+
+
 # Check whether --enable-browsing was given.
 if test "${enable_browsing+set}" = set; then :
   enableval=$enable_browsing;
diff --git a/man/cups-files.conf.5 b/man/cups-files.conf.5
index b451e2f92..d9b9a63e3 100644
--- a/man/cups-files.conf.5
+++ b/man/cups-files.conf.5
@@ -7,7 +7,7 @@
 .\" Licensed under Apache License v2.0.  See the file "LICENSE" for more
 .\" information.
 .\"
-.TH cups-files.conf 5 "CUPS" "26 April 2019" "Apple Inc."
+.TH cups-files.conf 5 "CUPS" "14 November 2020" "Apple Inc."
 .SH NAME
 cups\-files.conf \- file and directory configuration file for cups
 .SH DESCRIPTION
@@ -211,7 +211,6 @@ The default is "/var/run/cups" or "/etc/cups" depending on the platform.
 Specifies whether the scheduler calls
 .BR fsync (2)
 after writing configuration or state files.
-The default is "No".
 .\"#SystemGroup
 .TP 5
 \fBSystemGroup \fIgroup-name \fR[ ... \fIgroup-name\fR ]
diff --git a/scheduler/conf.c b/scheduler/conf.c
index 839cd6866..8dfebe546 100644
--- a/scheduler/conf.c
+++ b/scheduler/conf.c
@@ -735,7 +735,11 @@ cupsdReadConfiguration(void)
   RootCertDuration         = 300;
   Sandboxing               = CUPSD_SANDBOXING_STRICT;
   StrictConformance        = FALSE;
+#ifdef CUPS_DEFAULT_SYNC_ON_CLOSE
+  SyncOnClose              = TRUE;
+#else
   SyncOnClose              = FALSE;
+#endif /* CUPS_DEFAULT_SYNC_ON_CLOSE */
   Timeout                  = 900;
   WebInterface             = CUPS_DEFAULT_WEBIF;
 
diff --git a/vcnet/config.h b/vcnet/config.h
index 5e105c826..05d36dcfc 100644
--- a/vcnet/config.h
+++ b/vcnet/config.h
@@ -181,6 +181,13 @@ typedef unsigned long useconds_t;
 #define CUPS_DEFAULT_MAX_COPIES 9999
 
 
+/*
+ * Default SyncOnClose value...
+ */
+
+/* #undef CUPS_DEFAULT_SYNC_ON_CLOSE */
+
+
 /*
  * Do we have domain socket support, and if so what is the default one?
  */
diff --git a/xcode/config.h b/xcode/config.h
index 7a3f98aa9..5f8117467 100644
--- a/xcode/config.h
+++ b/xcode/config.h
@@ -102,6 +102,13 @@
 #define CUPS_DEFAULT_MAX_COPIES 9999
 
 
+/*
+ * Default SyncOnClose value...
+ */
+
+/* #undef CUPS_DEFAULT_SYNC_ON_CLOSE */
+
+
 /*
  * Do we have domain socket support, and if so what is the default one?
  */