diff options
author | Stef Walter <stef@memberwebs.com> | 2004-08-18 22:47:38 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-08-18 22:47:38 +0000 |
commit | 53e4b851883571c92073c87986759bd98dab9c7e (patch) | |
tree | 436748a52788e2f0434ec9beef8768f881dbcd07 /daemon/ntlm.c | |
parent | 59099b09a63f200147fc506e75f3052469d69fe9 (diff) |
Thread safety and locking checks.
Diffstat (limited to 'daemon/ntlm.c')
-rw-r--r-- | daemon/ntlm.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/daemon/ntlm.c b/daemon/ntlm.c index 8e1aa20..fba4624 100644 --- a/daemon/ntlm.c +++ b/daemon/ntlm.c @@ -39,14 +39,14 @@ ntlm_connection_t; /* The main context */ typedef struct ntlm_context { - /* Settings ---------------------------------------------------------- */ + /* Read Only --------------------------------------------------------- */ const char* server; /* Server to authenticate against */ const char* domain; /* NTLM domain to authenticate against */ const char* backup; /* Backup server if primary is down */ int pending_max; /* Maximum number of connections at once */ int pending_timeout; /* Timeout for authentication (in seconds) */ - /* Context ----------------------------------------------------------- */ + /* Require Locking --------------------------------------------------- */ hsh_t* pending; /* Pending connections */ hsh_t* established; /* Established connections */ } @@ -149,19 +149,19 @@ static int putpending(ntlm_context_t* ctx, const void* key, ntlm_connection_t* c ASSERT(ctx && key && conn); ASSERT(conn->handle); - if(!hsh_get(ctx->pending, key)) - { - ha_lock(NULL); + ha_lock(NULL); + if(!hsh_get(ctx->pending, key)) + { if(!hsh_set(ctx->pending, key, (void*)conn)) { free_hash_object(NULL, conn); ha_messagex(NULL, LOG_ERR, "out of memory"); r = -1; } + } - ha_unlock(NULL); - } + ha_unlock(NULL); return r; } @@ -633,7 +633,7 @@ void ntlm_destroy(ha_context_t* context) ntlm_context_t* ctx = (ntlm_context_t*)(context->ctx_data); if(ctx->pending) - hsh_free(ctx->pending); + hsh_free(ctx->pending); if(ctx->established) hsh_free(ctx->established); @@ -721,18 +721,18 @@ int ntlm_process(ha_request_t* rq) { ha_lock(NULL); - /* - * NTLM trusts a connection after it's been authenticated - * so just pass success for those. Note that we do this - * in the absence of a authorization header so that we - * allow connections to be re-authenticated. - */ + /* + * NTLM trusts a connection after it's been authenticated + * so just pass success for those. Note that we do this + * in the absence of a authorization header so that we + * allow connections to be re-authenticated. + */ - if(hsh_get(ctx->established, key) == NTLM_ESTABLISHED) - { - hsh_touch(ctx->established, key); - rq->resp_code = HA_SERVER_OK; - } + if(hsh_get(ctx->established, key) == NTLM_ESTABLISHED) + { + hsh_touch(ctx->established, key); + rq->resp_code = HA_SERVER_OK; + } ha_unlock(NULL); |