]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats plugin: Fix /proc/self/io fd leak on plugin deinit
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 17 Jan 2017 14:28:10 +0000 (16:28 +0200)
committerGitLab <gitlab@git.dovecot.net>
Tue, 17 Jan 2017 17:35:04 +0000 (19:35 +0200)
This could have been a problem with doveadm-server processes if they had
service_count>1, because doveadm unloads all plugins between commands.

src/plugins/stats/mail-stats-fill.c
src/plugins/stats/mail-stats.h
src/plugins/stats/stats-plugin.c

index 07561a9b89caaa5818cd99e90de3fbb73c8fa1bb..d706450d34650286c7ae30331781e57b56994b66 100644 (file)
@@ -141,3 +141,9 @@ void mail_stats_fill(struct stats_user *suser, struct mail_stats *stats_r)
        process_read_io_stats(stats_r);
        user_trans_stats_get(suser, stats_r);
 }
+
+void mail_stats_fill_global_deinit(void)
+{
+       if (proc_io_fd != -1)
+               i_close_fd(&proc_io_fd);
+}
index 0663dae06991900b32a603b31582d061cac4a2d1..fc536325e011757c072dc65bffcd0f638056d787 100644 (file)
@@ -35,4 +35,6 @@ void mail_stats_fill(struct stats_user *suser, struct mail_stats *mail_stats);
 void mail_stats_add_transaction(struct mail_stats *stats,
                                const struct mailbox_transaction_stats *trans_stats);
 
+void mail_stats_fill_global_deinit(void);
+
 #endif
index 7cd744ce1c8d747a6bcfae29bd900cad6ee909c2..d843c5915a90ebb429298e62a17b978a4e0e1fea 100644 (file)
@@ -469,6 +469,7 @@ void stats_plugin_deinit(void)
 {
        if (global_stats_conn != NULL)
                stats_connection_unref(&global_stats_conn);
+       mail_stats_fill_global_deinit();
        mail_storage_hooks_remove(&stats_mail_storage_hooks);
        stats_unregister(&mail_stats_item);
 }