From d43484d49ad8f2e506c1deacef9be63322ced622 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 14 Mar 2005 23:07:34 +0000 Subject: [PATCH] Fix various places where "clients" stats value was decremented without having previously been incremented. svn path=/icecast/trunk/icecast/; revision=9074 --- src/connection.c | 6 +++--- src/fserve.c | 5 +++++ src/source.c | 8 +++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/connection.c b/src/connection.c index f50fa097..51f3535b 100644 --- a/src/connection.c +++ b/src/connection.c @@ -694,7 +694,7 @@ static void _handle_source_request(connection_t *con, client = client_create(con, parser); INFO1("Source logging in at mountpoint \"%s\"", uri); - + if (uri[0] != '/') { WARN0 ("source mountpoint not starting with /"); @@ -708,7 +708,7 @@ static void _handle_source_request(connection_t *con, * protocol: attempt to diagnose this and return an error */ /* TODO: Do what the above comment says */ - INFO1("Source (%s) attempted to login with invalid or missing password", uri); + WARN1("Source (%s) attempted to login with invalid or missing password", uri); client_send_401(client); return; } @@ -787,7 +787,7 @@ static void _handle_get_request(connection_t *con, fileserve = config->fileserve; host = config->hostname; port = config->port; - for(i = 0; i < MAX_LISTEN_SOCKETS; i++) { + for(i = 0; i < global.server_sockets; i++) { if(global.serversock[i] == con->serversock) { serverhost = config->listeners[i].bind_address; serverport = config->listeners[i].port; diff --git a/src/fserve.c b/src/fserve.c index 3fd9cceb..c3f13c2c 100644 --- a/src/fserve.c +++ b/src/fserve.c @@ -302,6 +302,11 @@ static void *fserv_thread_function(void *arg) { fserve_t *to_go = (fserve_t *)pending_list; pending_list = to_go->next; + + /* Argh! _free_client decrements "clients" in stats, but it hasn't been + incremented if the client is still on the pending list. So, fix that + up first. Messy. */ + stats_event_inc(NULL, "clients"); _free_client (to_go); } thread_mutex_unlock (&pending_lock); diff --git a/src/source.c b/src/source.c index 3bc18f47..a392ff4f 100644 --- a/src/source.c +++ b/src/source.c @@ -219,6 +219,9 @@ void source_clear_source (source_t *source) avl_tree_rlock (source->pending_tree); while (avl_get_first (source->pending_tree)) { + /* _free_client decrements client count, so increment it first... */ + stats_event_inc(NULL, "clients"); + avl_delete (source->pending_tree, avl_get_first(source->pending_tree)->key, _free_client); } @@ -689,6 +692,10 @@ void source_main (source_t *source) /** add pending clients **/ client_node = avl_get_first(source->pending_tree); while (client_node) { + + /* We have to do this first, since _free_client decrements it... */ + stats_event_inc(NULL, "clients"); + if(source->max_listeners != -1 && source->listeners >= source->max_listeners) { @@ -711,7 +718,6 @@ void source_main (source_t *source) source->listeners++; DEBUG0("Client added"); - stats_event_inc(NULL, "clients"); stats_event_inc(source->mount, "connections"); client_node = avl_get_next(client_node);