From 1ec2b5c096e4a7a47bff2f65fe3dce104a063dec Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Tue, 11 May 2004 21:45:36 +0000 Subject: Fix the potential for an infinite loop in lockhistfile() if the link() calls fails for some other reason than EEXIST. --- Src/hist.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Src') diff --git a/Src/hist.c b/Src/hist.c index 0e0c4be98..e0b0475fb 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -2139,11 +2139,13 @@ lockhistfile(char *fn, int keep_trying) write(fd, tmpfile+len+1, strlen(tmpfile+len+1)); close(fd); while (link(tmpfile, lockfile) < 0) { - if (stat(lockfile, &sb) < 0) { + if (errno != EEXIST || !keep_trying) + ; + else if (stat(lockfile, &sb) < 0) { if (errno == ENOENT) continue; } - else if (keep_trying) { + else { if (time(NULL) - sb.st_mtime < 10) sleep(1); else -- cgit 1.4.1