git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Fischer <mika.fischer@zoopnet.de>
To: git@vger.kernel.org
Cc: gitster@pobox.com, daniel@haxx.se, peff@peff.net,
	Mika Fischer <mika.fischer@zoopnet.de>
Subject: [PATCH v3 3/3] http.c: Rely on select instead of tracking whether data was received
Date: Fri,  4 Nov 2011 15:19:27 +0100	[thread overview]
Message-ID: <1320416367-28843-4-git-send-email-mika.fischer@zoopnet.de> (raw)
In-Reply-To: <1320416367-28843-1-git-send-email-mika.fischer@zoopnet.de>

Since now select is used with the file descriptors of the http connections,
tracking whether data was received recently (and trying to read more in
that case) is no longer necessary. Instead, always call select and rely on
it to return as soon as new data can be read.

Signed-off-by: Mika Fischer <mika.fischer@zoopnet.de>
---
 http.c |   16 +---------------
 http.h |    1 -
 2 files changed, 1 insertions(+), 16 deletions(-)

diff --git a/http.c b/http.c
index e91a2ab..3c6a00b 100644
--- a/http.c
+++ b/http.c
@@ -4,7 +4,6 @@
 #include "run-command.h"
 #include "url.h"
 
-int data_received;
 int active_requests;
 int http_is_verbose;
 size_t http_post_buffer = 16 * LARGE_PACKET_MAX;
@@ -99,13 +98,11 @@ size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
 	struct strbuf *buffer = buffer_;
 
 	strbuf_add(buffer, ptr, size);
-	data_received++;
 	return size;
 }
 
 size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf)
 {
-	data_received++;
 	return eltsize * nmemb;
 }
 
@@ -642,8 +639,6 @@ void step_active_slots(void)
 void run_active_slot(struct active_request_slot *slot)
 {
 #ifdef USE_CURL_MULTI
-	long last_pos = 0;
-	long current_pos;
 	fd_set readfds;
 	fd_set writefds;
 	fd_set excfds;
@@ -656,17 +651,9 @@ void run_active_slot(struct active_request_slot *slot)
 
 	slot->finished = &finished;
 	while (!finished) {
-		data_received = 0;
 		step_active_slots();
 
-		if (!data_received && slot->local != NULL) {
-			current_pos = ftell(slot->local);
-			if (current_pos > last_pos)
-				data_received++;
-			last_pos = current_pos;
-		}
-
-		if (slot->in_use && !data_received) {
+		if (slot->in_use) {
 #if LIBCURL_VERSION_NUM >= 0x070f04
 			curl_multi_timeout(curlm, &curl_timeout);
 			if (curl_timeout == 0) {
@@ -1232,7 +1219,6 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,
 		git_SHA1_Update(&freq->c, expn,
 				sizeof(expn) - freq->stream.avail_out);
 	} while (freq->stream.avail_in && freq->zret == Z_OK);
-	data_received++;
 	return size;
 }
 
diff --git a/http.h b/http.h
index 3c332a9..71bdf58 100644
--- a/http.h
+++ b/http.h
@@ -89,7 +89,6 @@ extern void step_active_slots(void);
 extern void http_init(struct remote *remote, const char *url);
 extern void http_cleanup(void);
 
-extern int data_received;
 extern int active_requests;
 extern int http_is_verbose;
 extern size_t http_post_buffer;
-- 
1.7.8.rc0.35.gd9f16.dirty

  parent reply	other threads:[~2011-11-04 14:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-02 20:21 [PATCHv2] Improve use of select in http backend Mika Fischer
2011-11-02 20:21 ` [PATCH 1/2] http.c: Use curl_multi_fdset to select on curl fds instead of just sleeping Mika Fischer
2011-11-02 20:32   ` Jeff King
2011-11-02 20:35     ` Jeff King
2011-11-02 21:26       ` Junio C Hamano
2011-11-02 22:22     ` Mika Fischer
2011-11-02 22:40       ` Daniel Stenberg
2011-11-02 20:21 ` [PATCH 2/2] http.c: Use timeout suggested by curl instead of fixed 50ms timeout Mika Fischer
2011-11-03 23:14 ` [PATCHv2] Improve use of select in http backend Junio C Hamano
2011-11-04 14:19 ` [PATCH v3 0/3] " Mika Fischer
2011-11-04 14:19   ` [PATCH v3 1/3] http.c: Use curl_multi_fdset to select on curl fds instead of just sleeping Mika Fischer
2011-11-04 14:19   ` [PATCH v3 2/3] http.c: Use timeout suggested by curl instead of fixed 50ms timeout Mika Fischer
2011-11-04 17:13     ` Junio C Hamano
2011-11-04 17:47       ` Mika Fischer
2011-11-04 17:51         ` Jeff King
2011-11-04 17:55           ` Mika Fischer
2011-11-04 18:02         ` Junio C Hamano
2011-11-04 14:19   ` Mika Fischer [this message]
2011-11-04 17:53   ` [PATCH v3 0/3] Improve use of select in http backend Jeff King

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=1320416367-28843-4-git-send-email-mika.fischer@zoopnet.de \
    --to=mika.fischer@zoopnet.de \
    --cc=daniel@haxx.se \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).