This will shrink the diff for the following changes.
struct director *dir = conn->dir;
struct user *user;
bool ret = FALSE, unset_weak_user = FALSE;
+ struct user_directory *users = dir->users;
*forced_r = FALSE;
- user = user_directory_lookup(dir->users, username_hash);
+ user = user_directory_lookup(users, username_hash);
if (user == NULL) {
- *user_r = user_directory_add(dir->users, username_hash,
+ *user_r = user_directory_add(users, username_hash,
host, timestamp);
(*user_r)->weak = weak;
dir_debug("user refresh: %u added", username_hash);
/* weak user marked again as weak */
}
} else if (weak &&
- !user_directory_user_is_recently_updated(dir->users, user)) {
+ !user_directory_user_is_recently_updated(users, user)) {
/* mark the user as weak */
dir_debug("user refresh: %u set weak", username_hash);
user->weak = TRUE;
ret = TRUE;
} else if (user->host == host) {
/* update to the same host */
- } else if (user_directory_user_is_near_expiring(dir->users, user)) {
+ } else if (user_directory_user_is_near_expiring(users, user)) {
/* host conflict for a user that is already near expiring. we can
assume that the other director had already dropped this user
and we should have as well. use the new host. */
ret = TRUE;
}
if (timestamp == ioloop_time && (time_t)user->timestamp != timestamp) {
- user_directory_refresh(dir->users, user);
+ user_directory_refresh(users, user);
ret = TRUE;
}
dir_debug("user refresh: %u refreshed timeout to %ld",
const char *tag)
{
struct director *dir = request->dir;
+ struct user_directory *users = dir->users;
struct mail_host *host;
if (USER_IS_BEING_KILLED(user)) {
request->username_hash);
return FALSE;
}
- if (!user_directory_user_is_near_expiring(dir->users, user))
+ if (!user_directory_user_is_near_expiring(users, user))
return TRUE;
/* user is close to being expired. another director may have
bool director_request_continue(struct director_request *request)
{
struct director *dir = request->dir;
+ struct user_directory *users = dir->users;
struct mail_host *host;
struct user *user;
const char *tag;
return FALSE;
}
- user = user_directory_lookup(dir->users, request->username_hash);
+ user = user_directory_lookup(users, request->username_hash);
tag = request->username_tag == NULL ? "" : request->username_tag;
if (user != NULL) {
if (!director_request_existing(request, user, tag))
return FALSE;
- user_directory_refresh(dir->users, user);
+ user_directory_refresh(users, user);
dir_debug("request: %u refreshed timeout to %u",
request->username_hash, user->timestamp);
} else {
request->username_hash);
return FALSE;
}
- user = user_directory_add(dir->users, request->username_hash,
+ user = user_directory_add(users, request->username_hash,
host, ioloop_time);
dir_debug("request: %u added timeout to %u (hosts_hash=%u)",
request->username_hash, user->timestamp,
struct director_host *orig_src,
struct mail_host *host)
{
+ struct user_directory *users = dir->users;
+
if (src != NULL) {
if (orig_src == NULL) {
orig_src = dir->self_host;
orig_src->last_seq, net_ip2addr(&host->ip)));
}
- user_directory_remove_host(dir->users, host);
+ user_directory_remove_host(users, host);
mail_host_remove(host);
director_sync(dir);
}
struct director_host *orig_src,
struct mail_host *host)
{
+ struct user_directory *users = dir->users;
+
if (orig_src == NULL) {
orig_src = dir->self_host;
orig_src->last_seq++;
"HOST-FLUSH\t%s\t%u\t%u\t%s\n",
net_ip2addr(&orig_src->ip), orig_src->port, orig_src->last_seq,
net_ip2addr(&host->ip)));
- user_directory_remove_host(dir->users, host);
+ user_directory_remove_host(users, host);
director_sync(dir);
}
const char *data, void *context)
{
struct director_kill_context *ctx = context;
+ struct user_directory *users = ctx->dir->users;
struct user *user;
/* this is an asynchronous notification about user being killed.
ctx->callback_pending = FALSE;
- user = user_directory_lookup(ctx->dir->users, ctx->username_hash);
+ user = user_directory_lookup(users, ctx->username_hash);
if (!DIRECTOR_KILL_CONTEXT_IS_VALID(user, ctx)) {
/* user was already freed - ignore */
i_assert(ctx->to_move == NULL);
struct director_host *orig_src,
unsigned int username_hash, struct mail_host *host)
{
+ struct user_directory *users = dir->users;
struct user *user;
/* 1. move this user's host, and set its "killing" flag to delay all of
5. after receiving USER-KILLED-EVERYWHERE notification,
new connections are again allowed for the user.
*/
- user = user_directory_lookup(dir->users, username_hash);
+ user = user_directory_lookup(users, username_hash);
if (user == NULL) {
- user = user_directory_add(dir->users, username_hash,
+ user = user_directory_add(users, username_hash,
host, ioloop_time);
director_kill_user(dir, src, user, NULL);
} else {
void director_user_killed(struct director *dir, unsigned int username_hash)
{
+ struct user_directory *users = dir->users;
struct user *user;
- user = user_directory_lookup(dir->users, username_hash);
+ user = user_directory_lookup(users, username_hash);
if (user == NULL || !USER_IS_BEING_KILLED(user))
return;
doveadm_cmd_user_lookup(struct doveadm_connection *conn,
const char *const *args)
{
+ struct user_directory *users = conn->dir->users;
struct user *user;
struct mail_host *host;
const char *username, *tag;
tag = args[1] != NULL ? args[1] : "";
}
if (str_to_uint(username, &username_hash) < 0) {
- if (!user_directory_get_username_hash(conn->dir->users,
- args[0], &username_hash)) {
+ if (!user_directory_get_username_hash(users,
+ username, &username_hash)) {
o_stream_nsend_str(conn->output, "TRYAGAIN\n");
return 1;
}
}
/* get user's current host */
- user = user_directory_lookup(conn->dir->users, username_hash);
+ user = user_directory_lookup(users, username_hash);
if (user == NULL)
str_append(str, "\t0");
else {
static int
doveadm_cmd_user_move(struct doveadm_connection *conn, const char *const *args)
{
+ struct user_directory *users = conn->dir->users;
unsigned int username_hash;
struct user *user;
struct mail_host *host;
}
if (str_to_uint(args[0], &username_hash) < 0) {
- if (!user_directory_get_username_hash(conn->dir->users,
+ if (!user_directory_get_username_hash(users,
args[0], &username_hash)) {
o_stream_nsend_str(conn->output, "TRYAGAIN\n");
return 1;
}
}
- user = user_directory_lookup(conn->dir->users, username_hash);
+ user = user_directory_lookup(users, username_hash);
if (user != NULL && USER_IS_BEING_KILLED(user)) {
o_stream_nsend_str(conn->output, "TRYAGAIN\n");
return 1;