Commit 0f6d8ba8 authored by Karl Heyes's avatar Karl Heyes

merge fixes. NULL checks

svn path=/icecast/trunk/icecast/; revision=9720
parent 042ba3b8
...@@ -240,8 +240,8 @@ xmlDocPtr admin_build_sourcelist (const char *mount) ...@@ -240,8 +240,8 @@ xmlDocPtr admin_build_sourcelist (const char *mount)
source->fallback_mount:""); source->fallback_mount:"");
snprintf (buf, sizeof(buf), "%lu", source->listeners); snprintf (buf, sizeof(buf), "%lu", source->listeners);
xmlNewChild(srcnode, NULL, "listeners", buf); xmlNewChild(srcnode, NULL, "listeners", buf);
config = config_get_config();
config = config_get_config();
mountinfo = config_find_mount (config, source->mount); mountinfo = config_find_mount (config, source->mount);
if (mountinfo && mountinfo->auth) if (mountinfo && mountinfo->auth)
{ {
...@@ -252,9 +252,12 @@ xmlDocPtr admin_build_sourcelist (const char *mount) ...@@ -252,9 +252,12 @@ xmlDocPtr admin_build_sourcelist (const char *mount)
if (source->running) if (source->running)
{ {
snprintf (buf, sizeof(buf), "%lu", if (source->client->con)
(unsigned long)(now - source->con->con_time)); {
xmlNewChild (srcnode, NULL, "Connected", buf); snprintf (buf, sizeof(buf), "%lu",
(unsigned long)(now - source->con->con_time));
xmlNewChild (srcnode, NULL, "Connected", buf);
}
xmlNewChild (srcnode, NULL, "content-type", xmlNewChild (srcnode, NULL, "content-type",
source->format->contenttype); source->format->contenttype);
} }
......
...@@ -79,12 +79,13 @@ void client_destroy(client_t *client) ...@@ -79,12 +79,13 @@ void client_destroy(client_t *client)
/* write log entry if ip is set (some things don't set it, like outgoing /* write log entry if ip is set (some things don't set it, like outgoing
* slave requests * slave requests
*/ */
if (client->con && client->con->ip) if (client->respcode && client->parser)
logging_access(client); logging_access(client);
if (client->con) if (client->con)
connection_close(client->con); connection_close(client->con);
httpp_destroy(client->parser); if (client->parser)
httpp_destroy(client->parser);
global_lock (); global_lock ();
global.clients--; global.clients--;
...@@ -94,11 +95,13 @@ void client_destroy(client_t *client) ...@@ -94,11 +95,13 @@ void client_destroy(client_t *client)
/* drop ref counts if need be */ /* drop ref counts if need be */
if (client->refbuf) if (client->refbuf)
refbuf_release (client->refbuf); refbuf_release (client->refbuf);
/* we need to free client specific format data (if any) */ /* we need to free client specific format data (if any) */
if (client->free_client_data) if (client->free_client_data)
client->free_client_data (client); client->free_client_data (client);
free(client->username); free(client->username);
free(client->password);
free(client); free(client);
} }
......
...@@ -85,11 +85,12 @@ typedef struct ypdata_tag ...@@ -85,11 +85,12 @@ typedef struct ypdata_tag
static rwlock_t yp_lock; static rwlock_t yp_lock;
static mutex_t yp_pending_lock; static mutex_t yp_pending_lock;
volatile static struct yp_server *active_yps = NULL, *pending_yps = NULL; static volatile struct yp_server *active_yps = NULL, *pending_yps = NULL;
static volatile int yp_update = 0; static volatile int yp_update = 0;
static int yp_running; static int yp_running;
static time_t now; static time_t now;
static thread_type *yp_thread; static thread_type *yp_thread;
static volatile unsigned client_limit = 0;
static void *yp_update_thread(void *arg); static void *yp_update_thread(void *arg);
static void add_yp_info (ypdata_t *yp, void *info, int type); static void add_yp_info (ypdata_t *yp, void *info, int type);
...@@ -215,6 +216,7 @@ void yp_recheck_config (ice_config_t *config) ...@@ -215,6 +216,7 @@ void yp_recheck_config (ice_config_t *config)
server->remove = 1; server->remove = 1;
server = server->next; server = server->next;
} }
client_limit = config->client_limit;
/* for each yp url in config, check to see if one exists /* for each yp url in config, check to see if one exists
if not, then add it. */ if not, then add it. */
for (i=0 ; i < config->num_yp_directories; i++) for (i=0 ; i < config->num_yp_directories; i++)
...@@ -387,10 +389,9 @@ static unsigned do_yp_add (ypdata_t *yp, char *s, unsigned len) ...@@ -387,10 +389,9 @@ static unsigned do_yp_add (ypdata_t *yp, char *s, unsigned len)
static unsigned do_yp_touch (ypdata_t *yp, char *s, unsigned len) static unsigned do_yp_touch (ypdata_t *yp, char *s, unsigned len)
{ {
unsigned listeners = 0; unsigned listeners = 0, max_listeners = 1;
char *val, *artist, *title; char *val, *artist, *title;
int ret; int ret;
char *max_listeners;
artist = (char *)stats_get_value (yp->mount, "artist"); artist = (char *)stats_get_value (yp->mount, "artist");
title = (char *)stats_get_value (yp->mount, "title"); title = (char *)stats_get_value (yp->mount, "title");
...@@ -422,12 +423,15 @@ static unsigned do_yp_touch (ypdata_t *yp, char *s, unsigned len) ...@@ -422,12 +423,15 @@ static unsigned do_yp_touch (ypdata_t *yp, char *s, unsigned len)
listeners = atoi (val); listeners = atoi (val);
free (val); free (val);
} }
max_listeners = stats_get_value (yp->mount, "max_listeners"); val = stats_get_value (yp->mount, "max_listeners");
if (max_listeners == NULL || strcmp (max_listeners, "unlimited") == 0) if (val == NULL || strcmp (val, "unlimited") == 0)
{ {
free (max_listeners); free (val);
max_listeners = (char *)stats_get_value (NULL, "client_limit"); max_listeners = client_limit;
} }
else
max_listeners = atoi (val);
val = stats_get_value (yp->mount, "subtype"); val = stats_get_value (yp->mount, "subtype");
if (val) if (val)
{ {
...@@ -436,10 +440,9 @@ static unsigned do_yp_touch (ypdata_t *yp, char *s, unsigned len) ...@@ -436,10 +440,9 @@ static unsigned do_yp_touch (ypdata_t *yp, char *s, unsigned len)
} }
ret = snprintf (s, len, "action=touch&sid=%s&st=%s" ret = snprintf (s, len, "action=touch&sid=%s&st=%s"
"&listeners=%u&max_listeners=%s&stype=%s\r\n", "&listeners=%u&max_listeners=%u&stype=%s\r\n",
yp->sid, yp->current_song, listeners, max_listeners, yp->subtype); yp->sid, yp->current_song, listeners, max_listeners, yp->subtype);
free (max_listeners);
if (ret >= (signed)len) if (ret >= (signed)len)
return ret+1; /* space required for above text and nul*/ return ret+1; /* space required for above text and nul*/
......
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