[Gnucash-changes] r13634 - gnucash/trunk - Disable extra NFS lockfile checking on windows due to

Christian Stimming cstim at cvs.gnucash.org
Tue Mar 14 11:59:33 EST 2006


Author: cstim
Date: 2006-03-14 11:59:32 -0500 (Tue, 14 Mar 2006)
New Revision: 13634
Trac: http://svn.gnucash.org/trac/changeset/13634

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/backend/file/gnc-backend-file.c
Log:
Disable extra NFS lockfile checking on windows due to 
missing link(2). This is not a problem because on windows 
there also is no NFS, and the open(O_CREAT|O_EXCL) is 
sufficiently atomic for our purposes.



Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-03-14 16:31:29 UTC (rev 13633)
+++ gnucash/trunk/ChangeLog	2006-03-14 16:59:32 UTC (rev 13634)
@@ -1,5 +1,10 @@
 2006-03-14  Christian Stimming <stimming at tuhh.de>
 
+	* src/backend/file/gnc-backend-file.c: Disable extra NFS lockfile
+	checking on windows due to missing link(2). This is not a problem
+	because on windows there also is no NFS, and the
+	open(O_CREAT|O_EXCL) is sufficiently atomic for our purposes.
+
 	* src/backend/file/io-gncxml-v2.c: Disable file compression on
 	windows due to missing pipe(2), conditioned on #ifdef
 	_WIN32. Insert code suggestion for windows, but is disabled for

Modified: gnucash/trunk/src/backend/file/gnc-backend-file.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-backend-file.c	2006-03-14 16:31:29 UTC (rev 13633)
+++ gnucash/trunk/src/backend/file/gnc-backend-file.c	2006-03-14 16:59:32 UTC (rev 13634)
@@ -74,8 +74,10 @@
 gnc_file_be_get_file_lock (FileBackend *be)
 {
     struct stat statbuf;
+#ifndef _WIN32
     char pathbuf[PATH_MAX];
     char *path = NULL;
+#endif
     int rc;
     QofBackendError be_err;
 
@@ -121,6 +123,7 @@
      * provides a better long-term solution.
      */
 
+#ifndef _WIN32
     strcpy (pathbuf, be->lockfile);
     path = strrchr (pathbuf, '.');
     sprintf (path, ".%lx.%d.LNK", gethostid(), getpid());
@@ -130,9 +133,9 @@
     {
         /* If hard links aren't supported, just allow the lock. */
         if (errno == EPERM
-#ifdef EOPNOTSUPP
+# ifdef EOPNOTSUPP
 	    || errno == EOPNOTSUPP
-#endif
+# endif
 	    )
         {
             be->linkfile = NULL;
@@ -170,6 +173,13 @@
     be->linkfile = g_strdup (pathbuf);
 
     return TRUE;
+
+#else /* ifndef _WIN32 */
+    /* On windows, there is no NFS and the open(,O_CREAT | O_EXCL)
+       is sufficient for locking. */
+    be->linkfile = NULL;
+    return TRUE;
+#endif /* ifndef _WIN32 */
 }
 
 /* ================================================================= */
@@ -337,14 +347,22 @@
 static gboolean
 gnc_int_link_or_make_backup(FileBackend *be, const char *orig, const char *bkup)
 {
-    int err_ret = link(orig, bkup);
+    int err_ret = 
+#ifdef HAVE_LINK
+      link (orig, bkup)
+#else
+      -1
+#endif
+      ;
     if(err_ret != 0)
     {
+#ifdef HAVE_LINK
         if(errno == EPERM
-#ifdef EOPNOTSUPP
+# ifdef EOPNOTSUPP
 	   || errno == EOPNOTSUPP
+# endif
+	   )
 #endif
-	   )
         {
             err_ret = copy_file(orig, bkup);
         }



More information about the gnucash-changes mailing list