Skip to content

Commit a90d8ca

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 <[email protected]>
1 parent f046226 commit a90d8ca

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
@@ -414,10 +414,16 @@ static void gh__response_status__set_from_slot(
414414
strbuf_addf(&status->error_message, "%s (curl)",
415415
curl_easy_strerror(status->curl_code));
416416
status->ec = GH__ERROR_CODE__CURL_ERROR;
417+
418+
trace2_data_string("gvfs-helper", NULL,
419+
"error/curl", status->error_message.buf);
417420
} else {
418421
strbuf_addf(&status->error_message, "HTTP %ld Unexpected",
419422
status->response_code);
420423
status->ec = GH__ERROR_CODE__HTTP_UNEXPECTED_CODE;
424+
425+
trace2_data_string("gvfs-helper", NULL,
426+
"error/http", status->error_message.buf);
421427
}
422428

423429
if (status->ec != GH__ERROR_CODE__OK)
@@ -2041,7 +2047,7 @@ static enum gh__error_code do_sub_cmd__get(int argc, const char **argv)
20412047
}
20422048

20432049
/*
2044-
* Handle the 'get' command when in "server mode". Only call error()
2050+
* Handle the 'get' command when in "server mode". Only call error() and set ec
20452051
* for hard errors where we cannot communicate correctly with the foreground
20462052
* client process. Pass any actual data errors (such as 404's or 401's from
20472053
* the fetch back to the client process.
@@ -2113,10 +2119,15 @@ static enum gh__error_code do_server_subprocess_get(void)
21132119
goto cleanup;
21142120
}
21152121

2122+
/*
2123+
* We only use status.ec to tell the client whether the request
2124+
* was complete, incomplete, or had IO errors. We DO NOT return
2125+
* this value to our caller.
2126+
*/
21162127
err = 0;
2117-
if (ec == GH__ERROR_CODE__OK)
2128+
if (status.ec == GH__ERROR_CODE__OK)
21182129
err = packet_write_fmt_gently(1, "ok\n");
2119-
else if (ec == GH__ERROR_CODE__HTTP_404)
2130+
else if (status.ec == GH__ERROR_CODE__HTTP_404)
21202131
err = packet_write_fmt_gently(1, "partial\n");
21212132
else
21222133
err = packet_write_fmt_gently(1, "error %s\n",
@@ -2344,6 +2355,7 @@ int cmd_main(int argc, const char **argv)
23442355
usage_with_options(main_usage, main_options);
23452356

23462357
trace2_cmd_name("gvfs-helper");
2358+
packet_trace_identity("gvfs-helper");
23472359

23482360
setup_git_directory_gently(NULL);
23492361

0 commit comments

Comments
 (0)