[Freeciv-Dev] (PR#12512) better detection of file locking
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12512 >
In the userdb code, locking is enabled on all systems except windows.
However this is bad because locking depends on fileno which is not 100%
portable. (C99-pedantic compilation leaves it out. The manpage does
not mention it a all in the "conforming to" section.)
This patch makes it better. I also fixed a HAVE_FLOCK preprocessor
directive error.
-jason
Index: server/userdb/lockfile.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/userdb/lockfile.c,v
retrieving revision 1.5
diff -u -r1.5 lockfile.c
--- server/userdb/lockfile.c 29 Sep 2004 06:36:03 -0000 1.5
+++ server/userdb/lockfile.c 15 Mar 2005 01:00:45 -0000
@@ -23,7 +23,7 @@
#include <unistd.h>
#endif
-#ifndef WIN32_NATIVE
+#if defined HAVE_FILENO && (defined HAVE_FLOCK || defined HAVE_FCNTL)
#define HAS_FILE_LOCKING
#endif
@@ -75,7 +75,7 @@
{
#ifdef HAS_FILE_LOCKING
int i, fd;
-#ifndef HAVE_FLOCK
+#ifdef HAVE_FLOCK
struct flock fl = { F_WRLCK, SEEK_SET, 0, 0, 0 };
fl.l_pid = getpid();
@@ -113,7 +113,7 @@
{
#ifdef HAS_FILE_LOCKING
int fd = fileno(fp);
-#ifndef HAVE_FLOCK
+#ifdef HAVE_FLOCK
struct flock fl = { F_UNLCK, SEEK_SET, 0, 0, 0 };
fl.l_pid = getpid();
- [Freeciv-Dev] (PR#12512) better detection of file locking,
Jason Short <=
|
|