[xiph-commits] r9720 - icecast/trunk/icecast/src
karl at svn.xiph.org
karl at svn.xiph.org
Mon Aug 8 19:14:23 PDT 2005
Author: karl
Date: 2005-08-08 19:14:20 -0700 (Mon, 08 Aug 2005)
New Revision: 9720
Modified:
icecast/trunk/icecast/src/admin.c
icecast/trunk/icecast/src/client.c
icecast/trunk/icecast/src/yp.c
Log:
merge fixes. NULL checks
Modified: icecast/trunk/icecast/src/admin.c
===================================================================
--- icecast/trunk/icecast/src/admin.c 2005-08-09 01:01:04 UTC (rev 9719)
+++ icecast/trunk/icecast/src/admin.c 2005-08-09 02:14:20 UTC (rev 9720)
@@ -240,8 +240,8 @@
source->fallback_mount:"");
snprintf (buf, sizeof(buf), "%lu", source->listeners);
xmlNewChild(srcnode, NULL, "listeners", buf);
+
config = config_get_config();
-
mountinfo = config_find_mount (config, source->mount);
if (mountinfo && mountinfo->auth)
{
@@ -252,9 +252,12 @@
if (source->running)
{
- snprintf (buf, sizeof(buf), "%lu",
- (unsigned long)(now - source->con->con_time));
- xmlNewChild (srcnode, NULL, "Connected", buf);
+ if (source->client->con)
+ {
+ snprintf (buf, sizeof(buf), "%lu",
+ (unsigned long)(now - source->con->con_time));
+ xmlNewChild (srcnode, NULL, "Connected", buf);
+ }
xmlNewChild (srcnode, NULL, "content-type",
source->format->contenttype);
}
Modified: icecast/trunk/icecast/src/client.c
===================================================================
--- icecast/trunk/icecast/src/client.c 2005-08-09 01:01:04 UTC (rev 9719)
+++ icecast/trunk/icecast/src/client.c 2005-08-09 02:14:20 UTC (rev 9720)
@@ -79,12 +79,13 @@
/* write log entry if ip is set (some things don't set it, like outgoing
* slave requests
*/
- if (client->con && client->con->ip)
+ if (client->respcode && client->parser)
logging_access(client);
if (client->con)
connection_close(client->con);
- httpp_destroy(client->parser);
+ if (client->parser)
+ httpp_destroy(client->parser);
global_lock ();
global.clients--;
@@ -94,11 +95,13 @@
/* drop ref counts if need be */
if (client->refbuf)
refbuf_release (client->refbuf);
+
/* we need to free client specific format data (if any) */
if (client->free_client_data)
client->free_client_data (client);
free(client->username);
+ free(client->password);
free(client);
}
Modified: icecast/trunk/icecast/src/yp.c
===================================================================
--- icecast/trunk/icecast/src/yp.c 2005-08-09 01:01:04 UTC (rev 9719)
+++ icecast/trunk/icecast/src/yp.c 2005-08-09 02:14:20 UTC (rev 9720)
@@ -85,11 +85,12 @@
static rwlock_t yp_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 int yp_running;
static time_t now;
static thread_type *yp_thread;
+static volatile unsigned client_limit = 0;
static void *yp_update_thread(void *arg);
static void add_yp_info (ypdata_t *yp, void *info, int type);
@@ -215,6 +216,7 @@
server->remove = 1;
server = server->next;
}
+ client_limit = config->client_limit;
/* for each yp url in config, check to see if one exists
if not, then add it. */
for (i=0 ; i < config->num_yp_directories; i++)
@@ -387,10 +389,9 @@
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;
int ret;
- char *max_listeners;
artist = (char *)stats_get_value (yp->mount, "artist");
title = (char *)stats_get_value (yp->mount, "title");
@@ -422,12 +423,15 @@
listeners = atoi (val);
free (val);
}
- max_listeners = stats_get_value (yp->mount, "max_listeners");
- if (max_listeners == NULL || strcmp (max_listeners, "unlimited") == 0)
+ val = stats_get_value (yp->mount, "max_listeners");
+ if (val == NULL || strcmp (val, "unlimited") == 0)
{
- free (max_listeners);
- max_listeners = (char *)stats_get_value (NULL, "client_limit");
+ free (val);
+ max_listeners = client_limit;
}
+ else
+ max_listeners = atoi (val);
+
val = stats_get_value (yp->mount, "subtype");
if (val)
{
@@ -436,10 +440,9 @@
}
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);
- free (max_listeners);
if (ret >= (signed)len)
return ret+1; /* space required for above text and nul*/
More information about the commits
mailing list