xboing used to lock the score file against itself. This has been due
to a wrong understanding of how the locking works. It locks on files, not descriptors, hence it's not sufficient to close the descriptor of a locked file. The patch fixes this.
This commit is contained in:
parent
7c4666c1d0
commit
8870a76e52
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=1274
134
games/xboing/files/patch-ad
Normal file
134
games/xboing/files/patch-ad
Normal file
@ -0,0 +1,134 @@
|
||||
*** highscore.c.orig Wed May 25 02:53:44 1994
|
||||
--- highscore.c Sat Apr 1 23:34:07 1995
|
||||
***************
|
||||
*** 40,45 ****
|
||||
--- 40,46 ----
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/types.h>
|
||||
+ #include <sys/stat.h>
|
||||
#include <netinet/in.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
***************
|
||||
*** 104,110 ****
|
||||
static void InitialiseHighScores(void);
|
||||
static void SortHighScores(void);
|
||||
static void DeleteScore(int i);
|
||||
! static int LockUnlock(int cmd);
|
||||
#else
|
||||
static int LockUnlock();
|
||||
static void DeleteScore();
|
||||
--- 105,111 ----
|
||||
static void InitialiseHighScores(void);
|
||||
static void SortHighScores(void);
|
||||
static void DeleteScore(int i);
|
||||
! static int LockUnlock(int cmd, int fd);
|
||||
#else
|
||||
static int LockUnlock();
|
||||
static void DeleteScore();
|
||||
***************
|
||||
*** 825,831 ****
|
||||
|
||||
/* Lock the file for me only */
|
||||
if (type == GLOBAL)
|
||||
! id = LockUnlock(LOCK_FILE);
|
||||
|
||||
/* Read in the lastest scores */
|
||||
if (ReadHighScoreTable(type) == False)
|
||||
--- 826,832 ----
|
||||
|
||||
/* Lock the file for me only */
|
||||
if (type == GLOBAL)
|
||||
! id = LockUnlock(LOCK_FILE, -1);
|
||||
|
||||
/* Read in the lastest scores */
|
||||
if (ReadHighScoreTable(type) == False)
|
||||
***************
|
||||
*** 855,861 ****
|
||||
else
|
||||
{
|
||||
/* Don't add as score is smaller */
|
||||
! return False;
|
||||
}
|
||||
}
|
||||
} /* for */
|
||||
--- 856,862 ----
|
||||
else
|
||||
{
|
||||
/* Don't add as score is smaller */
|
||||
! goto doUnlock;
|
||||
}
|
||||
}
|
||||
} /* for */
|
||||
***************
|
||||
*** 877,892 ****
|
||||
|
||||
/* Unlock the file now thanks */
|
||||
if (id != -1)
|
||||
! id = LockUnlock(UNLOCK_FILE);
|
||||
|
||||
/* Yes - it was placed in the highscore */
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unlock the file now thanks */
|
||||
if (id != -1)
|
||||
! id = LockUnlock(UNLOCK_FILE);
|
||||
|
||||
/* Not even a highscore - loser! */
|
||||
return False;
|
||||
--- 878,894 ----
|
||||
|
||||
/* Unlock the file now thanks */
|
||||
if (id != -1)
|
||||
! id = LockUnlock(UNLOCK_FILE, id);
|
||||
|
||||
/* Yes - it was placed in the highscore */
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
+ doUnlock:
|
||||
/* Unlock the file now thanks */
|
||||
if (id != -1)
|
||||
! id = LockUnlock(UNLOCK_FILE, id);
|
||||
|
||||
/* Not even a highscore - loser! */
|
||||
return False;
|
||||
***************
|
||||
*** 1164,1173 ****
|
||||
}
|
||||
|
||||
#if NeedFunctionPrototypes
|
||||
! static int LockUnlock(int cmd)
|
||||
#else
|
||||
! static int LockUnlock(cmd)
|
||||
! int cmd;
|
||||
#endif
|
||||
{
|
||||
int inter = -1;
|
||||
--- 1166,1175 ----
|
||||
}
|
||||
|
||||
#if NeedFunctionPrototypes
|
||||
! static int LockUnlock(int cmd, int fd)
|
||||
#else
|
||||
! static int LockUnlock(cmd, fd)
|
||||
! int cmd, fd;
|
||||
#endif
|
||||
{
|
||||
int inter = -1;
|
||||
***************
|
||||
*** 1204,1209 ****
|
||||
--- 1206,1214 ----
|
||||
/* Open the highscore file for both read & write */
|
||||
if (cmd == LOCK_FILE)
|
||||
inter = open(filename, O_CREAT | O_RDWR);
|
||||
+ else
|
||||
+ /* use old fd to unlock */
|
||||
+ inter = fd;
|
||||
|
||||
|
||||
#ifndef NO_LOCKING
|
Loading…
Reference in New Issue
Block a user