[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lib-src/update-game-score.c
From: |
Colin Walters |
Subject: |
[Emacs-diffs] Changes to emacs/lib-src/update-game-score.c |
Date: |
Sun, 14 Apr 2002 02:40:19 -0400 |
Index: emacs/lib-src/update-game-score.c
diff -c emacs/lib-src/update-game-score.c:1.6
emacs/lib-src/update-game-score.c:1.7
*** emacs/lib-src/update-game-score.c:1.6 Sat Apr 13 21:02:36 2002
--- emacs/lib-src/update-game-score.c Sun Apr 14 02:40:19 2002
***************
*** 416,421 ****
--- 416,422 ----
lock_file(const char *filename, void **state)
{
int fd;
+ struct stat buf;
int attempts = 0;
char *lockext = ".lockfile";
char *lockpath = malloc(strlen(filename) + strlen(lockext) + 60);
***************
*** 426,431 ****
--- 427,436 ----
*state = lockpath;
trylock:
attempts++;
+ /* If the lock is over an hour old, delete it. */
+ if (stat(lockpath, &buf) == 0
+ && (difftime(buf.st_ctime, time(NULL) > 60*60)))
+ unlink(lockpath);
if ((fd = open(lockpath, O_CREAT | O_EXCL, 0600)) < 0)
{
if (errno == EEXIST)
***************
*** 433,439 ****
/* Break the lock; we won't corrupt the file, but we might
lose some scores. */
if (attempts > MAX_ATTEMPTS)
! unlink(lockpath);
sleep((rand() % 2)+1);
goto trylock;
}
--- 438,447 ----
/* Break the lock; we won't corrupt the file, but we might
lose some scores. */
if (attempts > MAX_ATTEMPTS)
! {
! unlink(lockpath);
! attempts = 0;
! }
sleep((rand() % 2)+1);
goto trylock;
}
- [Emacs-diffs] Changes to emacs/lib-src/update-game-score.c, Colin Walters, 2002/04/05
- [Emacs-diffs] Changes to emacs/lib-src/update-game-score.c, Colin Walters, 2002/04/05
- [Emacs-diffs] Changes to emacs/lib-src/update-game-score.c, Colin Walters, 2002/04/07
- [Emacs-diffs] Changes to emacs/lib-src/update-game-score.c, Colin Walters, 2002/04/10
- [Emacs-diffs] Changes to emacs/lib-src/update-game-score.c, Andreas Schwab, 2002/04/13
- [Emacs-diffs] Changes to emacs/lib-src/update-game-score.c,
Colin Walters <=
- [Emacs-diffs] Changes to emacs/lib-src/update-game-score.c, Eli Zaretskii, 2002/04/16
- [Emacs-diffs] Changes to emacs/lib-src/update-game-score.c, Colin Walters, 2002/04/23
- [Emacs-diffs] Changes to emacs/lib-src/update-game-score.c, Colin Walters, 2002/04/29