http.c: Rely on select instead of tracking whether data was received

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> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Mika Fischer committed Nov 4, 2011 at 15:19 UTC df26c471278f13ca6ad96b12a533ef4172323c13
2 files changed +1 -16
http.c
+1 -15
@@ -4,7 +4,6 @@
4 #include "run-command.h"
5 #include "url.h"
6
7 -int data_received;
7 int active_requests;
8 int http_is_verbose;
9 size_t http_post_buffer = 16 * LARGE_PACKET_MAX;
@@ -98,13 +97,11 @@ size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
97 struct strbuf *buffer = buffer_;
98
99 strbuf_add(buffer, ptr, size);
101 - data_received++;
100 return size;
101 }
102
103 size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf)
104 {
107 - data_received++;
105 return eltsize * nmemb;
106 }
107
@@ -629,8 +626,6 @@ void step_active_slots(void)
626 void run_active_slot(struct active_request_slot *slot)
627 {
628 #ifdef USE_CURL_MULTI
632 - long last_pos = 0;
633 - long current_pos;
629 fd_set readfds;
630 fd_set writefds;
631 fd_set excfds;
@@ -640,17 +635,9 @@ void run_active_slot(struct active_request_slot *slot)
635
636 slot->finished = &finished;
637 while (!finished) {
643 - data_received = 0;
638 step_active_slots();
639
646 - if (!data_received && slot->local != NULL) {
647 - current_pos = ftell(slot->local);
648 - if (current_pos > last_pos)
649 - data_received++;
650 - last_pos = current_pos;
651 - }
652 -
653 - if (slot->in_use && !data_received) {
640 + if (slot->in_use) {
641 #if LIBCURL_VERSION_NUM >= 0x070f04
642 long curl_timeout;
643 curl_multi_timeout(curlm, &curl_timeout);
@@ -1208,7 +1195,6 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,
1195 git_SHA1_Update(&freq->c, expn,
1196 sizeof(expn) - freq->stream.avail_out);
1197 } while (freq->stream.avail_in && freq->zret == Z_OK);
1211 - data_received++;
1198 return size;
1199 }
1200
http.h
-1
@@ -89,7 +89,6 @@ extern void step_active_slots(void);
89 extern void http_init(struct remote *remote);
90 extern void http_cleanup(void);
91
92 -extern int data_received;
92 extern int active_requests;
93 extern int http_is_verbose;
94 extern size_t http_post_buffer;