[xiph-commits] r9139 - icecast/branches/kh/icecast/src
karl at motherfish-iii.xiph.org
karl at motherfish-iii.xiph.org
Thu Apr 14 19:07:34 PDT 2005
Author: karl
Date: 2005-04-14 19:07:29 -0700 (Thu, 14 Apr 2005)
New Revision: 9139
Modified:
icecast/branches/kh/icecast/src/cfgfile.c
icecast/branches/kh/icecast/src/cfgfile.h
icecast/branches/kh/icecast/src/connection.c
icecast/branches/kh/icecast/src/connection.h
icecast/branches/kh/icecast/src/format_ogg.c
icecast/branches/kh/icecast/src/slave.c
icecast/branches/kh/icecast/src/source.c
icecast/branches/kh/icecast/src/xslt.c
icecast/branches/kh/icecast/src/yp.c
Log:
Various fixes and cleanups. Theora keyframes could have a refcount uncleared
on chained streams leading to large memory use by the queue. YP add now deals
with querying the stats allowing for a delay when collecting the details.
small leaks elsewhere plugged.
Modified: icecast/branches/kh/icecast/src/cfgfile.c
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.c 2005-04-14 19:30:40 UTC (rev 9138)
+++ icecast/branches/kh/icecast/src/cfgfile.c 2005-04-15 02:07:29 UTC (rev 9139)
@@ -87,13 +87,11 @@
static void create_locks() {
thread_mutex_create("relay lock", &_locks.relay_lock);
- thread_mutex_create("mounts lock", &_locks.mounts_lock);
thread_rwlock_create(&_locks.config_lock);
}
static void release_locks() {
thread_mutex_destroy(&_locks.relay_lock);
- thread_mutex_destroy(&_locks.mounts_lock);
thread_rwlock_destroy(&_locks.config_lock);
}
@@ -181,7 +179,6 @@
}
thread_mutex_unlock(&(_locks.relay_lock));
- thread_mutex_lock(&(_locks.mounts_lock));
mount = c->mounts;
while(mount) {
nextmount = mount->next;
@@ -193,6 +190,11 @@
xmlFree(mount->on_connect);
xmlFree(mount->on_disconnect);
xmlFree(mount->fallback_mount);
+ xmlFree(mount->stream_name);
+ xmlFree(mount->stream_description);
+ xmlFree(mount->stream_url);
+ xmlFree(mount->stream_genre);
+ xmlFree(mount->bitrate);
if (mount->cluster_password) {
xmlFree(mount->cluster_password);
}
@@ -211,7 +213,6 @@
free(mount);
mount = nextmount;
}
- thread_mutex_unlock(&(_locks.mounts_lock));
alias = c->aliases;
while(alias) {
Modified: icecast/branches/kh/icecast/src/cfgfile.h
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.h 2005-04-14 19:30:40 UTC (rev 9138)
+++ icecast/branches/kh/icecast/src/cfgfile.h 2005-04-15 02:07:29 UTC (rev 9139)
@@ -168,7 +168,6 @@
typedef struct {
rwlock_t config_lock;
mutex_t relay_lock;
- mutex_t mounts_lock;
} ice_config_locks;
void config_initialize(void);
Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c 2005-04-14 19:30:40 UTC (rev 9138)
+++ icecast/branches/kh/icecast/src/connection.c 2005-04-15 02:07:29 UTC (rev 9139)
@@ -431,7 +431,7 @@
/* Called when activating a source. Verifies that the source count is not
* exceeded and applies any initial parameters.
*/
-int connection_complete_source (source_t *source)
+int connection_complete_source (source_t *source, connection_t *con, http_parser_t *parser)
{
ice_config_t *config = config_get_config();
@@ -444,7 +444,11 @@
format_type_t format_type;
/* setup format handler */
- contenttype = httpp_getvar (source->parser, "content-type");
+ if (parser || source->client == NULL)
+ contenttype = httpp_getvar (parser, "content-type");
+ else
+ contenttype = httpp_getvar (source->client->parser, "content-type");
+
if (contenttype != NULL)
{
format_type = format_get_type (contenttype);
@@ -484,8 +488,15 @@
* because we can't use this client to return an error code/message,
* so we only do this once we know we're going to accept the source.
*/
- if (source->client == NULL && source->con)
- source->client = client_create (source->con, source->parser);
+ if (source->client == NULL && con)
+ {
+ source->client = client_create (con, parser);
+ if (source->client == NULL)
+ {
+ config_release_config();
+ return -1;
+ }
+ }
source_update_settings (config, source);
config_release_config();
@@ -624,7 +635,6 @@
char *protocol;
mount_proxy *mountinfo = config->mounts;
- thread_mutex_lock(&(config_locks()->mounts_lock));
while(mountinfo) {
if(!strcmp(mountinfo->mountname, mount)) {
@@ -637,8 +647,6 @@
mountinfo = mountinfo->next;
}
- thread_mutex_unlock(&(config_locks()->mounts_lock));
-
if(!pass) {
WARN0("No source password set, rejecting source");
config_release_config();
@@ -700,7 +708,7 @@
source->client = client;
source->parser = parser;
source->con = con;
- if (connection_complete_source (source) < 0)
+ if (connection_complete_source (source, NULL, NULL) < 0)
{
source->client = NULL;
source_free_source (source);
Modified: icecast/branches/kh/icecast/src/connection.h
===================================================================
--- icecast/branches/kh/icecast/src/connection.h 2005-04-14 19:30:40 UTC (rev 9138)
+++ icecast/branches/kh/icecast/src/connection.h 2005-04-15 02:07:29 UTC (rev 9139)
@@ -48,7 +48,8 @@
void connection_accept_loop(void);
void connection_close(connection_t *con);
connection_t *create_connection(sock_t sock, sock_t serversock, char *ip);
-int connection_complete_source (struct source_tag *source);
+int connection_complete_source (struct source_tag *source, connection_t *con,
+ http_parser_t *parser);
void connection_inject_event(int eventnum, void *event_data);
Modified: icecast/branches/kh/icecast/src/format_ogg.c
===================================================================
--- icecast/branches/kh/icecast/src/format_ogg.c 2005-04-14 19:30:40 UTC (rev 9138)
+++ icecast/branches/kh/icecast/src/format_ogg.c 2005-04-15 02:07:29 UTC (rev 9139)
@@ -140,6 +140,8 @@
while (codec)
{
ogg_codec_t *next = codec->next;
+ if (codec->possible_start)
+ refbuf_release (codec->possible_start);
codec->codec_free (ogg_info, codec);
codec = next;
}
Modified: icecast/branches/kh/icecast/src/slave.c
===================================================================
--- icecast/branches/kh/icecast/src/slave.c 2005-04-14 19:30:40 UTC (rev 9138)
+++ icecast/branches/kh/icecast/src/slave.c 2005-04-15 02:07:29 UTC (rev 9139)
@@ -300,7 +300,7 @@
}
src->parser = parser;
src->con = con;
- if (connection_complete_source (src) < 0)
+ if (connection_complete_source (src, con, parser) < 0)
{
DEBUG0("Failed to complete source initialisation");
break;
Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c 2005-04-14 19:30:40 UTC (rev 9138)
+++ icecast/branches/kh/icecast/src/source.c 2005-04-15 02:07:29 UTC (rev 9139)
@@ -232,6 +232,10 @@
source->pending_clients_tail = &source->pending_clients;
source->first_normal_client = NULL;
+ if (source->format && source->format->free_plugin)
+ source->format->free_plugin (source->format);
+ source->format = NULL;
+
/* flush out the stream data, we don't want any left over */
while (source->stream_data)
{
@@ -244,12 +248,6 @@
}
source->stream_data_tail = NULL;
- if (source->format && source->format->free_plugin)
- {
- source->format->free_plugin (source->format);
- }
- source->format = NULL;
-
source->burst_point = NULL;
source->burst_size = 0;
source->burst_offset = 0;
@@ -995,8 +993,6 @@
static void source_apply_mount (source_t *source, mount_proxy *mountinfo)
{
- char *str;
-
if (strcmp (mountinfo->mountname, source->mount) == 0)
INFO1 ("Applying mount information for \"%s\"", source->mount);
else
@@ -1007,46 +1003,21 @@
source->no_mount = mountinfo->no_mount;
source->hidden = mountinfo->hidden;
- do
- {
- str = mountinfo->stream_name;
- if (str) break;
- str = httpp_getvar(source->parser, "ice-name");
- if (str) break;
- str = httpp_getvar(source->parser, "icy-name");
- } while (0);
- stats_event (source->mount, "server_name", str);
+ if (mountinfo->stream_name)
+ stats_event (source->mount, "server_name", mountinfo->stream_name);
- do
- {
- str = mountinfo->stream_description;
- if (str) break;
- str = httpp_getvar(source->parser, "ice-description");
- if (str) break;
- str = httpp_getvar(source->parser, "icy-description");
- } while (0);
- stats_event (source->mount, "server_description", str);
+ if (mountinfo->stream_description)
+ stats_event (source->mount, "server_description", mountinfo->stream_description);
- do
- {
- str = mountinfo->stream_genre;
- if (str) break;
- str = httpp_getvar(source->parser, "ice-genre");
- if (str) break;
- str = httpp_getvar(source->parser, "icy-genre");
- } while (0);
- stats_event (source->mount, "genre", str);
+ if (mountinfo->stream_url)
+ stats_event (source->mount, "server_url", mountinfo->stream_url);
- do
- {
- str = mountinfo->bitrate;
- if (str) break;
- str = httpp_getvar(source->parser, "ice-bitrate");
- if (str) break;
- str = httpp_getvar(source->parser, "icy-br");
- } while (0);
- stats_event (source->mount, "bitrate", str);
+ if (mountinfo->stream_genre)
+ stats_event (source->mount, "genre", mountinfo->stream_genre);
+ if (mountinfo->bitrate)
+ stats_event (source->mount, "bitrate", mountinfo->bitrate);
+
if (mountinfo->auth)
stats_event (source->mount, "authenticator", mountinfo->auth->type);
else
@@ -1115,6 +1086,7 @@
void source_update_settings (ice_config_t *config, source_t *source)
{
mount_proxy *mountinfo = config_find_mount (config, source->mount);
+ char *str;
/* set global settings first */
source->queue_size_limit = config->queue_size_limit;
@@ -1122,6 +1094,51 @@
source->burst_size = config->burst_size;
source->dumpfilename = NULL;
+ do {
+ str = httpp_getvar(source->parser, "ice-name");
+ if (str) break;
+ str = httpp_getvar(source->parser, "icy-name");
+ if (str) break;
+ str = httpp_getvar(source->parser, "x-audiocast-name");
+ } while (0);
+ stats_event (source->mount, "server_name", str);
+
+ do {
+ str = httpp_getvar(source->parser, "ice-description");
+ if (str) break;
+ str = httpp_getvar(source->parser, "icy-description");
+ if (str) break;
+ str = httpp_getvar(source->parser, "x-audiocast-description");
+ } while (0);
+ stats_event (source->mount, "server_description", str);
+
+ do {
+ str = httpp_getvar(source->parser, "ice-genre");
+ if (str) break;
+ str = httpp_getvar(source->parser, "icy-genre");
+ if (str) break;
+ str = httpp_getvar(source->parser, "x-audiocast-genre");
+ } while (0);
+ stats_event (source->mount, "genre", str);
+
+ do {
+ str = httpp_getvar(source->parser, "ice-url");
+ if (str) break;
+ str = httpp_getvar(source->parser, "icy-url");
+ if (str) break;
+ str = httpp_getvar(source->parser, "x-audiocast-url");
+ } while (0);
+ stats_event (source->mount, "server_url", str);
+
+ do {
+ str = httpp_getvar(source->parser, "ice-bitrate");
+ if (str) break;
+ str = httpp_getvar(source->parser, "icy-br");
+ if (str) break;
+ str = httpp_getvar(source->parser, "x-audiocast-bitrate");
+ } while (0);
+ stats_event (source->mount, "bitrate", str);
+
if (mountinfo && source->file_only == 0)
source_apply_mount (source, mountinfo);
@@ -1314,7 +1331,7 @@
source->intro_file = file;
file = NULL;
- if (connection_complete_source (source) < 0)
+ if (connection_complete_source (source, NULL, NULL) < 0)
break;
source_client_thread (source);
} while (0);
Modified: icecast/branches/kh/icecast/src/xslt.c
===================================================================
--- icecast/branches/kh/icecast/src/xslt.c 2005-04-14 19:30:40 UTC (rev 9138)
+++ icecast/branches/kh/icecast/src/xslt.c 2005-04-15 02:07:29 UTC (rev 9139)
@@ -82,6 +82,7 @@
xsltFreeStylesheet(cache[i].stylesheet);
}
+ thread_mutex_destroy (&xsltlock);
xsltCleanupGlobals();
}
Modified: icecast/branches/kh/icecast/src/yp.c
===================================================================
--- icecast/branches/kh/icecast/src/yp.c 2005-04-14 19:30:40 UTC (rev 9138)
+++ icecast/branches/kh/icecast/src/yp.c 2005-04-15 02:07:29 UTC (rev 9139)
@@ -334,22 +334,33 @@
int ret;
char *value;
- if (yp->bitrate == NULL)
- {
- yp->bitrate = stats_get_value (yp->mount, "ice-bitrate");
- if (yp->bitrate == NULL)
- {
- yp->next_update = time(NULL) + 5;
- WARN1 ("mount \"%s\" bitrate unknown, cannot add to YP", yp->mount);
- return 0;
- }
- }
+ value = stats_get_value (yp->mount, "server_type");
+ add_yp_info (yp, value, YP_SERVER_TYPE);
+ free (value);
+
+ value = stats_get_value (yp->mount, "server_name");
+ add_yp_info (yp, value, YP_SERVER_NAME);
+ free (value);
+
+ value = stats_get_value (yp->mount, "server_url");
+ add_yp_info (yp, value, YP_SERVER_URL);
+ free (value);
+
+ value = stats_get_value (yp->mount, "genre");
+ add_yp_info (yp, value, YP_SERVER_GENRE);
+ free (value);
+
+ value = stats_get_value (yp->mount, "bitrate");
+ add_yp_info (yp, value, YP_BITRATE);
+ free (value);
+
+ value = stats_get_value (yp->mount, "stream_description");
+ add_yp_info (yp, value, YP_SERVER_DESC);
+ free (value);
+
value = stats_get_value (yp->mount, "subtype");
- if (value)
- {
- add_yp_info (yp, value, YP_SUBTYPE);
- free (value);
- }
+ add_yp_info (yp, value, YP_SUBTYPE);
+ free (value);
ret = snprintf (s, len, "action=add&sn=%s&genre=%s&cpswd=%s&desc="
"%s&url=%s&listenurl=%s&type=%s&stype=%s&b=%s&%s\r\n",
@@ -541,28 +552,6 @@
if (yp->listen_url == NULL)
break;
- /* ice-* is icecast, icy-* is shoutcast */
- add_yp_info (yp, source->format->contenttype, YP_SERVER_TYPE);
-
- s = stats_get_value (yp->mount, "server_name");
- add_yp_info (yp, s, YP_SERVER_NAME);
- free (s);
-
- s = stats_get_value (yp->mount, "server_url");
- add_yp_info (yp, s, YP_SERVER_URL);
- free (s);
-
- s = stats_get_value (yp->mount, "genre");
- add_yp_info (yp, s, YP_SERVER_GENRE);
- free (s);
-
- s = stats_get_value (yp->mount, "bitrate");
- add_yp_info (yp, s, YP_BITRATE);
- free (s);
-
- s = stats_get_value (yp->mount, "stream_description");
- add_yp_info (yp, s, YP_SERVER_DESC);
-
s = util_dict_urlencode (source->audio_info, '&');
if (s)
add_yp_info (yp, s, YP_AUDIO_INFO);
@@ -901,6 +890,7 @@
yp->server = server;
yp->touch_interval = server->touch_interval;
yp->next = server->pending_mounts;
+ yp->next_update = time(NULL) + 5;
server->pending_mounts = yp;
yp_update = 1;
}
More information about the commits
mailing list