remote-helpers: make recvline return an error
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>
Felipe Contreras committed
Apr 12, 2014 at 15:33 UTC
5931b33e202856aa0046b493c3aacdd16be7d8f3
1 file changed
+14
-7
transport-helper.c
+14
-7
@@ -58,7 +58,7 @@ static int recvline_fh(FILE *helper, struct strbuf *buffer, const char *name)
58
if (strbuf_getline(buffer, helper, '\n') == EOF) {
59
if (debug)
60
fprintf(stderr, "Debug: Remote helper quit.\n");
61
- exit(128);
61
+ return 1;
62
}
63
64
if (debug)
@@ -157,7 +157,8 @@ static struct child_process *get_helper(struct transport *transport)
157
while (1) {
158
const char *capname;
159
int mandatory = 0;
160
- recvline(data, &buf);
160
+ if (recvline(data, &buf))
161
+ exit(128);
162
163
if (!*buf.buf)
164
break;
@@ -302,7 +303,8 @@ static int set_helper_option(struct transport *transport,
303
strbuf_addch(&buf, '\n');
304
305
sendline(data, &buf);
305
- recvline(data, &buf);
306
+ if (recvline(data, &buf))
307
+ exit(128);
308
309
if (!strcmp(buf.buf, "ok"))
310
ret = 0;
@@ -374,7 +376,8 @@ static int fetch_with_fetch(struct transport *transport,
376
sendline(data, &buf);
377
378
while (1) {
377
- recvline(data, &buf);
379
+ if (recvline(data, &buf))
380
+ exit(128);
381
382
if (starts_with(buf.buf, "lock ")) {
383
const char *name = buf.buf + 5;
@@ -558,7 +561,9 @@ static int process_connect_service(struct transport *transport,
561
goto exit;
562
563
sendline(data, &cmdbuf);
561
- recvline_fh(input, &cmdbuf, name);
564
+ if (recvline_fh(input, &cmdbuf, name))
565
+ exit(128);
566
+
567
if (!strcmp(cmdbuf.buf, "")) {
568
data->no_disconnect_req = 1;
569
if (debug)
@@ -743,7 +748,8 @@ static void push_update_refs_status(struct helper_data *data,
748
for (;;) {
749
char *private;
750
746
- recvline(data, &buf);
751
+ if (recvline(data, &buf))
752
+ exit(128);
753
if (!buf.len)
754
break;
755
@@ -969,7 +975,8 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
975
976
while (1) {
977
char *eov, *eon;
972
- recvline(data, &buf);
978
+ if (recvline(data, &buf))
979
+ exit(128);
980
981
if (!*buf.buf)
982
break;