From: Stephan Bosch Date: Fri, 18 May 2018 13:56:15 +0000 (+0200) Subject: lib-http: client: Drop the ioloop switch callback before freeing the global client... X-Git-Tag: 2.3.2.rc1~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ca66aa9ed83abf7d238de3710024228421e65660;p=thirdparty%2Fdovecot%2Fcore.git lib-http: client: Drop the ioloop switch callback before freeing the global client context. This removes the possibility of recursion when the client context object somehow triggers an ioloop switch (e.g., when debug logging starts blocking at that inopportune moment). --- diff --git a/src/lib-http/http-client.c b/src/lib-http/http-client.c index 1c4f89ad4e..4b4e7cce04 100644 --- a/src/lib-http/http-client.c +++ b/src/lib-http/http-client.c @@ -691,11 +691,6 @@ void http_client_context_switch_ioloop(struct http_client_context *cctx) http_client_context_do_switch_ioloop(cctx); } -static void http_client_global_context_free(void) -{ - http_client_context_unref(&http_client_global_context); -} - static void http_client_global_context_ioloop_switched( struct ioloop *prev_ioloop ATTR_UNUSED) @@ -713,6 +708,15 @@ http_client_global_context_ioloop_switched( } } +static void http_client_global_context_free(void) +{ + /* drop ioloop switch callback to make absolutely sure there is no + recursion. */ + io_loop_remove_switch_callback(http_client_global_context_ioloop_switched); + + http_client_context_unref(&http_client_global_context); +} + struct http_client_context *http_client_get_global_context(void) { if (http_client_global_context != NULL)