zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: warn on "hard" hard link failure
@ 2009-11-14 16:18 Clint Adams
  2009-11-14 17:32 ` François Revol
  0 siblings, 1 reply; 3+ messages in thread
From: Clint Adams @ 2009-11-14 16:18 UTC (permalink / raw)
  To: zsh-workers; +Cc: 555957

On Tue, Mar 10, 2009 at 02:18:41PM +0000, Peter Stephenson wrote:
> This is reponse to Sourceforge issue 1968395: failures to create hard
> links aren't gracefully handled.  Failing to create a link because the
> file already exists is the normal condition being handled by the locking
> code; however, a failure for any other reason is presumably a hard
> failure worthy of reporting.  The same goes if stat() fails with
> anything other than ENOENT: in both cases we give up and should say so.
> 
> It's possible this can be improved further.

Apparently this has caused someone distress because of the hard failure
preventing the correction of the out-of-diskspace condition causing the
history failure.


^ permalink raw reply	[flat|nested] 3+ messages in thread
* PATCH: warn on "hard" hard link failure
@ 2009-03-10 14:18 Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2009-03-10 14:18 UTC (permalink / raw)
  To: Zsh hackers list

This is reponse to Sourceforge issue 1968395: failures to create hard
links aren't gracefully handled.  Failing to create a link because the
file already exists is the normal condition being handled by the locking
code; however, a failure for any other reason is presumably a hard
failure worthy of reporting.  The same goes if stat() fails with
anything other than ENOENT: in both cases we give up and should say so.

It's possible this can be improved further.

Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.87
diff -u -r1.87 hist.c
--- Src/hist.c	25 Feb 2009 10:30:15 -0000	1.87
+++ Src/hist.c	10 Mar 2009 14:15:07 -0000
@@ -2433,13 +2433,16 @@
 	    } else
 		close(fd);
 	    while (link(tmpfile, lockfile) < 0) {
-		if (errno != EEXIST || !keep_trying)
+		if (errno != EEXIST)
+		    zerr("failed to create hard link as lock file %s: %e",
+			 lockfile, errno);
+		else if (!keep_trying)
 		    ;
 		else if (stat(lockfile, &sb) < 0) {
 		    if (errno == ENOENT)
 			continue;
-		}
-		else {
+		    zerr("failed to stat lock file %s: %e", lockfile, errno);
+		} else {
 		    if (time(NULL) - sb.st_mtime < 10)
 			sleep(1);
 		    else


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-14 17:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-14 16:18 PATCH: warn on "hard" hard link failure Clint Adams
2009-11-14 17:32 ` François Revol
  -- strict thread matches above, loose matches on Subject: below --
2009-03-10 14:18 Peter Stephenson

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).