[dovecot-cvs] dovecot/src/auth db-ldap.c,1.6,1.7 db-ldap.h,1.5,1.6
cras at procontrol.fi
cras at procontrol.fi
Tue Feb 11 16:06:48 EET 2003
Update of /home/cvs/dovecot/src/auth
In directory danu:/tmp/cvs-serv23425
Modified Files:
db-ldap.c db-ldap.h
Log Message:
Use the same LDAP connection for both userdb and passdb if config_path is
the same.
Index: db-ldap.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/db-ldap.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- db-ldap.c 11 Feb 2003 12:53:56 -0000 1.6
+++ db-ldap.c 11 Feb 2003 14:06:46 -0000 1.7
@@ -52,6 +52,8 @@
MEMBER(user_global_gid) 0
};
+static struct ldap_connection *ldap_connections = NULL;
+
static int ldap_conn_open(struct ldap_connection *conn);
static int deref2str(const char *str)
@@ -258,11 +260,30 @@
&conn->set, key, value);
}
+static struct ldap_connection *ldap_conn_find(const char *config_path)
+{
+ struct ldap_connection *conn;
+
+ for (conn = ldap_connections; conn != NULL; conn = conn->next) {
+ if (strcmp(conn->config_path, config_path) == 0)
+ return conn;
+ }
+
+ return NULL;
+}
+
struct ldap_connection *db_ldap_init(const char *config_path)
{
struct ldap_connection *conn;
pool_t pool;
+ /* see if it already exists */
+ conn = ldap_conn_find(config_path);
+ if (conn != NULL) {
+ conn->refcount++;
+ return conn;
+ }
+
pool = pool_alloconly_create("ldap_connection", 1024);
conn = p_new(pool, struct ldap_connection, 1);
conn->pool = pool;
@@ -270,6 +291,7 @@
conn->refcount = 1;
conn->requests = hash_create(default_pool, pool, 0, NULL, NULL);
+ conn->config_path = p_strdup(pool, config_path);
conn->set = default_ldap_settings;
settings_read(config_path, parse_setting, conn);
@@ -280,6 +302,9 @@
conn->set.ldap_scope = scope2str(conn->set.scope);
(void)ldap_conn_open(conn);
+
+ conn->next = ldap_connections;
+ ldap_connections = conn;
return conn;
}
Index: db-ldap.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/db-ldap.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- db-ldap.h 11 Feb 2003 12:53:56 -0000 1.5
+++ db-ldap.h 11 Feb 2003 14:06:46 -0000 1.6
@@ -29,6 +29,8 @@
};
struct ldap_connection {
+ struct ldap_connection *next;
+
pool_t pool;
int refcount;
More information about the dovecot-cvs
mailing list