]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Use data stack frame with IO context activate/deactive callbacks
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 8 Jan 2021 09:28:26 +0000 (11:28 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 27 Oct 2021 17:18:37 +0000 (17:18 +0000)
These were running outside the regular ioloop data stack frames, so if the
callback used any data stack it kept increasing memory usage.

This fixes excessive memory usage with old_stats plugin when used with
long-running imap sessions. The memory got filled with UPDATE-SESSION
commands.

src/lib/ioloop.c

index 39b171329aeff204a45fd1ac300cf3fdc4b7091b..209fa9999bea6bfa905ebffe4060f9859e7cdf92 100644 (file)
@@ -1181,8 +1181,9 @@ void io_loop_context_activate(struct ioloop_context *ctx)
        io_loop_context_ref(ctx);
        array_foreach_modifiable(&ctx->callbacks, cb) {
                i_assert(!cb->activated);
-               if (cb->activate != NULL)
+               if (cb->activate != NULL) T_BEGIN {
                        cb->activate(cb->context);
+               } T_END;
                cb->activated = TRUE;
        }
 }
@@ -1198,8 +1199,9 @@ void io_loop_context_deactivate(struct ioloop_context *ctx)
                        /* we just added this callback. don't deactivate it
                           before it gets first activated. */
                } else {
-                       if (cb->deactivate != NULL)
+                       if (cb->deactivate != NULL) T_BEGIN {
                                cb->deactivate(cb->context);
+                       } T_END;
                        cb->activated = FALSE;
                }
        }