dovecot-2.2: auth ldap: Start LDAP connection only after auth pr...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Mar 16 21:26:24 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/0a17875f0ece
changeset: 18361:0a17875f0ece
user: Timo Sirainen <tss at iki.fi>
date: Mon Mar 16 23:25:34 2015 +0200
description:
auth ldap: Start LDAP connection only after auth process initialization is finished.
This way even if connecting to LDAP takes a while it won't cause the master
process to kill the auth process due to it not sending the startup "I'm ok"
notification early enough.
diffstat:
src/auth/db-ldap.c | 15 +++++++++++++++
src/auth/db-ldap.h | 1 +
src/auth/passdb-ldap.c | 2 +-
src/auth/userdb-ldap.c | 2 +-
4 files changed, 18 insertions(+), 2 deletions(-)
diffs (67 lines):
diff -r d9a0d4f4f4b6 -r 0a17875f0ece src/auth/db-ldap.c
--- a/src/auth/db-ldap.c Mon Mar 16 23:21:05 2015 +0200
+++ b/src/auth/db-ldap.c Mon Mar 16 23:25:34 2015 +0200
@@ -1155,6 +1155,8 @@
memset(&start, 0, sizeof(start));
}
i_assert(conn->pending_count == 0);
+ if (conn->to != NULL)
+ timeout_remove(&conn->to);
if (conn->ld == NULL)
db_ldap_init_ld(conn);
@@ -1215,6 +1217,19 @@
return 0;
}
+static void db_ldap_connect_callback(struct ldap_connection *conn)
+{
+ timeout_remove(&conn->to);
+ (void)db_ldap_connect(conn);
+}
+
+void db_ldap_connect_delayed(struct ldap_connection *conn)
+{
+ i_assert(conn->to == NULL);
+
+ conn->to = timeout_add_short(0, db_ldap_connect_callback, conn);
+}
+
void db_ldap_enable_input(struct ldap_connection *conn, bool enable)
{
if (!enable) {
diff -r d9a0d4f4f4b6 -r 0a17875f0ece src/auth/db-ldap.h
--- a/src/auth/db-ldap.h Mon Mar 16 23:21:05 2015 +0200
+++ b/src/auth/db-ldap.h Mon Mar 16 23:25:34 2015 +0200
@@ -190,6 +190,7 @@
void db_ldap_unref(struct ldap_connection **conn);
int db_ldap_connect(struct ldap_connection *conn);
+void db_ldap_connect_delayed(struct ldap_connection *conn);
void db_ldap_enable_input(struct ldap_connection *conn, bool enable);
diff -r d9a0d4f4f4b6 -r 0a17875f0ece src/auth/passdb-ldap.c
--- a/src/auth/passdb-ldap.c Mon Mar 16 23:21:05 2015 +0200
+++ b/src/auth/passdb-ldap.c Mon Mar 16 23:25:34 2015 +0200
@@ -449,7 +449,7 @@
struct ldap_passdb_module *module =
(struct ldap_passdb_module *)_module;
- (void)db_ldap_connect(module->conn);
+ db_ldap_connect_delayed(module->conn);
}
static void passdb_ldap_deinit(struct passdb_module *_module)
diff -r d9a0d4f4f4b6 -r 0a17875f0ece src/auth/userdb-ldap.c
--- a/src/auth/userdb-ldap.c Mon Mar 16 23:21:05 2015 +0200
+++ b/src/auth/userdb-ldap.c Mon Mar 16 23:25:34 2015 +0200
@@ -285,7 +285,7 @@
struct ldap_userdb_module *module =
(struct ldap_userdb_module *)_module;
- (void)db_ldap_connect(module->conn);
+ db_ldap_connect_delayed(module->conn);
}
static void userdb_ldap_deinit(struct userdb_module *_module)
More information about the dovecot-cvs
mailing list