git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH 2/5] remote-helpers: make recvline return an error
Date: Sat, 19 Apr 2014 00:00:40 -0700	[thread overview]
Message-ID: <1397890843-27035-3-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1397890843-27035-1-git-send-email-gitster@pobox.com>

From: Felipe Contreras <felipe.contreras@gmail.com>

Instead of exiting directly, make it the duty of the caller to do so.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 transport-helper.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index 892107c..f0d7fc7 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -58,7 +58,7 @@ static int recvline_fh(FILE *helper, struct strbuf *buffer, const char *name)
 	if (strbuf_getline(buffer, helper, '\n') == EOF) {
 		if (debug)
 			fprintf(stderr, "Debug: Remote helper quit.\n");
-		exit(128);
+		return 1;
 	}
 
 	if (debug)
@@ -157,7 +157,8 @@ static struct child_process *get_helper(struct transport *transport)
 	while (1) {
 		const char *capname;
 		int mandatory = 0;
-		recvline(data, &buf);
+		if (recvline(data, &buf))
+			exit(128);
 
 		if (!*buf.buf)
 			break;
@@ -302,7 +303,8 @@ static int set_helper_option(struct transport *transport,
 	strbuf_addch(&buf, '\n');
 
 	sendline(data, &buf);
-	recvline(data, &buf);
+	if (recvline(data, &buf))
+		exit(128);
 
 	if (!strcmp(buf.buf, "ok"))
 		ret = 0;
@@ -374,7 +376,8 @@ static int fetch_with_fetch(struct transport *transport,
 	sendline(data, &buf);
 
 	while (1) {
-		recvline(data, &buf);
+		if (recvline(data, &buf))
+			exit(128);
 
 		if (starts_with(buf.buf, "lock ")) {
 			const char *name = buf.buf + 5;
@@ -558,7 +561,9 @@ static int process_connect_service(struct transport *transport,
 		goto exit;
 
 	sendline(data, &cmdbuf);
-	recvline_fh(input, &cmdbuf, name);
+	if (recvline_fh(input, &cmdbuf, name))
+		exit(128);
+
 	if (!strcmp(cmdbuf.buf, "")) {
 		data->no_disconnect_req = 1;
 		if (debug)
@@ -743,7 +748,8 @@ static void push_update_refs_status(struct helper_data *data,
 	for (;;) {
 		char *private;
 
-		recvline(data, &buf);
+		if (recvline(data, &buf))
+			exit(128);
 		if (!buf.len)
 			break;
 
@@ -969,7 +975,8 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
 
 	while (1) {
 		char *eov, *eon;
-		recvline(data, &buf);
+		if (recvline(data, &buf))
+			exit(128);
 
 		if (!*buf.buf)
 			break;
-- 
1.9.2-459-g68773ac

  parent reply	other threads:[~2014-04-19  6:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-12 20:33 [PATCH 0/5] transport-helper: serious crash fix Felipe Contreras
2014-04-12 20:33 ` [PATCH 1/5] transport-helper: remove barely used xchgline() Felipe Contreras
2014-04-12 20:33 ` [PATCH 2/5] remote-helpers: make recvline return an error Felipe Contreras
2014-04-12 20:33 ` [PATCH 3/5] transport-helper: propagate recvline() error pushing Felipe Contreras
2014-04-12 20:33 ` [PATCH 4/5] transport-helper: trivial cleanup Felipe Contreras
2014-04-14 21:14   ` Junio C Hamano
2014-04-12 20:33 ` [PATCH 5/5] transport-helper: fix sync issue on crashes Felipe Contreras
2014-04-14 21:25   ` Junio C Hamano
2014-04-15 21:28 ` [PATCH 0/5] transport-helper: serious crash fix Junio C Hamano
2014-04-19  7:00 ` [PATCH 0/5] fc/transport-helper-sync-error-fix rebased Junio C Hamano
2014-04-19  7:00   ` [PATCH 1/5] transport-helper: remove barely used xchgline() Junio C Hamano
2014-04-19  7:00   ` Junio C Hamano [this message]
2014-04-19  7:00   ` [PATCH 3/5] transport-helper: propagate recvline() error pushing Junio C Hamano
2014-04-19  7:00   ` [PATCH 4/5] transport-helper: trivial cleanup Junio C Hamano
2014-04-19  7:00   ` [PATCH 5/5] transport-helper: fix sync issue on crashes Junio C Hamano
2014-04-20 18:36   ` [PATCH 0/5] fc/transport-helper-sync-error-fix rebased Felipe Contreras
2014-04-20 21:10     ` Junio C Hamano
2014-04-20 21:12       ` Felipe Contreras
2014-04-20 21:52         ` Junio C Hamano
2014-04-20 21:54           ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397890843-27035-3-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).