director-request.c revision c3c9d0258e7d11c97f73e0f7fbb6b45a88a7e545
/* Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "str.h"
#include "mail-host.h"
#include "user-directory.h"
#include "director.h"
#include "director-request.h"
#define DIRECTOR_REQUEST_TIMEOUT_SECS 30
struct director_request {
unsigned int username_hash;
void *context;
};
static const char *
{
unsigned int secs;
else {
else
}
}
}
{
const char *errormsg;
if (request->create_time +
break;
T_BEGIN {
} T_END;
}
}
{
struct director_request *request;
unsigned int username_hash =
return;
/* need to queue it */
dir->to_request =
}
}
{
if (!dir->ring_handshaked) {
i_warning("Delaying all requests "
"until all directors have connected");
} else {
i_warning("Delaying new user requests until ring is synced");
}
}
{
if (dir->ring_handshake_warning_sent ||
return;
}
{
/* delay processing this user's connections until
its existing connections have been killed */
return FALSE;
}
/* wait for user to become non-weak */
return FALSE;
}
return TRUE;
/* user is close to being expired. another director may have
already expired it. */
if (!dir->ring_synced) {
/* try again later once ring is synced */
return FALSE;
}
/* doesn't matter, other directors would
assign the user the same way regardless */
return TRUE;
}
/* We have to worry about two separate timepoints in here:
a) some directors think the user isn't expiring, and
others think the user is near expiring
b) some directors think the user is near expiring, and
others think the user has already expired
What we don't have to worry about is:
!c) some directors think the user isn't expiring, and
others think the user has already expired
If !c) happens, the user might get redirected to different backends.
We'll use a large enough timeout between a) and b) states, so that
!c) should never happen.
So what we'll do here is:
1. Send a USER-WEAK notification to all directors with the new host.
2. Each director receiving USER-WEAK refreshes the user's timestamp
and host, but marks the user as being weak.
3. Once USER-WEAK has reached all directors, a real USER update is
sent, which removes the weak-flag.
4. If a director ever receives a USER update for a weak user, the
USER update overrides the host and removes the weak-flag.
5. Director doesn't let any weak user log in, until the weak-flag
gets removed.
*/
/* weak users not supported by ring currently */
return TRUE;
} else {
return FALSE;
}
}
{
if (!dir->ring_handshaked) {
/* delay requests until ring handshaking is complete */
return FALSE;
}
return FALSE;
} else {
if (!dir->ring_synced) {
/* delay adding new users until ring is again synced */
return FALSE;
}
/* all hosts have been removed */
return FALSE;
}
host, ioloop_time);
}
T_BEGIN {
} T_END;
return TRUE;
}