Blame SOURCES/cups-synconclose.patch

87cf9a
diff -up cups-1.6.3/conf/cups-files.conf.in.synconclose cups-1.6.3/conf/cups-files.conf.in
87cf9a
--- cups-1.6.3/conf/cups-files.conf.in.synconclose	2013-06-07 02:12:52.000000000 +0100
87cf9a
+++ cups-1.6.3/conf/cups-files.conf.in	2013-11-04 11:37:32.063897669 +0000
87cf9a
@@ -8,6 +8,9 @@
87cf9a
 # List of events that are considered fatal errors for the scheduler...
87cf9a
 #FatalErrors @CUPS_FATAL_ERRORS@
87cf9a
 
87cf9a
+# Do we call fsync() after writing configuration or status files?
87cf9a
+#SyncOnClose Yes
87cf9a
+
87cf9a
 # Default user and group for filters/backends/helper programs; this cannot be
87cf9a
 # any user or group that resolves to ID 0 for security reasons...
87cf9a
 #User @CUPS_USER@
87cf9a
diff -up cups-1.6.3/doc/help/ref-cups-files-conf.html.in.synconclose cups-1.6.3/doc/help/ref-cups-files-conf.html.in
87cf9a
--- cups-1.6.3/doc/help/ref-cups-files-conf.html.in.synconclose	2013-05-10 17:52:10.000000000 +0100
87cf9a
+++ cups-1.6.3/doc/help/ref-cups-files-conf.html.in	2013-11-04 11:39:51.104528571 +0000
87cf9a
@@ -437,6 +437,31 @@ to resolve relative paths in the cu
87cf9a
 default server directory is /etc/cups.

87cf9a
 
87cf9a
 
87cf9a
+

CUPS 1.6.4SyncOnClose

87cf9a
+
87cf9a
+

Examples

87cf9a
+
87cf9a
+
87cf9a
+SyncOnClose No
87cf9a
+SyncOnClose Yes
87cf9a
+
87cf9a
+
87cf9a
+

Description

87cf9a
+
87cf9a
+

The SyncOnClose directive determines whether the scheduler

87cf9a
+flushes changes to configuration and state files to disk. The default is
87cf9a
+Yes. The option No relies on the operating
87cf9a
+system to schedule a suitable time to write changes to disk.

87cf9a
+
87cf9a
+
Note:
87cf9a
+
87cf9a
+

Setting SyncOnClose to Yes makes the scheduler use the fsync(2) system call to write all changes to disk, however the drive or network file system server may still delay writing data to disk. Do not depend on this functionality to prevent data loss in the event of unexpected hardware failure.

87cf9a
+
87cf9a
+

Enabling SyncOnClose may also cause the scheduler to periodically become unresponsive while it waits for changes to be written.

87cf9a
+
87cf9a
+
87cf9a
+
87cf9a
+
87cf9a
 

SystemGroup

87cf9a
 
87cf9a
 

Examples

87cf9a
diff -up cups-1.6.3/man/cups-files.conf.man.in.synconclose cups-1.6.3/man/cups-files.conf.man.in
87cf9a
--- cups-1.6.3/man/cups-files.conf.man.in.synconclose	2013-06-07 02:12:52.000000000 +0100
87cf9a
+++ cups-1.6.3/man/cups-files.conf.man.in	2013-11-04 11:39:51.104528571 +0000
87cf9a
@@ -122,6 +122,12 @@ ServerRoot directory
87cf9a
 .br
87cf9a
 Specifies the directory where the server configuration files can be found.
87cf9a
 .TP 5
87cf9a
+SyncOnClose Yes
87cf9a
+.TP 5
87cf9a
+SyncOnClose No
87cf9a
+Specifies whether the scheduler calls \fIfsync(2)\fR after writing configuration
87cf9a
+or state files. The default is Yes.
87cf9a
+.TP 5
87cf9a
 SystemGroup group-name [group-name ...]
87cf9a
 .br
87cf9a
 Specifies the group(s) to use for System class authentication.
