dovecot-2.2: lib-http: Added http_client_request_set_destroy_cal...

dovecot at dovecot.org dovecot at dovecot.org
Mon Feb 4 20:11:06 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/e11b9ba8b90a
changeset: 15723:e11b9ba8b90a
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Feb 04 20:10:59 2013 +0200
description:
lib-http: Added http_client_request_set_destroy_callback()
This is useful for io_remove()ing the payload stream's fd at the right time.

diffstat:

 src/lib-http/http-client-private.h |   3 +++
 src/lib-http/http-client-request.c |  11 +++++++++++
 src/lib-http/http-client.h         |   5 +++++
 3 files changed, 19 insertions(+), 0 deletions(-)

diffs (53 lines):

diff -r b1a03d3c0ae7 -r e11b9ba8b90a src/lib-http/http-client-private.h
--- a/src/lib-http/http-client-private.h	Mon Feb 04 18:17:21 2013 +0200
+++ b/src/lib-http/http-client-private.h	Mon Feb 04 20:10:59 2013 +0200
@@ -66,6 +66,9 @@
 	http_client_request_callback_t *callback;
 	void *context;
 
+	void (*destroy_callback)(void *);
+	void *destroy_context;
+
 	enum http_request_state state;
 
 	unsigned int payload_sync:1;
diff -r b1a03d3c0ae7 -r e11b9ba8b90a src/lib-http/http-client-request.c
--- a/src/lib-http/http-client-request.c	Mon Feb 04 18:17:21 2013 +0200
+++ b/src/lib-http/http-client-request.c	Mon Feb 04 20:10:59 2013 +0200
@@ -412,6 +412,9 @@
 	req->callback = NULL;
 	req->state = HTTP_REQUEST_STATE_FINISHED;
 
+	if (req->destroy_callback != NULL)
+		req->destroy_callback(req->destroy_context);
+
 	if (req->payload_wait && req->client->ioloop != NULL)
 		io_loop_stop(req->client->ioloop);
 	http_client_request_unref(_req);
@@ -581,3 +584,11 @@
 	/* resubmit */
 	http_client_request_resubmit(req);
 }
+
+void http_client_request_set_destroy_callback(struct http_client_request *req,
+					      void (*callback)(void *),
+					      void *context)
+{
+	req->destroy_callback = callback;
+	req->destroy_context = context;
+}
diff -r b1a03d3c0ae7 -r e11b9ba8b90a src/lib-http/http-client.h
--- a/src/lib-http/http-client.h	Mon Feb 04 18:17:21 2013 +0200
+++ b/src/lib-http/http-client.h	Mon Feb 04 20:10:59 2013 +0200
@@ -78,6 +78,11 @@
 void http_client_request_submit(struct http_client_request *req);
 void http_client_request_abort(struct http_client_request **req);
 
+/* Call the specified callback when HTTP request is destroyed. */
+void http_client_request_set_destroy_callback(struct http_client_request *req,
+					      void (*callback)(void *),
+					      void *context);
+
 /* submits request and blocks until provided payload is sent. Multiple calls
    are allowed; payload transmission is ended when data == NULL. */
 int http_client_request_send_payload(struct http_client_request **req,


More information about the dovecot-cvs mailing list