dovecot-2.2: lib-http: Allow caller to find out what state a req...

dovecot at dovecot.org dovecot at dovecot.org
Sun Mar 10 17:19:29 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/5e63f628e3ca
changeset: 16004:5e63f628e3ca
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Mar 10 17:17:47 2013 +0200
description:
lib-http: Allow caller to find out what state a request is in.

diffstat:

 src/lib-http/http-client-private.h |  11 -----------
 src/lib-http/http-client-request.c |  17 +++++++++++++++++
 src/lib-http/http-client.h         |  14 ++++++++++++++
 3 files changed, 31 insertions(+), 11 deletions(-)

diffs (86 lines):

diff -r 0aea43f87c0b -r 5e63f628e3ca src/lib-http/http-client-private.h
--- a/src/lib-http/http-client-private.h	Fri Mar 08 20:25:12 2013 +0200
+++ b/src/lib-http/http-client-private.h	Sun Mar 10 17:17:47 2013 +0200
@@ -30,17 +30,6 @@
 HASH_TABLE_DEFINE_TYPE(http_client_peer, const struct http_client_peer_addr *,
 	struct http_client_peer *);
 
-enum http_request_state {
-	HTTP_REQUEST_STATE_NEW = 0,
-	HTTP_REQUEST_STATE_QUEUED,
-	HTTP_REQUEST_STATE_PAYLOAD_OUT,
-	HTTP_REQUEST_STATE_WAITING,
-	HTTP_REQUEST_STATE_GOT_RESPONSE,
-	HTTP_REQUEST_STATE_PAYLOAD_IN,
-	HTTP_REQUEST_STATE_FINISHED,
-	HTTP_REQUEST_STATE_ABORTED
-};
-
 struct http_client_request {
 	pool_t pool;
 	unsigned int refcount;
diff -r 0aea43f87c0b -r 5e63f628e3ca src/lib-http/http-client-request.c
--- a/src/lib-http/http-client-request.c	Fri Mar 08 20:25:12 2013 +0200
+++ b/src/lib-http/http-client-request.c	Sun Mar 10 17:17:47 2013 +0200
@@ -13,6 +13,17 @@
 
 #include "http-client-private.h"
 
+const char *http_request_state_names[] = {
+	"new",
+	"queued",
+	"payload_out",
+	"waiting",
+	"got_response",
+	"payload_in",
+	"finished",
+	"aborted"
+};
+
 /*
  * Logging
  */
@@ -158,6 +169,12 @@
 		req->payload_sync = TRUE;
 }
 
+enum http_request_state
+http_client_request_get_state(struct http_client_request *req)
+{
+	return req->state;
+}
+
 static void http_client_request_do_submit(struct http_client_request *req)
 {
 	struct http_client_host *host;
diff -r 0aea43f87c0b -r 5e63f628e3ca src/lib-http/http-client.h
--- a/src/lib-http/http-client.h	Fri Mar 08 20:25:12 2013 +0200
+++ b/src/lib-http/http-client.h	Sun Mar 10 17:17:47 2013 +0200
@@ -18,6 +18,18 @@
 	HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT,
 };
 
+enum http_request_state {
+	HTTP_REQUEST_STATE_NEW = 0,
+	HTTP_REQUEST_STATE_QUEUED,
+	HTTP_REQUEST_STATE_PAYLOAD_OUT,
+	HTTP_REQUEST_STATE_WAITING,
+	HTTP_REQUEST_STATE_GOT_RESPONSE,
+	HTTP_REQUEST_STATE_PAYLOAD_IN,
+	HTTP_REQUEST_STATE_FINISHED,
+	HTTP_REQUEST_STATE_ABORTED
+};
+extern const char *http_request_state_names[];
+
 struct http_client_settings {
 	const char *dns_client_socket_path;
 
@@ -75,6 +87,8 @@
 void http_client_request_set_payload(struct http_client_request *req,
 				     struct istream *input, bool sync);
 
+enum http_request_state
+http_client_request_get_state(struct http_client_request *req);
 void http_client_request_submit(struct http_client_request *req);
 void http_client_request_abort(struct http_client_request **req);
 


More information about the dovecot-cvs mailing list