[xiph-commits] r9926 - icecast/trunk/icecast/src
karl at svn.xiph.org
karl at svn.xiph.org
Thu Sep 1 09:11:10 PDT 2005
Author: karl
Date: 2005-09-01 09:11:07 -0700 (Thu, 01 Sep 2005)
New Revision: 9926
Modified:
icecast/trunk/icecast/src/auth.c
icecast/trunk/icecast/src/auth.h
Log:
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.
Modified: icecast/trunk/icecast/src/auth.c
===================================================================
--- icecast/trunk/icecast/src/auth.c 2005-09-01 05:36:11 UTC (rev 9925)
+++ icecast/trunk/icecast/src/auth.c 2005-09-01 16:11:07 UTC (rev 9926)
@@ -85,8 +85,10 @@
} while (0);
+ thread_mutex_lock (&mountinfo->auth->lock);
client->auth = mountinfo->auth;
client->auth->refcount++;
+ thread_mutex_unlock (&mountinfo->auth->lock);
}
@@ -108,13 +110,19 @@
if (authenticator == NULL)
return;
+ thread_mutex_lock (&authenticator->lock);
authenticator->refcount--;
if (authenticator->refcount)
+ {
+ thread_mutex_unlock (&authenticator->lock);
return;
+ }
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 @@
if (client->auth->authenticate)
{
if (client->auth->authenticate (auth_user) != AUTH_OK)
+ {
+ auth_release (client->auth);
+ client->auth = NULL;
return;
+ }
}
if (auth_postprocess_client (auth_user) < 0)
INFO1 ("client %lu failed", client->con->id);
@@ -512,6 +524,7 @@
}
auth->type = xmlGetProp (node, "type");
get_authenticator (auth, options);
+ thread_mutex_create (&auth->lock);
while (options)
{
config_options_t *opt = options;
Modified: icecast/trunk/icecast/src/auth.h
===================================================================
--- icecast/trunk/icecast/src/auth.h 2005-09-01 05:36:11 UTC (rev 9925)
+++ icecast/trunk/icecast/src/auth.h 2005-09-01 16:11:07 UTC (rev 9926)
@@ -66,6 +66,7 @@
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;
More information about the commits
mailing list