Skip to content

Commit 743dbba

Browse files
jeffhostetlerdscho
authored andcommitted
gvfs-helper: better handling of network errors
Add trace2 message for CURL and HTTP errors. Fix typo reporting network error code back to gvfs-helper-client. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
1 parent f706a93 commit 743dbba

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

gvfs-helper.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,16 @@ static void gh__response_status__set_from_slot(
412412
strbuf_addf(&status->error_message, "%s (curl)",
413413
curl_easy_strerror(status->curl_code));
414414
status->ec = GH__ERROR_CODE__CURL_ERROR;
415+
416+
trace2_data_string("gvfs-helper", NULL,
417+
"error/curl", status->error_message.buf);
415418
} else {
416419
strbuf_addf(&status->error_message, "HTTP %ld Unexpected",
417420
status->response_code);
418421
status->ec = GH__ERROR_CODE__HTTP_UNEXPECTED_CODE;
422+
423+
trace2_data_string("gvfs-helper", NULL,
424+
"error/http", status->error_message.buf);
419425
}
420426

421427
if (status->ec != GH__ERROR_CODE__OK)
@@ -2035,7 +2041,7 @@ static enum gh__error_code do_sub_cmd__get(int argc, const char **argv)
20352041
}
20362042

20372043
/*
2038-
* Handle the 'get' command when in "server mode". Only call error()
2044+
* Handle the 'get' command when in "server mode". Only call error() and set ec
20392045
* for hard errors where we cannot communicate correctly with the foreground
20402046
* client process. Pass any actual data errors (such as 404's or 401's from
20412047
* the fetch back to the client process.
@@ -2107,10 +2113,15 @@ static enum gh__error_code do_server_subprocess_get(void)
21072113
goto cleanup;
21082114
}
21092115

2116+
/*
2117+
* We only use status.ec to tell the client whether the request
2118+
* was complete, incomplete, or had IO errors. We DO NOT return
2119+
* this value to our caller.
2120+
*/
21102121
err = 0;
2111-
if (ec == GH__ERROR_CODE__OK)
2122+
if (status.ec == GH__ERROR_CODE__OK)
21122123
err = packet_write_fmt_gently(1, "ok\n");
2113-
else if (ec == GH__ERROR_CODE__HTTP_404)
2124+
else if (status.ec == GH__ERROR_CODE__HTTP_404)
21142125
err = packet_write_fmt_gently(1, "partial\n");
21152126
else
21162127
err = packet_write_fmt_gently(1, "error %s\n",
@@ -2337,6 +2348,7 @@ int cmd_main(int argc, const char **argv)
23372348
usage_with_options(main_usage, main_options);
23382349

23392350
trace2_cmd_name("gvfs-helper");
2351+
packet_trace_identity("gvfs-helper");
23402352

23412353
setup_git_directory_gently(NULL);
23422354

0 commit comments

Comments
 (0)