Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] Re: (PR#12512) better detection of file locking
Home

[Freeciv-Dev] Re: (PR#12512) better detection of file locking

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#12512) better detection of file locking
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Mar 2005 15:02:35 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12512 >

Brett Albertson wrote:

> I think we determined that Solaris does not have "HAVE_FLOCK" last time
> we looked at this.

Oops.  My "bugfix" was wrong.  For some reason the flock struct is for 
use with fcntl() not flock().

-jason

Index: server/userdb/lockfile.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/userdb/lockfile.c,v
retrieving revision 1.6
diff -u -r1.6 lockfile.c
--- server/userdb/lockfile.c    16 Mar 2005 19:34:08 -0000      1.6
+++ server/userdb/lockfile.c    23 Mar 2005 23:01:45 -0000
@@ -75,10 +75,10 @@
 {
 #ifdef HAS_FILE_LOCKING
   int i, fd;
-#ifdef HAVE_FLOCK
-  struct flock fl = { F_WRLCK, SEEK_SET, 0, 0, 0 };
+#ifndef HAVE_FLOCK
+  /* For use with fcntl */
+  struct flock fl = { F_WRLCK, SEEK_SET, 0, 0, 0, .l_pid = getpid()};
 
-  fl.l_pid = getpid();
 #endif
 
   /* open the file */
@@ -113,10 +113,10 @@
 {
 #ifdef HAS_FILE_LOCKING
   int fd = fileno(fp);
-#ifdef HAVE_FLOCK
-  struct flock fl = { F_UNLCK, SEEK_SET, 0, 0, 0 };
+#ifndef HAVE_FLOCK
+  /* For use with fcntl */
+  struct flock fl = { F_UNLCK, SEEK_SET, 0, 0, 0, .l_pid = getpid()};
 
-  fl.l_pid = getpid();
 #endif
 
   if (UNLOCK_CMD == -1) {

[Prev in Thread] Current Thread [Next in Thread]