]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: Fix user login counters
authorAki Tuomi <aki.tuomi@dovecot.fi>
Sun, 28 Aug 2016 16:14:08 +0000 (19:14 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 29 Aug 2016 06:35:01 +0000 (09:35 +0300)
Before we would count all users twice,
because the same counters would get increment
in both CONNECT and ADD-USER. Now we do not
increment them at all on ADD-USER.

src/stats/mail-domain.c
src/stats/mail-session.c
src/stats/mail-user.c

index 382d1e0d4ae9267b3035c652cb3bb90508eb0cc3..b55f1605e3ad2402b50ed513660694010c32ae9d 100644 (file)
@@ -25,7 +25,6 @@ struct mail_domain *mail_domain_login_create(const char *name)
 
        domain = hash_table_lookup(mail_domains_hash, name);
        if (domain != NULL) {
-               mail_domain_login(domain);
                return domain;
        }
 
@@ -37,7 +36,6 @@ struct mail_domain *mail_domain_login_create(const char *name)
        hash_table_insert(mail_domains_hash, domain->name, domain);
        DLLIST_PREPEND_FULL(&stable_mail_domains, domain,
                            stable_prev, stable_next);
-       mail_domain_login(domain);
        global_memory_alloc(mail_domain_memsize(domain));
        return domain;
 }
@@ -46,7 +44,6 @@ void mail_domain_login(struct mail_domain *domain)
 {
        domain->num_logins++;
        domain->num_connected_sessions++;
-       mail_global_login();
        mail_domain_refresh(domain, NULL);
 }
 
index 3f276f054095f19672f8876b3434b8d5e13333ce..ae6219156bb79863c5b284bfcc1490282fda5082 100644 (file)
@@ -13,6 +13,7 @@
 #include "mail-user.h"
 #include "mail-ip.h"
 #include "mail-session.h"
+#include "mail-domain.h"
 
 /* If session doesn't receive any updates for this long, assume that the
    process associated with it has crashed, and forcibly disconnect the
@@ -107,6 +108,9 @@ int mail_session_connect_parse(const char *const *args, const char **error_r)
                                       mail_session_idle_timeout, session);
 
        session->user = mail_user_login(args[1]);
+       session->user->num_logins++;
+       mail_domain_login(session->user->domain);
+
        for (i = 3; args[i] != NULL; i++) {
                if (strncmp(args[i], "rip=", 4) == 0 &&
                    net_addr2ip(args[i] + 4, &ip) == 0)
@@ -127,6 +131,8 @@ int mail_session_connect_parse(const char *const *args, const char **error_r)
                mail_ip_ref(session->ip);
        }
        global_memory_alloc(mail_session_memsize(session));
+
+       mail_global_login();
        return 0;
 }
 
index 6e0f7b87c6266b94cf0a09e9e91f1f379a861e3f..8f9be2ab254dc4cf0dbd0b1819437df6636e22f0 100644 (file)
@@ -29,9 +29,7 @@ struct mail_user *mail_user_login(const char *username)
 
        user = hash_table_lookup(mail_users_hash, username);
        if (user != NULL) {
-               user->num_logins++;
                mail_user_refresh(user, NULL);
-               mail_domain_login(user->domain);
                return user;
        }
 
@@ -56,7 +54,6 @@ struct mail_user *mail_user_login(const char *username)
                            domain_prev, domain_next);
        mail_domain_ref(user->domain);
 
-       user->num_logins++;
        user->last_update = ioloop_timeval;
        global_memory_alloc(mail_user_memsize(user));
        return user;