dovecot-2.2: lib-http: client: Created list of all submitted req...

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 20 15:55:25 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/3a1d89b45c12
changeset: 17972:3a1d89b45c12
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Mon Oct 20 08:54:27 2014 -0700
description:
lib-http: client: Created list of all submitted requests.
Currently only needed to improve debugging of hanging requests.

diffstat:

 src/lib-http/http-client-private.h |   5 ++++-
 src/lib-http/http-client-request.c |  17 ++++++++++++-----
 src/lib-http/http-client.c         |   8 ++++----
 3 files changed, 20 insertions(+), 10 deletions(-)

diffs (107 lines):

diff -r 1ddc6c86de78 -r 3a1d89b45c12 src/lib-http/http-client-private.h
--- a/src/lib-http/http-client-private.h	Mon Oct 20 08:54:27 2014 -0700
+++ b/src/lib-http/http-client-private.h	Mon Oct 20 08:54:27 2014 -0700
@@ -52,6 +52,8 @@
 	unsigned int refcount;
 	const char *label;
 
+	struct http_client_request *prev, *next;
+
 	const char *method, *target;
 	struct http_url origin_url;
 
@@ -245,7 +247,8 @@
 	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);
diff -r 1ddc6c86de78 -r 3a1d89b45c12 src/lib-http/http-client-request.c
--- a/src/lib-http/http-client-request.c	Mon Oct 20 08:54:27 2014 -0700
+++ b/src/lib-http/http-client-request.c	Mon Oct 20 08:54:27 2014 -0700
@@ -5,6 +5,7 @@
 #include "str.h"
 #include "hash.h"
 #include "array.h"
+#include "llist.h"
 #include "time-util.h"
 #include "istream.h"
 #include "ostream.h"
@@ -164,16 +165,18 @@
 	}
 
 	/* 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)
@@ -483,12 +486,16 @@
 
 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
diff -r 1ddc6c86de78 -r 3a1d89b45c12 src/lib-http/http-client.c
--- a/src/lib-http/http-client.c	Mon Oct 20 08:54:27 2014 -0700
+++ b/src/lib-http/http-client.c	Mon Oct 20 08:54:27 2014 -0700
@@ -228,7 +228,7 @@
 
 	i_assert(client->ioloop == NULL);
 
-	if (client->pending_requests == 0)
+	if (client->requests_count == 0)
 		return;
 
 	client->ioloop = io_loop_create();
@@ -242,9 +242,9 @@
 
 	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");
 
@@ -258,7 +258,7 @@
 
 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)


More information about the dovecot-cvs mailing list