git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] remote-curl: pass curl slot_results back through run_slot

From
Jeff King <peff@peff.net>
Date
Oct 31, 2013, 06:36 UTC
Message-ID
<20131031063626.GB5812@sigill.intra.peff.net>
In-Reply-To
<20131031063451.GA5513@sigill.intra.peff.net>

Some callers may want to know more than just the integer error code we return. Let them optionally pass a slot_results struct to fill in (or NULL if they do not care). In either case we continue to return the integer code.

We can also give probe_rpc the same treatment (since it builds directly on run_slot).

Signed-off-by: Jeff King <peff@peff.net>
---
 remote-curl.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/remote-curl.c b/remote-curl.c
index b5ebe01..79db21e 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -383,25 +383,29 @@ static size_t rpc_in(char *ptr, size_t eltsize,
 	return size;
 }
 
-static int run_slot(struct active_request_slot *slot)
+static int run_slot(struct active_request_slot *slot,
+		    struct slot_results *results)
 {
 	int err;
-	struct slot_results results;
+	struct slot_results results_buf;
 
-	slot->results = &results;
+	if (!results)
+		results = &results_buf;
+
+	slot->results = results;
 	slot->curl_result = curl_easy_perform(slot->curl);
 	finish_active_slot(slot);
 
-	err = handle_curl_result(&results);
+	err = handle_curl_result(results);
 	if (err != HTTP_OK && err != HTTP_REAUTH) {
 		error("RPC failed; result=%d, HTTP code = %ld",
-		      results.curl_result, results.http_code);
+		      results->curl_result, results->http_code);
 	}
 
 	return err;
 }
 
-static int probe_rpc(struct rpc_state *rpc)
+static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)
 {
 	struct active_request_slot *slot;
 	struct curl_slist *headers = NULL;
@@ -423,7 +427,7 @@ static int probe_rpc(struct rpc_state *rpc)
 	curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
 	curl_easy_setopt(slot->curl, CURLOPT_FILE, &buf);
 
-	err = run_slot(slot);
+	err = run_slot(slot, results);
 
 	curl_slist_free_all(headers);
 	strbuf_release(&buf);
@@ -462,7 +466,7 @@ static int post_rpc(struct rpc_state *rpc)
 
 	if (large_request) {
 		do {
-			err = probe_rpc(rpc);
+			err = probe_rpc(rpc, NULL);
 		} while (err == HTTP_REAUTH);
 		if (err != HTTP_OK)
 			return -1;
@@ -561,7 +565,7 @@ retry:
 	curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
 	curl_easy_setopt(slot->curl, CURLOPT_FILE, rpc);
 
-	err = run_slot(slot);
+	err = run_slot(slot, NULL);
 	if (err == HTTP_REAUTH && !large_request)
 		goto retry;
 	if (err != HTTP_OK)
-- 
1.8.4.1.898.g8bf8a41.dirty
Previous: Jeff KingNext: Junio C Hamano
Message 6 of 17 in “remote-curl: fix large pushes with GSSAPI”
  1. remote-curl: fix large pushes with GSSAPIbrian m. carlson, Oct 29, 2013
  2. Jeff KingOct 30, 2013
  3. brian m. carlsonOct 30, 2013
  4. Jeff KingOct 31, 2013
  5. 1/3 http: return curl's AUTHAVAIL via slot_resultsJeff King, Oct 31, 2013
  6. 2/3 remote-curl: pass curl slot_results back through run_slotJeff King, Oct 31, 2013
  7. [BUG?] "error: cache entry has null sha1"Junio C Hamano, Oct 31, 2013
  8. Jeff KingOct 31, 2013
  9. Jeff KingOct 31, 2013
  10. Junio C HamanoOct 31, 2013
  11. Re* [BUG?] "error: cache entry has null sha1"Junio C Hamano, Nov 1, 2013
  12. 1/3 unpack-trees: fix "read-tree -u --reset A B" with conflicted indexJunio C Hamano, Nov 1, 2013
  13. 2/3 t1005: reindentJunio C Hamano, Nov 1, 2013
  14. 3/3 t1005: add test for "read-tree --reset -u A B"Junio C Hamano, Nov 1, 2013
  15. Jeff KingNov 3, 2013
  16. 3/3 remote-curl: fix large pushes with GSSAPIJeff King, Oct 31, 2013
  17. brian m. carlsonOct 31, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.