Skip to content

Commit 0945545

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 beb994c commit 0945545

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)
@@ -2054,7 +2060,7 @@ static enum gh__error_code do_sub_cmd__get(int argc, const char **argv)
20542060
}
20552061

20562062
/*
2057-
* Handle the 'get' command when in "server mode". Only call error()
2063+
* Handle the 'get' command when in "server mode". Only call error() and set ec
20582064
* for hard errors where we cannot communicate correctly with the foreground
20592065
* client process. Pass any actual data errors (such as 404's or 401's from
20602066
* the fetch back to the client process.
@@ -2126,10 +2132,15 @@ static enum gh__error_code do_server_subprocess_get(void)
21262132
goto cleanup;
21272133
}
21282134

2135+
/*
2136+
* We only use status.ec to tell the client whether the request
2137+
* was complete, incomplete, or had IO errors. We DO NOT return
2138+
* this value to our caller.
2139+
*/
21292140
err = 0;
2130-
if (ec == GH__ERROR_CODE__OK)
2141+
if (status.ec == GH__ERROR_CODE__OK)
21312142
err = packet_write_fmt_gently(1, "ok\n");
2132-
else if (ec == GH__ERROR_CODE__HTTP_404)
2143+
else if (status.ec == GH__ERROR_CODE__HTTP_404)
21332144
err = packet_write_fmt_gently(1, "partial\n");
21342145
else
21352146
err = packet_write_fmt_gently(1, "error %s\n",
@@ -2357,6 +2368,7 @@ int cmd_main(int argc, const char **argv)
23572368
usage_with_options(main_usage, main_options);
23582369

23592370
trace2_cmd_name("gvfs-helper");
2371+
packet_trace_identity("gvfs-helper");
23602372

23612373
setup_git_directory_gently(NULL);
23622374

0 commit comments

Comments
 (0)