Commit 32691f49 authored by Karl Heyes's avatar Karl Heyes
Browse files

immediately release auth_t if authentication fails, that way we don't

trigger release_client like listener_remove event in the url auth.
Add lock in auth_t so that refcount changes are not a race possibility.

svn path=/icecast/trunk/icecast/; revision=9926
parent 0903dd68
......@@ -85,8 +85,10 @@ static void auth_client_setup (mount_proxy *mountinfo, client_t *client)
} while (0);
thread_mutex_lock (&mountinfo->auth->lock);
client->auth = mountinfo->auth;
thread_mutex_unlock (&mountinfo->auth->lock);
......@@ -108,13 +110,19 @@ void auth_release (auth_t *authenticator)
if (authenticator == NULL)
thread_mutex_lock (&authenticator->lock);
if (authenticator->refcount)
thread_mutex_unlock (&authenticator->lock);
if (authenticator->free)
authenticator->free (authenticator);
xmlFree (authenticator->type);
thread_mutex_unlock (&authenticator->lock);
thread_mutex_destroy (&authenticator->lock);
free (authenticator);
......@@ -148,7 +156,11 @@ static void auth_new_listener (auth_client *auth_user)
if (client->auth->authenticate)
if (client->auth->authenticate (auth_user) != AUTH_OK)
auth_release (client->auth);
client->auth = NULL;
if (auth_postprocess_client (auth_user) < 0)
INFO1 ("client %lu failed", client->con->id);
......@@ -512,6 +524,7 @@ auth_t *auth_get_authenticator (xmlNodePtr node)
auth->type = xmlGetProp (node, "type");
get_authenticator (auth, options);
thread_mutex_create (&auth->lock);
while (options)
config_options_t *opt = options;
......@@ -66,6 +66,7 @@ typedef struct auth_tag
auth_result (*deleteuser)(struct auth_tag *auth, const char *username);
auth_result (*listuser)(struct auth_tag *auth, xmlNodePtr srcnode);
mutex_t lock;
int refcount;
int allow_duplicate_users;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment