diff options
author | joerg <joerg@FreeBSD.org> | 1995-04-02 06:12:16 +0800 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1995-04-02 06:12:16 +0800 |
commit | b19bf5482a914d49ab7babc30e1b6d5329872dba (patch) | |
tree | 9fc29c44983cb27737bc21ecb96e7be39eaa48c9 /games/xboing | |
parent | 816272932f12ebd1566ed03701415fb41a6078b3 (diff) | |
download | freebsd-ports-gnome-b19bf5482a914d49ab7babc30e1b6d5329872dba.tar.gz freebsd-ports-gnome-b19bf5482a914d49ab7babc30e1b6d5329872dba.tar.zst freebsd-ports-gnome-b19bf5482a914d49ab7babc30e1b6d5329872dba.zip |
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.
Diffstat (limited to 'games/xboing')
-rw-r--r-- | games/xboing/files/patch-ad | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/games/xboing/files/patch-ad b/games/xboing/files/patch-ad new file mode 100644 index 000000000000..4f4f9050cdb3 --- /dev/null +++ b/games/xboing/files/patch-ad @@ -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 |