if (len < 0) {
perror("read");
Requests = r->next;
+ free(r);
+ noutstanding--;
return -1;
}
if (len == 0) {
struct _r *r;
struct _r *nextr;
int x;
+ int timeouts;
while (!done_reading_urls || noutstanding) {
+ if (timeouts == 20) {
+ close(pconn_fd);
+ pconn_fd = -1;
+ r = Requests;
+ Requests = Requests->next;
+ free(r);
+ noutstanding--;
+ }
if (pconn_fd < 0) {
pconn_fd = open_http_socket();
if (pconn_fd < 0) {
free(r);
noutstanding--;
}
+ timeouts = 0;
}
if (noutstanding < 10 && !done_reading_urls) {
char *t;
if ((t = strchr(buf, '\n')))
*t = '\0';
send_request(pconn_fd, buf);
+ timeouts = 0;
}
FD_ZERO(&R);
to.tv_sec = 1;
continue;
} else if (x == 0) {
assert(Requests != NULL);
- fprintf(stderr, "TIMEOUT waiting for %s\n", Requests->url);
+ fprintf(stderr, "TIMEOUT %s; %d, %d\n", Requests->url,
+ ++timeouts, noutstanding);
continue;
}
if (FD_ISSET(pconn_fd, &R)) {
+ timeouts = 0;
if (read_reply(pconn_fd) != 0)
pconn_fd = -1;
}