Skip to content

Commit df26c47

Browse files
mika-fischergitster
authored andcommitted
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 <[email protected]> Helped-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eb56c82 commit df26c47

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

http.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "run-command.h"
55
#include "url.h"
66

7-
int data_received;
87
int active_requests;
98
int http_is_verbose;
109
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_)
9897
struct strbuf *buffer = buffer_;
9998

10099
strbuf_add(buffer, ptr, size);
101-
data_received++;
102100
return size;
103101
}
104102

105103
size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf)
106104
{
107-
data_received++;
108105
return eltsize * nmemb;
109106
}
110107

@@ -629,8 +626,6 @@ void step_active_slots(void)
629626
void run_active_slot(struct active_request_slot *slot)
630627
{
631628
#ifdef USE_CURL_MULTI
632-
long last_pos = 0;
633-
long current_pos;
634629
fd_set readfds;
635630
fd_set writefds;
636631
fd_set excfds;
@@ -640,17 +635,9 @@ void run_active_slot(struct active_request_slot *slot)
640635

641636
slot->finished = &finished;
642637
while (!finished) {
643-
data_received = 0;
644638
step_active_slots();
645639

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) {
654641
#if LIBCURL_VERSION_NUM >= 0x070f04
655642
long curl_timeout;
656643
curl_multi_timeout(curlm, &curl_timeout);
@@ -1208,7 +1195,6 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,
12081195
git_SHA1_Update(&freq->c, expn,
12091196
sizeof(expn) - freq->stream.avail_out);
12101197
} while (freq->stream.avail_in && freq->zret == Z_OK);
1211-
data_received++;
12121198
return size;
12131199
}
12141200

http.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ extern void step_active_slots(void);
8989
extern void http_init(struct remote *remote);
9090
extern void http_cleanup(void);
9191

92-
extern int data_received;
9392
extern int active_requests;
9493
extern int http_is_verbose;
9594
extern size_t http_post_buffer;

0 commit comments

Comments
 (0)