Skip to content

Commit

Permalink
stats: Fix user login counters
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmouse authored and thuovila committed Aug 29, 2016
1 parent 7ba262b commit ea0bb9e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/stats/mail-domain.c
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -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);
}

Expand Down
6 changes: 6 additions & 0 deletions src/stats/mail-session.c
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}

Expand Down
3 changes: 0 additions & 3 deletions src/stats/mail-user.c
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down

0 comments on commit ea0bb9e

Please sign in to comment.