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.



git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13634 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2006-03-14 16:59:32 +00:00
parent 91d927cfef
commit f31ba70fe3
2 changed files with 28 additions and 5 deletions

View File

@ -1,5 +1,10 @@
2006-03-14 Christian Stimming <stimming@tuhh.de> 2006-03-14 Christian Stimming <stimming@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 * src/backend/file/io-gncxml-v2.c: Disable file compression on
windows due to missing pipe(2), conditioned on #ifdef windows due to missing pipe(2), conditioned on #ifdef
_WIN32. Insert code suggestion for windows, but is disabled for _WIN32. Insert code suggestion for windows, but is disabled for

View File

@ -74,8 +74,10 @@ static gboolean
gnc_file_be_get_file_lock (FileBackend *be) gnc_file_be_get_file_lock (FileBackend *be)
{ {
struct stat statbuf; struct stat statbuf;
#ifndef _WIN32
char pathbuf[PATH_MAX]; char pathbuf[PATH_MAX];
char *path = NULL; char *path = NULL;
#endif
int rc; int rc;
QofBackendError be_err; QofBackendError be_err;
@ -121,6 +123,7 @@ gnc_file_be_get_file_lock (FileBackend *be)
* provides a better long-term solution. * provides a better long-term solution.
*/ */
#ifndef _WIN32
strcpy (pathbuf, be->lockfile); strcpy (pathbuf, be->lockfile);
path = strrchr (pathbuf, '.'); path = strrchr (pathbuf, '.');
sprintf (path, ".%lx.%d.LNK", gethostid(), getpid()); sprintf (path, ".%lx.%d.LNK", gethostid(), getpid());
@ -130,9 +133,9 @@ gnc_file_be_get_file_lock (FileBackend *be)
{ {
/* If hard links aren't supported, just allow the lock. */ /* If hard links aren't supported, just allow the lock. */
if (errno == EPERM if (errno == EPERM
#ifdef EOPNOTSUPP # ifdef EOPNOTSUPP
|| errno == EOPNOTSUPP || errno == EOPNOTSUPP
#endif # endif
) )
{ {
be->linkfile = NULL; be->linkfile = NULL;
@ -170,6 +173,13 @@ gnc_file_be_get_file_lock (FileBackend *be)
be->linkfile = g_strdup (pathbuf); be->linkfile = g_strdup (pathbuf);
return TRUE; 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 @@ copy_file(const char *orig, const char *bkup)
static gboolean static gboolean
gnc_int_link_or_make_backup(FileBackend *be, const char *orig, const char *bkup) 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) if(err_ret != 0)
{ {
#ifdef HAVE_LINK
if(errno == EPERM if(errno == EPERM
#ifdef EOPNOTSUPP # ifdef EOPNOTSUPP
|| errno == EOPNOTSUPP || errno == EOPNOTSUPP
#endif # endif
) )
#endif
{ {
err_ret = copy_file(orig, bkup); err_ret = copy_file(orig, bkup);
} }