* [4.2.0] Src/hist.c:lockhistfile() endless loop
@ 2004-05-07 10:35 KELEMEN Peter
2004-05-07 15:41 ` Wayne Davison
0 siblings, 1 reply; 2+ messages in thread
From: KELEMEN Peter @ 2004-05-07 10:35 UTC (permalink / raw)
To: zsh-workers
[ Please Cc: me since I'm not subscribed. Thanks. ]
Hello,
2141 while (link(tmpfile, lockfile) < 0) {
2142 if (stat(lockfile, &sb) < 0) {
2143 if (errno == ENOENT)
2144 continue;
This looks like an endless loop if
1) link() fails, and
2) stat() returns -ENOENT.
It was the case for me with $HOME being on OpenAFS and an expired
ticket (link() returned -EACCES). What guarantees do we have here
to say that link() will eventually succeed?
Peter
--
.+'''+. .+'''+. .+'''+. .+'''+. .+''
Kelemen Péter / \ / \ Peter.Kelemen@cern.ch
.+' `+...+' `+...+' `+...+' `+...+'
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [4.2.0] Src/hist.c:lockhistfile() endless loop
2004-05-07 10:35 [4.2.0] Src/hist.c:lockhistfile() endless loop KELEMEN Peter
@ 2004-05-07 15:41 ` Wayne Davison
0 siblings, 0 replies; 2+ messages in thread
From: Wayne Davison @ 2004-05-07 15:41 UTC (permalink / raw)
To: KELEMEN Peter, zsh-workers
[-- Attachment #1: Type: text/plain, Size: 263 bytes --]
On Fri, May 07, 2004 at 12:35:15PM +0200, KELEMEN Peter wrote:
> This looks like an endless loop if
> 1) link() fails, and
> 2) stat() returns -ENOENT.
Seems to me that the attached change would avoid the infinite loop in
the failure case you cite.
..wayne..
[-- Attachment #2: lockfile.patch --]
[-- Type: text/plain, Size: 419 bytes --]
--- Src/hist.c 29 Oct 2003 19:17:30 -0000 1.47
+++ Src/hist.c 7 May 2004 15:39:44 -0000
@@ -2139,7 +2139,9 @@ 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)
+ ;
+ else if (stat(lockfile, &sb) < 0) {
if (errno == ENOENT)
continue;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-05-07 15:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-07 10:35 [4.2.0] Src/hist.c:lockhistfile() endless loop KELEMEN Peter
2004-05-07 15:41 ` Wayne Davison
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).