All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: What's cooking in git.git (Apr 2013, #05; Mon, 15)
Date: Mon, 15 Apr 2013 20:30:38 -0400	[thread overview]
Message-ID: <20130416003038.GA5336@sigill.intra.peff.net> (raw)
In-Reply-To: <20130415232532.GA7134@sigill.intra.peff.net>

On Mon, Apr 15, 2013 at 07:25:32PM -0400, Jeff King wrote:

> 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

  parent reply	other threads:[~2013-04-16  0:30 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-15 20:28 What's cooking in git.git (Apr 2013, #05; Mon, 15) Junio C Hamano
2013-04-15 22:24 ` Felipe Contreras
2013-04-15 23:14   ` Junio C Hamano
2013-04-15 23:30     ` Felipe Contreras
2013-04-16  4:12       ` Junio C Hamano
2013-04-16  5:32         ` Felipe Contreras
2013-04-16  9:59       ` Thomas Rast
2013-04-16 19:04         ` Felipe Contreras
2013-04-16 19:19           ` Junio C Hamano
2013-04-16 19:48             ` Felipe Contreras
2013-04-16 22:34               ` Phil Hord
2013-04-16 23:50                 ` Felipe Contreras
2013-04-16 22:45           ` Phil Hord
2013-04-17  4:44             ` Junio C Hamano
2013-04-17 18:50             ` Felipe Contreras
2013-04-17 23:56               ` Junio C Hamano
2013-04-18  3:59                 ` Felipe Contreras
2013-04-18  7:44                   ` Matthieu Moy
2013-04-18  9:15                     ` Felipe Contreras
2013-04-18  9:19               ` Ramkumar Ramachandra
2013-04-18  9:53                 ` Felipe Contreras
2013-04-18 10:27                   ` Ramkumar Ramachandra
2013-04-18 10:55                     ` Felipe Contreras
2013-04-18 11:31                       ` Ramkumar Ramachandra
2013-04-18 12:05                         ` Felipe Contreras
2013-04-18 11:46                       ` Ramkumar Ramachandra
2013-04-18 12:16                         ` Felipe Contreras
2013-04-23 18:49                           ` Ramkumar Ramachandra
2013-04-23 19:11                             ` Felipe Contreras
2013-04-18 20:06               ` Phil Hord
2013-04-18 23:48                 ` Felipe Contreras
2013-04-19 21:07                   ` Phil Hord
2013-04-20  1:29                     ` Felipe Contreras
2013-04-15 23:25 ` Jeff King
2013-04-15 23:49   ` Øyvind A. Holm
2013-04-16  0:53     ` Jeff King
2013-04-16  0:30   ` Jeff King [this message]
2013-04-16  1:08     ` Eric Sunshine
2013-04-16 17:18     ` Junio C Hamano
2013-04-16  3:21 ` Drew Northup
2013-04-16 23:52 ` "What's cooking" between #05 and #06 Junio C Hamano
2013-04-17  8:40   ` John Keeping
2013-04-17 15:30     ` Junio C Hamano
2013-04-17 21:25   ` Jens Lehmann
2013-04-18  8:49     ` John Keeping
2013-04-17  8:49 ` What's cooking in git.git (Apr 2013, #05; Mon, 15) Lukas Fleischer
2013-04-17 15:11   ` Junio C Hamano
2013-04-17  9:47 ` Thomas Rast
2013-04-17 15:24   ` Junio C Hamano
2013-04-17 15:56     ` Thomas Rast
2013-04-17 17:08       ` Junio C Hamano
2013-04-17 18:14         ` Junio C Hamano
2013-04-17 20:10           ` Jeff King
2013-04-18  1:39             ` Junio C Hamano
2013-04-18  1:47               ` [PATCH] git add <pathspec>... defaults to "-A" Junio C Hamano
2013-04-18 17:27               ` What's cooking in git.git (Apr 2013, #05; Mon, 15) Jeff King
2013-04-18 17:51                 ` Junio C Hamano
2013-04-18 18:00                   ` Jeff King
2013-04-18 18:16                     ` Junio C Hamano
2013-04-18 20:30                       ` Jeff King
2013-04-18 21:37                         ` Junio C Hamano
2013-04-18 21:44                           ` Jeff King
2013-04-18 22:10                             ` Junio C Hamano
2013-04-19  4:14                               ` Jeff King
2013-04-19  4:31                               ` Jonathan Nieder
2013-04-19 17:25                                 ` Junio C Hamano
2013-04-19 21:34                                   ` Jeff King
2013-04-19 21:56                                     ` Junio C Hamano
2013-04-21  7:39                                     ` jc/add-2.0-delete-default (Re: What's cooking in git.git (Apr 2013, #05; Mon, 15)) Jonathan Nieder
2013-04-22  1:51                                       ` Junio C Hamano
2013-04-22  4:54                                         ` Junio C Hamano
2013-04-22 20:43                                           ` [PATCH 0/2] "git add -A/--no-all" finishing touches Junio C Hamano
2013-04-22 20:43                                             ` [PATCH 1/2] git add: --ignore-removal is a better named --no-all Junio C Hamano
2013-04-22 20:43                                             ` [PATCH 2/2] git add: rephrase -A/--no-all warning Junio C Hamano
2013-04-22 22:41                                             ` [PATCH 3/2] git add <pathspec>... defaults to "-A" Junio C Hamano
2013-04-23  0:42                                               ` Eric Sunshine
2013-04-25 23:06                                             ` [PATCH 0/2] "git add -A/--no-all" finishing touches Junio C Hamano
2013-04-25 23:19                                               ` Junio C Hamano
2013-04-25 23:24                                                 ` Jonathan Nieder
2013-04-25 23:41                                                   ` Junio C Hamano
2013-04-25 23:44                                                     ` Junio C Hamano
2013-04-25 23:56                                                       ` Jonathan Nieder
2013-04-26  0:14                                                         ` Junio C Hamano
2013-04-26 20:44                                                           ` Junio C Hamano
2013-04-26 21:30                                                             ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130416003038.GA5336@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.