1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2025-01-03 14:56:34 -05:00

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
This commit is contained in:
Karl Heyes 2005-09-01 16:11:07 +00:00
parent 0903dd68ed
commit 32691f498a
2 changed files with 14 additions and 0 deletions

View File

@ -85,8 +85,10 @@ static void auth_client_setup (mount_proxy *mountinfo, client_t *client)
} while (0); } while (0);
thread_mutex_lock (&mountinfo->auth->lock);
client->auth = mountinfo->auth; client->auth = mountinfo->auth;
client->auth->refcount++; client->auth->refcount++;
thread_mutex_unlock (&mountinfo->auth->lock);
} }
@ -108,13 +110,19 @@ void auth_release (auth_t *authenticator)
if (authenticator == NULL) if (authenticator == NULL)
return; return;
thread_mutex_lock (&authenticator->lock);
authenticator->refcount--; authenticator->refcount--;
if (authenticator->refcount) if (authenticator->refcount)
{
thread_mutex_unlock (&authenticator->lock);
return; return;
}
if (authenticator->free) if (authenticator->free)
authenticator->free (authenticator); authenticator->free (authenticator);
xmlFree (authenticator->type); xmlFree (authenticator->type);
thread_mutex_unlock (&authenticator->lock);
thread_mutex_destroy (&authenticator->lock);
free (authenticator); free (authenticator);
} }
@ -148,7 +156,11 @@ static void auth_new_listener (auth_client *auth_user)
if (client->auth->authenticate) if (client->auth->authenticate)
{ {
if (client->auth->authenticate (auth_user) != AUTH_OK) if (client->auth->authenticate (auth_user) != AUTH_OK)
{
auth_release (client->auth);
client->auth = NULL;
return; return;
}
} }
if (auth_postprocess_client (auth_user) < 0) if (auth_postprocess_client (auth_user) < 0)
INFO1 ("client %lu failed", client->con->id); INFO1 ("client %lu failed", client->con->id);
@ -512,6 +524,7 @@ auth_t *auth_get_authenticator (xmlNodePtr node)
} }
auth->type = xmlGetProp (node, "type"); auth->type = xmlGetProp (node, "type");
get_authenticator (auth, options); get_authenticator (auth, options);
thread_mutex_create (&auth->lock);
while (options) while (options)
{ {
config_options_t *opt = options; config_options_t *opt = options;

View File

@ -66,6 +66,7 @@ typedef struct auth_tag
auth_result (*deleteuser)(struct auth_tag *auth, const char *username); auth_result (*deleteuser)(struct auth_tag *auth, const char *username);
auth_result (*listuser)(struct auth_tag *auth, xmlNodePtr srcnode); auth_result (*listuser)(struct auth_tag *auth, xmlNodePtr srcnode);
mutex_t lock;
int refcount; int refcount;
int allow_duplicate_users; int allow_duplicate_users;