Mercurial > dovecot > core-2.2
changeset 15723:e11b9ba8b90a
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.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 04 Feb 2013 20:10:59 +0200 |
parents | b1a03d3c0ae7 |
children | 595c00f289bf |
files | src/lib-http/http-client-private.h src/lib-http/http-client-request.c src/lib-http/http-client.h |
diffstat | 3 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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; +}
--- 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,