Skip to content

Commit

Permalink
stats plugin: Fix /proc/self/io fd leak on plugin deinit
Browse files Browse the repository at this point in the history
This could have been a problem with doveadm-server processes if they had
service_count>1, because doveadm unloads all plugins between commands.
  • Loading branch information
sirainen authored and GitLab committed Jan 17, 2017
1 parent 07af8ef commit 3d88d8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/plugins/stats/mail-stats-fill.c
Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions src/plugins/stats/mail-stats.h
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/plugins/stats/stats-plugin.c
Expand Up @@ -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);
}

0 comments on commit 3d88d8e

Please sign in to comment.