]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Drop the ioloop switch callback before freeing the global client...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 18 May 2018 13:56:15 +0000 (15:56 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 7 Jun 2018 07:13:57 +0000 (10:13 +0300)
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).

src/lib-http/http-client.c

index 1c4f89ad4e4b2940bd43759379e49b173b535a8a..4b4e7cce04fbc6426e530831587d9ee441fc5108 100644 (file)
@@ -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)