Blame SOURCES/cups-synconclose.patch

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

ea9550
 
ea9550
 
ea9550
+

CUPS 1.6.4SyncOnClose

ea9550
+
ea9550
+

Examples

ea9550
+
ea9550
+
ea9550
+SyncOnClose No
ea9550
+SyncOnClose Yes
ea9550
+
ea9550
+
ea9550
+

Description

ea9550
+
ea9550
+

The SyncOnClose directive determines whether the scheduler

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

ea9550
+
ea9550
+
Note:
ea9550
+
ea9550
+

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.

ea9550
+
ea9550
+

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

ea9550
+
ea9550
+
ea9550
+
ea9550
+
ea9550
 

SystemGroup

ea9550
 
ea9550
 

Examples

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