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

Re: What's cooking in git.git (Apr 2013, #05; Mon, 15)

From
Jeff King <peff@peff.net>
Date
Apr 16, 2013, 00:30 UTC
Message-ID
<20130416003038.GA5336@sigill.intra.peff.net>
In-Reply-To
<20130415232532.GA7134@sigill.intra.peff.net>
On Mon, Apr 15, 2013 at 07:25:32PM -0400, Jeff King wrote:
Show 11 quoted lines
> On Mon, Apr 15, 2013 at 01:28:53PM -0700, Junio C Hamano wrote:
> 
> > * jk/http-error-messages (2013-04-06) 9 commits
> [...]
> ...the tip of your current master does not currently pass the test
> suite[1]. I bisected the problem to "show server content on http
> errors" from the above topic, but haven't figure it out past that. I
> typically run "make test" before submitting, so I'm guessing it is an
> interaction with another topic that graduated around the same time
> (though it's also possible that I just failed to test after the last
> rebase).
This patch on top of jk/http-error-messages fixes it.
-- >8 --
Subject: [PATCH] http: set curl FAILONERROR each time we select a handle

Because we reuse curl handles for multiple requests, the setup of a handle happens in two stages: stable, global setup and per-request setup. The lifecycle of a handle is something like:

  1. get_curl_handle; do basic global setup that will last
     through the whole program (e.g., setting the user
     agent, ssl options, etc)
  2. get_active_slot; set up a per-request baseline (e.g.,
     clearing the read/write functions, making it a GET
     request, etc)
  3. perform the request with curl_*_perform functions
  4. goto step 2 to perform another request

Breaking it down this way means we can avoid doing global setup from step (1) repeatedly, but we still finish step (2) with a predictable baseline setup that callers can rely on.

Until commit 6d052d7 (http: add HTTP_KEEP_ERROR option, 2013-04-05), setting curl's FAILONERROR option was a global setup; we never changed it. However, 6d052d7 introduced in option where some requests might turn off FAILONERROR. Later requests using the same handle would have the option unexpectedly turned off, which meant they would not notice http failures at all.

This could easily be seen in the test-suite for the "half-auth" cases of t5541 and t5551. The initial requests turned off FAILONERROR, which meant it was erroneously off for the rpc POST. That worked fine for a successful request, but meant that we failed to react properly to the HTTP 401 (instead, we treated whatever the server handed us as a successful message body).

The solution is simple: now that FAILONERROR is a per-request setting, we move it to get_active_slot to make sure it is reset for each request.

Signed-off-by: Jeff King <peff@peff.net>
---
Hmph. I have no idea how this ever passed the tests, so I can only
assume that I screwed up in running them. I even recall considering this
issue while writing the patches, but I mixed up which of get_curl_handle
and get_active_slot it needed to be in when I did so.
 http.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/http.c b/http.c
index 58c063c..48d4ff6 100644
--- a/http.c
+++ b/http.c
@@ -282,7 +282,6 @@ static CURL *get_curl_handle(void)
 #endif
 	if (ssl_cainfo != NULL)
 		curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