87cf9a
diff -up cups-1.6.3/scheduler/conf.c.synconclose cups-1.6.3/scheduler/conf.c
87cf9a
--- cups-1.6.3/scheduler/conf.c.synconclose	2013-11-04 11:37:21.497849726 +0000
87cf9a
+++ cups-1.6.3/scheduler/conf.c	2013-11-04 11:39:51.106528580 +0000
87cf9a
@@ -174,6 +174,7 @@ static const cupsd_var_t	cupsfiles_vars[
87cf9a
   { "ServerRoot",		&ServerRoot,		CUPSD_VARTYPE_PATHNAME },
87cf9a
   { "SMBConfigFile",		&SMBConfigFile,		CUPSD_VARTYPE_STRING },
87cf9a
   { "StateDir",			&StateDir,		CUPSD_VARTYPE_STRING },
87cf9a
+  { "SyncOnClose",		&SyncOnClose,		CUPSD_VARTYPE_BOOLEAN },
87cf9a
 #ifdef HAVE_AUTHORIZATION_H
87cf9a
   { "SystemGroupAuthKey",	&SystemGroupAuthKey,	CUPSD_VARTYPE_STRING },
87cf9a
 #endif /* HAVE_AUTHORIZATION_H */
87cf9a
@@ -738,6 +739,7 @@ cupsdReadConfiguration(void)
87cf9a
   ReloadTimeout	           = DEFAULT_KEEPALIVE;
87cf9a
   RootCertDuration         = 300;
87cf9a
   StrictConformance        = FALSE;
87cf9a
+  SyncOnClose              = TRUE;
87cf9a
   Timeout                  = DEFAULT_TIMEOUT;
87cf9a
   WebInterface             = CUPS_DEFAULT_WEBIF;
87cf9a
 
87cf9a
diff -up cups-1.6.3/scheduler/conf.h.synconclose cups-1.6.3/scheduler/conf.h
87cf9a
--- cups-1.6.3/scheduler/conf.h.synconclose	2013-11-04 11:37:21.498849730 +0000
87cf9a
+++ cups-1.6.3/scheduler/conf.h	2013-11-04 11:37:32.064897673 +0000
87cf9a
@@ -177,6 +177,8 @@ VAR int			ClassifyOverride	VALUE(0),
87cf9a
 					/* Which errors are fatal? */
87cf9a
 			StrictConformance	VALUE(FALSE),
87cf9a
 					/* Require strict IPP conformance? */
87cf9a
+			SyncOnClose		VALUE(FALSE),
87cf9a
+					/* Call fsync() when closing files? */
87cf9a
 			LogFilePerm		VALUE(0644);
87cf9a
 					/* Permissions for log files */
87cf9a
 VAR cupsd_loglevel_t	LogLevel		VALUE(CUPSD_LOG_WARN);
87cf9a
diff -up cups-1.6.3/scheduler/file.c.synconclose cups-1.6.3/scheduler/file.c
87cf9a
--- cups-1.6.3/scheduler/file.c.synconclose	2013-06-07 02:12:52.000000000 +0100
87cf9a
+++ cups-1.6.3/scheduler/file.c	2013-11-04 11:37:32.064897673 +0000
87cf9a
@@ -109,6 +109,29 @@ cupsdCloseCreatedConfFile(
87cf9a
 
87cf9a
 
87cf9a
  /*
87cf9a
+  * Synchronize changes to disk if SyncOnClose is enabled.
87cf9a
+  */
87cf9a
+
87cf9a
+  if (SyncOnClose)
87cf9a
+  {
87cf9a
+    if (cupsFileFlush(fp))
87cf9a
+    {
87cf9a
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to write changes to \"%s\": %s",
87cf9a
+		      filename, strerror(errno));
87cf9a
+      cupsFileClose(fp);
87cf9a
+      return (-1);
87cf9a
+    }
87cf9a
+
87cf9a
+    if (fsync(cupsFileNumber(fp)))
87cf9a
+    {
87cf9a
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to sync changes to \"%s\": %s",
87cf9a
+		      filename, strerror(errno));
87cf9a
+      cupsFileClose(fp);
87cf9a
+      return (-1);
87cf9a
+    }
87cf9a
+  }
87cf9a
+
87cf9a
+ /*
87cf9a
   * First close the file...
87cf9a
   */
87cf9a