git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] refs.c: handle locking failure during transaction better
@ 2014-11-18 23:17 Stefan Beller
  2014-11-18 23:34 ` Stefan Beller
  0 siblings, 1 reply; 24+ messages in thread
From: Stefan Beller @ 2014-11-18 23:17 UTC (permalink / raw)
  To: sahlberg, git, gitster; +Cc: Stefan Beller, Jonathan Nieder

Change lock_ref_sha1_basic to return an error instead of dying,
when we fail to lock a file during a transaction. This function is
only called from transaction_commit() and it knows how to handle
these failures.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Cherry-picked-to-master: Stefan Beller <sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 refs.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
 
This was part of the ref-transactions-rename series[1], 
but it makes sense to send this one as a separate patch.

Thanks,
Stefan

[1] https://www.mail-archive.com/git@vger.kernel.org/msg60604.html

diff --git a/refs.c b/refs.c
index 5ff457e..0347328 100644
--- a/refs.c
+++ b/refs.c
@@ -2318,6 +2318,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
 
 	lock->lock_fd = hold_lock_file_for_update(lock->lk, ref_file, lflags);
 	if (lock->lock_fd < 0) {
+		last_errno = errno;
 		if (errno == ENOENT && --attempts_remaining > 0)
 			/*
 			 * Maybe somebody just deleted one of the
@@ -2325,8 +2326,13 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
 			 * again:
 			 */
 			goto retry;
-		else
-			unable_to_lock_die(ref_file, errno);
+		else {
+			struct strbuf err = STRBUF_INIT;
+			unable_to_lock_message(ref_file, errno, &err);
+			error("%s", err.buf);
+			strbuf_reset(&err);
+			goto error_return;
+		}
 	}
 	return old_sha1 ? verify_lock(lock, old_sha1, mustexist) : lock;
 
-- 
2.2.0.rc2.5.gf7b9fb2

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

end of thread, other threads:[~2014-11-21  9:25 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-18 23:17 [PATCH] refs.c: handle locking failure during transaction better Stefan Beller
2014-11-18 23:34 ` Stefan Beller
2014-11-19  1:13   ` Stefan Beller
2014-11-19  1:35     ` [PATCH 0/4] error cleanups in lock_ref_sha1_basic Jeff King
2014-11-19  1:37       ` [PATCH 1/4] error: save and restore errno Jeff King
2014-11-19  1:41         ` Stefan Beller
2014-11-19  1:43         ` Jonathan Nieder
2014-11-19  1:47           ` Jeff King
2014-11-19 18:14             ` Junio C Hamano
2014-11-19 18:28               ` Jeff King
2014-11-19  1:37       ` [PATCH 2/4] lock_ref_sha1_basic: simplify errno handling Jeff King
2014-11-19  1:54         ` Jonathan Nieder
2014-11-21  9:25         ` Michael Haggerty
2014-11-19  1:37       ` [PATCH 3/4] lock_ref_sha1_basic: simplify error code path Jeff King
2014-11-19  2:00         ` Jonathan Nieder
2014-11-19  2:04           ` Jeff King
2014-11-19  2:07             ` Jonathan Nieder
2014-11-19 21:41               ` Junio C Hamano
2014-11-19 22:28               ` Jeff King
2014-11-19 22:34                 ` Junio C Hamano
2014-11-19 22:36                   ` Jeff King
2014-11-20  1:07                 ` Jonathan Nieder
2014-11-19  1:41       ` [PATCH 4/4] lock_ref_sha1_basic: do not die on locking errors Jeff King
2014-11-19  2:05         ` Jonathan Nieder

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