diff options
author | Stef Walter <stef@memberwebs.com> | 2004-07-22 16:55:14 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-07-22 16:55:14 +0000 |
commit | 6be6d1dd25f2e7f2f1de6c0091e9aeae2ea1918c (patch) | |
tree | 1454a6bb0ec09fb6b105171d7aab29a217b30a39 /daemon/ldap.c | |
parent | 166f69df6dd704626c1b09ae60145956435b67e1 (diff) |
- Fixed uninitialized memory bug
- Imported updated sock_any and hash code
Diffstat (limited to 'daemon/ldap.c')
-rw-r--r-- | daemon/ldap.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/daemon/ldap.c b/daemon/ldap.c index 3befc4b..4398dc0 100644 --- a/daemon/ldap.c +++ b/daemon/ldap.c @@ -74,7 +74,7 @@ typedef struct ldap_context int ldap_timeout; /* Maximum amount of time to dedicate to an ldap query */ /* Context ----------------------------------------------------------- */ - hash_t* cache; /* Some cached records or basic */ + hsh_t* cache; /* Some cached records or basic */ LDAP** pool; /* Pool of available connections */ int pool_mark; /* Amount of connections allocated */ @@ -145,11 +145,11 @@ static digest_record_t* get_cached_digest(ldap_context_t* ctx, ha_context_t* c, ha_lock(NULL); - rec = (digest_record_t*)hash_get(ctx->cache, nonce); + rec = (digest_record_t*)hsh_get(ctx->cache, nonce); /* Just in case it's a basic :) */ if(rec && rec != BASIC_ESTABLISHED) - hash_rem(ctx->cache, nonce); + hsh_rem(ctx->cache, nonce); ha_unlock(NULL); @@ -165,7 +165,7 @@ static int have_cached_basic(ldap_context_t* ctx, unsigned char* key) ha_lock(NULL); - ret = (hash_get(ctx->cache, key) == BASIC_ESTABLISHED); + ret = (hsh_get(ctx->cache, key) == BASIC_ESTABLISHED); ha_unlock(NULL); @@ -187,10 +187,10 @@ static int save_cached_digest(ldap_context_t* ctx, ha_context_t* c, ha_lock(NULL); - while(hash_count(ctx->cache) >= c->cache_max) - hash_bump(ctx->cache); + while(hsh_count(ctx->cache) >= c->cache_max) + hsh_bump(ctx->cache); - r = hash_set(ctx->cache, rec->nonce, rec); + r = hsh_set(ctx->cache, rec->nonce, rec); ha_unlock(NULL); @@ -215,10 +215,10 @@ static int add_cached_basic(ldap_context_t* ctx, ha_context_t* c, ha_lock(NULL); - while(hash_count(ctx->cache) >= c->cache_max) - hash_bump(ctx->cache); + while(hsh_count(ctx->cache) >= c->cache_max) + hsh_bump(ctx->cache); - r = hash_set(ctx->cache, key, BASIC_ESTABLISHED); + r = hsh_set(ctx->cache, key, BASIC_ESTABLISHED); ha_unlock(NULL); @@ -633,6 +633,13 @@ static LDAP* get_ldap_connection(ldap_context_t* ctx) return ld; } +static void discard_ldap_connection(ldap_context_t* ctx, LDAP* ld) +{ + ldap_unbind_s(ld); + ctx->pool_mark--; + ha_messagex(LOG_DEBUG, "ldap: discarding connection (total %d)", ctx->pool_mark); +} + static void save_ldap_connection(ldap_context_t* ctx, LDAP* ld) { int i, e; @@ -670,13 +677,6 @@ static void save_ldap_connection(ldap_context_t* ctx, LDAP* ld) }; } -static discard_ldap_connection(ldap_context_t* ctx, LDAP* ld) -{ - ldap_unbind_s(ld); - ctx->pool_mark--; - ha_messagex(LOG_DEBUG, "ldap: discarding connection (total %d)", ctx->pool_mark); -} - static int retrieve_user_entry(ldap_context_t* ctx, const ha_request_t* req, LDAP* ld, const char* user, const char** dn, LDAPMessage** entry, LDAPMessage** result) @@ -1323,7 +1323,7 @@ int ldap_inithand(ha_context_t* context) else { ldap_context_t* ctx = (ldap_context_t*)(context->ctx_data); - hash_table_calls_t htc; + hsh_table_calls_t htc; ASSERT(ctx); @@ -1351,7 +1351,7 @@ int ldap_inithand(ha_context_t* context) } /* The cache for digest records and basic */ - if(!(ctx->cache = hash_create(MD5_LEN))) + if(!(ctx->cache = hsh_create(MD5_LEN))) { ha_messagex(LOG_CRIT, "out of memory"); return HA_CRITERROR; @@ -1359,7 +1359,7 @@ int ldap_inithand(ha_context_t* context) htc.f_freeval = free_hash_object; htc.arg = NULL; - hash_set_table_calls(ctx->cache, &htc); + hsh_set_table_calls(ctx->cache, &htc); ASSERT(!ctx->pool); ASSERT(ctx->ldap_max > 0); @@ -1398,7 +1398,7 @@ void ldap_destroy(ha_context_t* context) ASSERT(ctx); if(ctx->cache) - hash_free(ctx->cache); + hsh_free(ctx->cache); if(ctx->pool) { @@ -1430,7 +1430,7 @@ int ldap_process(const ha_request_t* req, ha_response_t* resp) ha_lock(NULL); /* Purge out stale connection stuff. */ - r = hash_purge(ctx->cache, t - req->context->cache_timeout); + r = hsh_purge(ctx->cache, t - req->context->cache_timeout); ha_unlock(NULL); |