summaryrefslogtreecommitdiff
path: root/games/xboing/files/patch-ad
diff options
context:
space:
mode:
authorJoerg Wunsch <joerg@FreeBSD.org>1995-04-01 22:12:16 +0000
committerJoerg Wunsch <joerg@FreeBSD.org>1995-04-01 22:12:16 +0000
commit8870a76e52126c84bbf27745bcf74345d5660459 (patch)
tree97667f5345e879a838fbfbaab20147c7612f6eb9 /games/xboing/files/patch-ad
parentChange the DEPENDS line to an EXEC_DEPENDS line. xarchie depends on archie, (diff)
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.
Notes
Notes: svn path=/head/; revision=1274
Diffstat (limited to 'games/xboing/files/patch-ad')
-rw-r--r--games/xboing/files/patch-ad134
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