dovecot-2.0: lib-master: Don't wait for handshake before sending...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Nov 9 21:48:50 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/e72ab743b8df
changeset: 12405:e72ab743b8df
user: Timo Sirainen <tss at iki.fi>
date: Tue Nov 09 19:48:47 2010 +0000
description:
lib-master: Don't wait for handshake before sending auth-master request.
diffstat:
src/lib-master/master-login-auth.c | 58 ++++++++++++++++++----------
1 files changed, 37 insertions(+), 21 deletions(-)
diffs (116 lines):
diff -r d1cf770dbef5 -r e72ab743b8df src/lib-master/master-login-auth.c
--- a/src/lib-master/master-login-auth.c Tue Nov 09 18:36:37 2010 +0000
+++ b/src/lib-master/master-login-auth.c Tue Nov 09 19:48:47 2010 +0000
@@ -31,6 +31,8 @@
master_login_auth_request_callback_t *callback;
void *context;
+
+ unsigned int aborted:1;
};
struct master_login_auth {
@@ -56,7 +58,7 @@
};
static void master_login_auth_set_timeout(struct master_login_auth *auth);
-static void master_login_auth_send_all_requests(struct master_login_auth *auth);
+static void master_login_auth_check_spids(struct master_login_auth *auth);
struct master_login_auth *master_login_auth_init(const char *auth_socket_path)
{
@@ -195,6 +197,12 @@
return NULL;
}
master_login_auth_request_remove(auth, request);
+ if (request->aborted) {
+ request->callback(NULL, MASTER_AUTH_ERRMSG_INTERNAL_FAILURE,
+ request->context);
+ i_free(request);
+ return NULL;
+ }
return request;
}
@@ -325,7 +333,7 @@
return;
}
auth->spid_received = TRUE;
- master_login_auth_send_all_requests(auth);
+ master_login_auth_check_spids(auth);
}
auth->refcount++;
@@ -367,19 +375,38 @@
return 0;
}
+static bool
+auth_request_check_spid(struct master_login_auth *auth,
+ struct master_login_auth_request *req)
+{
+ if (auth->auth_server_pid != req->auth_pid && auth->spid_received) {
+ /* auth server was restarted. don't even attempt a login. */
+ i_warning("Auth server restarted (pid %u -> %u), aborting auth",
+ (unsigned int)req->auth_pid,
+ (unsigned int)auth->auth_server_pid);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void master_login_auth_check_spids(struct master_login_auth *auth)
+{
+ struct master_login_auth_request *req, *next;
+
+ for (req = auth->request_head; req != NULL; req = next) {
+ next = req->next;
+ if (!auth_request_check_spid(auth, req))
+ req->aborted = TRUE;
+ }
+}
+
static void
master_login_auth_send_request(struct master_login_auth *auth,
struct master_login_auth_request *req)
{
string_t *str;
- i_assert(auth->spid_received);
-
- if (auth->auth_server_pid != req->auth_pid) {
- /* auth server was restarted. don't even attempt a login. */
- i_warning("Auth server restarted (pid %u -> %u), aborting auth",
- (unsigned int)req->auth_pid,
- (unsigned int)auth->auth_server_pid);
+ if (!auth_request_check_spid(auth, req)) {
master_login_auth_request_remove(auth, req);
req->callback(NULL, MASTER_AUTH_ERRMSG_INTERNAL_FAILURE,
req->context);
@@ -395,16 +422,6 @@
o_stream_send(auth->output, str_data(str), str_len(str));
}
-static void master_login_auth_send_all_requests(struct master_login_auth *auth)
-{
- struct master_login_auth_request *req, *next;
-
- for (req = auth->request_head; req != NULL; req = next) {
- next = req->next;
- master_login_auth_send_request(auth, req);
- }
-}
-
void master_login_auth_request(struct master_login_auth *auth,
const struct master_auth_request *req,
master_login_auth_request_callback_t *callback,
@@ -447,8 +464,7 @@
if (auth->to == NULL)
master_login_auth_set_timeout(auth);
- if (auth->spid_received)
- master_login_auth_send_request(auth, login_req);
+ master_login_auth_send_request(auth, login_req);
}
unsigned int master_login_auth_request_count(struct master_login_auth *auth)
More information about the dovecot-cvs
mailing list