-	curl_easy_setopt(result, CURLOPT_FAILONERROR, 1);
 
 	if (curl_low_speed_limit > 0 && curl_low_speed_time > 0) {
 		curl_easy_setopt(result, CURLOPT_LOW_SPEED_LIMIT,
@@ -506,6 +505,7 @@ struct active_request_slot *get_active_slot(void)
 	curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
 	curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
 	curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
+	curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);
 	if (http_auth.password)
 		init_curl_http_auth(slot->curl);
 
-- 
1.8.2.8.g44e4c28
Previous: Jeff KingNext: Eric Sunshine
Message 37 of 85 in “What's cooking in git.git (Apr 2013, #05; Mon, 15)”
  1. Junio C HamanoApr 15, 2013
  2. Felipe ContrerasApr 15, 2013
  3. Junio C HamanoApr 15, 2013
  4. Felipe ContrerasApr 15, 2013
  5. Junio C HamanoApr 16, 2013
  6. Felipe ContrerasApr 16, 2013
  7. Thomas RastApr 16, 2013
  8. Felipe ContrerasApr 16, 2013
  9. Junio C HamanoApr 16, 2013
  10. Felipe ContrerasApr 16, 2013
  11. Phil HordApr 16, 2013
  12. Felipe ContrerasApr 16, 2013
  13. Phil HordApr 16, 2013
  14. Junio C HamanoApr 17, 2013
  15. Felipe ContrerasApr 17, 2013
  16. Junio C HamanoApr 17, 2013
  17. Felipe ContrerasApr 18, 2013
  18. Matthieu MoyApr 18, 2013
  19. Felipe ContrerasApr 18, 2013
  20. Ramkumar RamachandraApr 18, 2013
  21. Felipe ContrerasApr 18, 2013
  22. Ramkumar RamachandraApr 18, 2013
  23. Felipe ContrerasApr 18, 2013
  24. Ramkumar RamachandraApr 18, 2013
  25. Felipe ContrerasApr 18, 2013
  26. Ramkumar RamachandraApr 18, 2013
  27. Felipe ContrerasApr 18, 2013
  28. Ramkumar RamachandraApr 23, 2013
  29. Felipe ContrerasApr 23, 2013
  30. Phil HordApr 18, 2013
  31. Felipe ContrerasApr 18, 2013
  32. Phil HordApr 19, 2013
  33. Felipe ContrerasApr 20, 2013
  34. Jeff KingApr 15, 2013
  35. Øyvind A. HolmApr 15, 2013
  36. Jeff KingApr 16, 2013
  37. Jeff KingApr 16, 2013
  38. Eric SunshineApr 16, 2013
  39. Junio C HamanoApr 16, 2013
  40. Drew NorthupApr 16, 2013
  41. "What's cooking" between #05 and #06Junio C Hamano, Apr 16, 2013
  42. John KeepingApr 17, 2013
  43. Junio C HamanoApr 17, 2013
  44. Jens LehmannApr 17, 2013
  45. John KeepingApr 18, 2013
  46. Lukas FleischerApr 17, 2013
  47. Junio C HamanoApr 17, 2013
  48. Thomas RastApr 17, 2013
  49. Junio C HamanoApr 17, 2013
  50. Thomas RastApr 17, 2013
  51. Junio C HamanoApr 17, 2013
  52. Junio C HamanoApr 17, 2013
  53. Jeff KingApr 17, 2013
  54. Junio C HamanoApr 18, 2013
  55. git add <pathspec>... defaults to "-A"Junio C Hamano, Apr 18, 2013
  56. Jeff KingApr 18, 2013
  57. Junio C HamanoApr 18, 2013
  58. Jeff KingApr 18, 2013
  59. Junio C HamanoApr 18, 2013
  60. Jeff KingApr 18, 2013
  61. Junio C HamanoApr 18, 2013
  62. Jeff KingApr 18, 2013
  63. Junio C HamanoApr 18, 2013
  64. Jeff KingApr 19, 2013
  65. Jonathan NiederApr 19, 2013
  66. Junio C HamanoApr 19, 2013
  67. Jeff KingApr 19, 2013
  68. Junio C HamanoApr 19, 2013
  69. jc/add-2.0-delete-default (Re: What's cooking in git.git (Apr 2013, #05; Mon, 15))Jonathan Nieder, Apr 21, 2013
  70. Junio C HamanoApr 22, 2013
  71. Junio C HamanoApr 22, 2013
  72. 0/2 "git add -A/--no-all" finishing touchesJunio C Hamano, Apr 22, 2013
  73. 1/2 git add: --ignore-removal is a better named --no-allJunio C Hamano, Apr 22, 2013
  74. 2/2 git add: rephrase -A/--no-all warningJunio C Hamano, Apr 22, 2013
  75. 3/2 git add <pathspec>... defaults to "-A"Junio C Hamano, Apr 22, 2013
  76. Eric SunshineApr 23, 2013
  77. Junio C HamanoApr 25, 2013
  78. Junio C HamanoApr 25, 2013
  79. Jonathan NiederApr 25, 2013
  80. Junio C HamanoApr 25, 2013
  81. Junio C HamanoApr 25, 2013
  82. Jonathan NiederApr 25, 2013
  83. Junio C HamanoApr 26, 2013
  84. Junio C HamanoApr 26, 2013
  85. Jonathan NiederApr 26, 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.