Mercurial > dovecot > core-2.2
view src/stats/mail-stats.h @ 22715:20415dd0b85a
dsync: Add per-mailbox sync lock that is always used.
Both importing and exporting gets the lock before they even sync the
mailbox. The lock is kept until the import/export finishes. This guarantees
that no matter how dsync is run, two dsyncs can't be working on the same
mailbox at the same time.
This lock is in addition to the optional per-user lock enabled by the -l
parameter. If the -l parameter is used, the same lock timeout is used for
the per-mailbox lock. Otherwise 30s timeout is used.
This should help to avoid email duplication when replication is enabled for
public namespaces, and maybe in some other rare situations as well.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 28 Dec 2017 14:10:23 +0200 |
parents | 968da3b58769 |
children |
line wrap: on
line source
#ifndef MAIL_STATS_H #define MAIL_STATS_H #include <sys/time.h> #include "net.h" #include "guid.h" #include "stats.h" struct stats_send_ctx; struct mail_command { struct mail_command *stable_prev, *stable_next; struct mail_command *session_prev, *session_next; struct mail_session *session; char *name, *args; /* non-zero id means the command is still running */ unsigned int id; struct timeval last_update; struct stats *stats; int refcount; }; struct mail_session { struct mail_session *stable_prev, *stable_next; struct mail_session *sorted_prev, *sorted_next; struct mail_session *user_prev, *user_next; struct mail_session *ip_prev, *ip_next; /* if id="", the session no longer exists */ char *id; struct mail_user *user; const char *service; pid_t pid; /* ip address may be NULL if there's none */ struct mail_ip *ip; struct timeout *to_idle; struct stats *stats; struct timeval last_update; unsigned int num_cmds; bool disconnected; unsigned int highest_cmd_id; int refcount; struct mail_command *commands; }; struct mail_user { struct mail_user *stable_prev, *stable_next; struct mail_user *sorted_prev, *sorted_next; struct mail_user *domain_prev, *domain_next; char *name; struct mail_domain *domain; time_t reset_timestamp; struct timeval last_update; struct stats *stats; unsigned int num_logins; unsigned int num_cmds; int refcount; struct mail_session *sessions; }; struct mail_domain { struct mail_domain *stable_prev, *stable_next; struct mail_domain *sorted_prev, *sorted_next; char *name; time_t reset_timestamp; struct timeval last_update; struct stats *stats; unsigned int num_logins; unsigned int num_cmds; unsigned int num_connected_sessions; int refcount; struct mail_user *users; }; struct mail_ip { struct mail_ip *stable_prev, *stable_next; struct mail_ip *sorted_prev, *sorted_next; struct ip_addr ip; time_t reset_timestamp; struct timeval last_update; struct stats *stats; unsigned int num_logins; unsigned int num_cmds; unsigned int num_connected_sessions; int refcount; struct mail_session *sessions; }; struct mail_global { time_t reset_timestamp; struct timeval last_update; struct stats *stats; unsigned int num_logins; unsigned int num_cmds; unsigned int num_connected_sessions; struct timeout *to_stats_send; struct stats_send_ctx *stats_send_ctx; }; extern struct mail_global mail_global_stats; void mail_global_init(void); void mail_global_deinit(void); void mail_global_login(void); void mail_global_disconnected(void); void mail_global_refresh(const struct stats *diff_stats); #endif