gconf r2748 - in branches/gnome-2-22: . gconf
- From: tml svn gnome org
- To: svn-commits-list gnome org
- Subject: gconf r2748 - in branches/gnome-2-22: . gconf
- Date: Tue, 27 Jan 2009 16:30:53 +0000 (UTC)
Author: tml
Date: Tue Jan 27 16:30:53 2009
New Revision: 2748
URL: http://svn.gnome.org/viewvc/gconf?rev=2748&view=rev
Log:
2009-01-27 Tor Lillqvist <tml novell com>
Merge changes from my build scripts.
* gconf/gconf-internals.c (create_new_locked_file): Drop the Win9x
code path. There is no Win9x support any more lower in the stack
anyway.
* gconf/gconf-internals.c: Rework locking on Windows.
(create_new_locked_file): Don't attempt to use shared open with
deny modes on Windows, that never worked correctly here.
(gconf_release_lock): Truncate the file to zero size before
closing. This is to avoid race conditions, as we don't want the
file to exist but with seemingly valid contents between closing
and unlinking.
Modified:
branches/gnome-2-22/ChangeLog
branches/gnome-2-22/gconf/gconf-internals.c
Modified: branches/gnome-2-22/gconf/gconf-internals.c
==============================================================================
--- branches/gnome-2-22/gconf/gconf-internals.c (original)
+++ branches/gnome-2-22/gconf/gconf-internals.c Tue Jan 27 16:30:53 2009
@@ -37,8 +37,9 @@
#include <math.h>
#ifdef G_OS_WIN32
+#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#include <share.h>
+#include <io.h>
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
#endif
@@ -2188,8 +2189,6 @@
#endif
}
-#endif
-
#ifdef F_SETLK
/* Your basic Stevens cut-and-paste */
static int
@@ -2242,8 +2241,6 @@
#endif
}
-#ifndef G_OS_WIN32
-
static char*
unique_filename (const char *directory)
{
@@ -2323,21 +2320,20 @@
#else
- if (G_WIN32_HAVE_WIDECHAR_API ())
- {
- wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
- fd = _wsopen (wfilename, O_WRONLY|O_CREAT|O_EXCL, SH_DENYWR, 0700);
- g_free (wfilename);
- }
- else
- {
- char *cpfilename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
- fd = _sopen (cpfilename, O_WRONLY|O_CREAT|O_EXCL, SH_DENYWR, 0700);
- g_free (cpfilename);
- }
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+
+ fd = _wopen (wfilename, O_WRONLY|O_CREAT|O_NOINHERIT|O_EXCL, 0700);
+ g_free (wfilename);
got_lock = (fd >= 0);
+ if (!got_lock)
+ g_set_error (err,
+ GCONF_ERROR,
+ GCONF_ERROR_LOCK_FAILED,
+ _("Could not create file '%s', probably because it already exists"),
+ filename);
+
#endif
if (!got_lock)
@@ -2626,6 +2622,8 @@
retval = FALSE;
uniquefile = NULL;
+#ifndef G_OS_WIN32
+
/* A paranoia check to avoid disaster if e.g.
* some random client code opened and closed the
* lockfile (maybe Nautilus checking its MIME type or
@@ -2642,8 +2640,6 @@
goto out;
}
-#ifndef G_OS_WIN32
-
/* To avoid annoying .nfs3435314513453145 files on unlink, which keep us
* from removing the lock directory, we don't want to hold the
* lockfile open after removing all links to it. But we can't
@@ -2678,6 +2674,16 @@
goto out;
}
+#else
+
+ /* On Windows we just truncate the file to zero size as we can't
+ * easily rename or unlink it while it is open. This is to avoid
+ * race conditions, as we don't want the file to exist but with
+ * seemingly valid contents between closing and unlinking.
+ */
+ if (lock->lock_fd >= 0)
+ chsize (lock->lock_fd, 0);
+
#endif
/* Now drop our lock */
@@ -2701,6 +2707,19 @@
goto out;
}
+#else
+
+ if (g_unlink (lock->iorfile) < 0)
+ {
+ g_set_error (err,
+ GCONF_ERROR,
+ GCONF_ERROR_FAILED,
+ _("Failed to clean up file '%s': %s"),
+ lock->iorfile, g_strerror (errno));
+
+ goto out;
+ }
+
#endif
/* And finally clean up the directory - this would have failed if
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]