Currently only needed to improve debugging of hanging requests.
unsigned int refcount;
const char *label;
+ struct http_client_request *prev, *next;
+
const char *method, *target;
struct http_url origin_url;
struct http_client_host *hosts_list;
HASH_TABLE_TYPE(http_client_peer) peers;
struct http_client_peer *peers_list;
- unsigned int pending_requests;
+ struct http_client_request *requests_list;
+ unsigned int requests_count;
};
int http_client_init_ssl_ctx(struct http_client *client, const char **error_r);
#include "str.h"
#include "hash.h"
#include "array.h"
+#include "llist.h"
#include "time-util.h"
#include "istream.h"
#include "ostream.h"
}
/* only decrease pending request counter if this request was submitted */
- if (req->state > HTTP_REQUEST_STATE_NEW)
- req->client->pending_requests--;
+ if (req->submitted) {
+ DLLIST_REMOVE(&client->requests_list, req);
+ client->requests_count--;
+ }
http_client_request_debug(req, "Destroy (requests left=%d)",
- client->pending_requests);
+ client->requests_count);
if (req->queue != NULL)
http_client_queue_drop_request(req->queue, req);
- if (client->pending_requests == 0 && client->ioloop != NULL)
+ if (client->requests_count == 0 && client->ioloop != NULL)
io_loop_stop(client->ioloop);
if (req->delayed_error != NULL)
void http_client_request_submit(struct http_client_request *req)
{
- req->client->pending_requests++;
+ struct http_client *client = req->client;
+
req->submit_time = ioloop_timeval;
http_client_request_do_submit(req);
http_client_request_debug(req, "Submitted");
+
req->submitted = TRUE;
+ DLLIST_PREPEND(&client->requests_list, req);
+ client->requests_count++;
}
static void
i_assert(client->ioloop == NULL);
- if (client->pending_requests == 0)
+ if (client->requests_count == 0)
return;
client->ioloop = io_loop_create();
do {
http_client_debug(client,
- "Waiting for %d requests to finish", client->pending_requests);
+ "Waiting for %d requests to finish", client->requests_count);
io_loop_run(client->ioloop);
- } while (client->pending_requests > 0);
+ } while (client->requests_count > 0);
http_client_debug(client, "All requests finished");
unsigned int http_client_get_pending_request_count(struct http_client *client)
{
- return client->pending_requests;
+ return client->requests_count;
}
int http_client_init_ssl_ctx(struct http_client *client, const char **error_r)