[xiph-commits] r9712 - icecast/branches/kh/icecast/src
karl at svn.xiph.org
karl at svn.xiph.org
Sun Aug 7 10:42:44 PDT 2005
Author: karl
Date: 2005-08-07 10:42:41 -0700 (Sun, 07 Aug 2005)
New Revision: 9712
Modified:
icecast/branches/kh/icecast/src/auth.c
icecast/branches/kh/icecast/src/format.c
icecast/branches/kh/icecast/src/source.c
icecast/branches/kh/icecast/src/source.h
Log:
add limiter for authentication queue and check for the no-mount setting at
the adding of the listener, no need to save it in the source_t.
Modified: icecast/branches/kh/icecast/src/auth.c
===================================================================
--- icecast/branches/kh/icecast/src/auth.c 2005-08-07 14:50:59 UTC (rev 9711)
+++ icecast/branches/kh/icecast/src/auth.c 2005-08-07 17:42:41 UTC (rev 9712)
@@ -39,6 +39,7 @@
static volatile auth_client *clients_to_auth;
+static volatile unsigned int auth_pending_count;
static volatile int auth_running;
static mutex_t auth_lock;
static thread_type *auth_thread;
@@ -95,6 +96,7 @@
thread_mutex_lock (&auth_lock);
auth_user->next = (auth_client *)clients_to_auth;
clients_to_auth = auth_user;
+ auth_pending_count++;
thread_mutex_unlock (&auth_lock);
}
@@ -182,6 +184,7 @@
thread_mutex_lock (&auth_lock);
auth_user = (auth_client*)clients_to_auth;
clients_to_auth = auth_user->next;
+ auth_pending_count--;
thread_mutex_unlock (&auth_lock);
auth_user->next = NULL;
@@ -236,7 +239,7 @@
* if 0 is returned then the client should not be touched, however if -1
* is returned then the caller is responsible for handling the client
*/
-int add_client_to_source (source_t *source, client_t *client)
+static int add_client_to_source (source_t *source, client_t *client)
{
int loop = 10;
do
@@ -285,7 +288,7 @@
source->on_demand_req = 1;
slave_rescan ();
}
- DEBUG1 ("Added client to pending on %s", source->mount);
+ DEBUG1 ("Added client to %s", source->mount);
return 0;
}
@@ -358,10 +361,23 @@
client->refbuf->len = PER_CLIENT_REFBUF_SIZE;
mountinfo = config_find_mount (config, mount);
+ if (mountinfo && mountinfo->no_mount)
+ {
+ config_release_config ();
+ client_send_404 (client, "mountpoint unavailable");
+ return;
+ }
if (mountinfo && mountinfo->auth)
{
auth_client *auth_user;
+ if (auth_pending_count > 30)
+ {
+ config_release_config ();
+ WARN0 ("too many clients awaiting authentication");
+ client_send_404 (client, "busy, please try again later");
+ return;
+ }
auth_client_setup (mountinfo, client);
config_release_config ();
@@ -556,6 +572,7 @@
void auth_initialise ()
{
clients_to_auth = NULL;
+ auth_pending_count = 0;
auth_running = 1;
thread_mutex_create ("auth lock", &auth_lock);
auth_thread = thread_create ("auth thread", auth_run_thread, NULL, THREAD_ATTACHED);
Modified: icecast/branches/kh/icecast/src/format.c
===================================================================
--- icecast/branches/kh/icecast/src/format.c 2005-08-07 14:50:59 UTC (rev 9711)
+++ icecast/branches/kh/icecast/src/format.c 2005-08-07 17:42:41 UTC (rev 9712)
@@ -166,7 +166,6 @@
return -1;
}
/* source -> file fallback, need a refbuf for data */
- client_set_queue (client, NULL);
refbuf = refbuf_new (PER_CLIENT_REFBUF_SIZE);
client->refbuf = refbuf;
client->pos = refbuf->len;
Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c 2005-08-07 14:50:59 UTC (rev 9711)
+++ icecast/branches/kh/icecast/src/source.c 2005-08-07 17:42:41 UTC (rev 9712)
@@ -230,7 +230,6 @@
source->queue_size_limit = 0;
source->listeners = 0;
source->prev_listeners = 0;
- source->no_mount = 0;
source->shoutcast_compat = 0;
source->max_listeners = -1;
source->hidden = 0;
@@ -913,7 +912,6 @@
{
source->max_listeners = mountinfo->max_listeners;
source->fallback_override = mountinfo->fallback_override;
- source->no_mount = mountinfo->no_mount;
source->hidden = mountinfo->hidden;
}
Modified: icecast/branches/kh/icecast/src/source.h
===================================================================
--- icecast/branches/kh/icecast/src/source.h 2005-08-07 14:50:59 UTC (rev 9711)
+++ icecast/branches/kh/icecast/src/source.h 2005-08-07 17:42:41 UTC (rev 9712)
@@ -56,7 +56,6 @@
int yp_public;
int fallback_override;
int fallback_when_full;
- int no_mount;
int shoutcast_compat;
/* per source burst handling for connecting clients */
More information about the commits
mailing list