[xiph-commits] r9156 - icecast/branches/kh/icecast/src
karl at motherfish-iii.xiph.org
karl at motherfish-iii.xiph.org
Tue Apr 19 06:29:41 PDT 2005
Author: karl
Date: 2005-04-19 06:29:37 -0700 (Tue, 19 Apr 2005)
New Revision: 9156
Modified:
icecast/branches/kh/icecast/src/admin.c
icecast/branches/kh/icecast/src/auth_url.c
icecast/branches/kh/icecast/src/connection.c
icecast/branches/kh/icecast/src/yp.c
Log:
revert source count change, it's a mutex not read lock. Add server= to
auth url requests and add some NULL checks.
Make streamlist.txt produce list based on mounts not sources, a source
client on master with a fallback was causing slaves to shutdown relays
as the source disappeared from the list.
Modified: icecast/branches/kh/icecast/src/admin.c
===================================================================
--- icecast/branches/kh/icecast/src/admin.c 2005-04-19 12:15:06 UTC (rev 9155)
+++ icecast/branches/kh/icecast/src/admin.c 2005-04-19 13:29:37 UTC (rev 9156)
@@ -1086,20 +1086,33 @@
int ret = snprintf (buffer, remaining,
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
- avl_node *node = avl_get_first(global.source_tree);
- while (node && ret > 0 && (unsigned)ret < remaining)
+ ice_config_t *config = config_get_config ();
+ mount_proxy *mountinfo = config->mounts;
+ while (mountinfo)
{
- source_t *source = (source_t *)node->key;
- node = avl_get_next(node);
+ mount_proxy *current = mountinfo;
+ source_t *source;
+ mountinfo = mountinfo->next;
+
+ /* avoid non-specific mounts */
+ if (strcmp (current->mountname, "all") == 0)
+ continue;
+ /* now check that a source is available */
+ source = source_find_mount (current->mountname);
+
+ if (source == NULL)
+ continue;
if (source->running == 0 && source->on_demand == 0)
continue;
if (source->hidden)
continue;
remaining -= ret;
buf += ret;
- ret = snprintf (buf, remaining, "%s\n", source->mount);
+ ret = snprintf (buf, remaining, "%s\n", current->mountname);
}
avl_tree_unlock (global.source_tree);
+ config_release_config();
+
/* handle last line */
if (ret > 0 && (unsigned)ret < remaining)
{
Modified: icecast/branches/kh/icecast/src/auth_url.c
===================================================================
--- icecast/branches/kh/icecast/src/auth_url.c 2005-04-19 12:15:06 UTC (rev 9155)
+++ icecast/branches/kh/icecast/src/auth_url.c 2005-04-19 13:29:37 UTC (rev 9156)
@@ -122,18 +122,24 @@
auth_t *auth = client->auth;
auth_url *url = auth->state;
time_t duration = time(NULL) - client->con->con_time;
- char *username, *password, *mount;
+ char *username, *password, *mount, *server;
+ ice_config_t *config;
char post[1024];
if (url->removeurl == NULL)
return AUTH_OK;
+ config = config_get_config ();
+ server = util_url_escape (config->hostname);
+ config_release_config ();
username = util_url_escape (client->username);
password = util_url_escape (client->password);
mount = util_url_escape (auth_user->mount);
snprintf (post, sizeof (post),
- "action=remove&client=%lu&mount=%s&user=%s&pass=%s&duration=%lu",
- client->con->id, mount, username, password, (long unsigned)duration);
+ "action=remove&server=%sclient=%lu&mount=%s"
+ "&user=%s&pass=%s&duration=%lu",
+ server, client->con->id, mount, username,
+ password, (long unsigned)duration);
free (mount);
free (username);
free (password);
@@ -160,9 +166,16 @@
auth_url *url = auth->state;
int res = 0;
char *agent, *user_agent, *username, *password;
- char *mount, *ipaddr;
+ char *mount, *ipaddr, *server;
+ ice_config_t *config;
char post[1024];
+ if (url->addurl == NULL)
+ return AUTH_OK;
+
+ config = config_get_config ();
+ server = util_url_escape (config->hostname);
+ config_release_config ();
agent = httpp_getvar (client->parser, "user-agent");
if (agent == NULL)
agent = "-";
@@ -173,8 +186,10 @@
ipaddr = util_url_escape (client->con->ip);
snprintf (post, sizeof (post),
- "action=auth&client=%lu&mount=%s&user=%s&pass=%s&ip=%s&agent=%s",
- client->con->id, mount, username, password, ipaddr, user_agent);
+ "action=auth&server=%s&client=%lu&mount=%s"
+ "&user=%s&pass=%s&ip=%s&agent=%s",
+ server, client->con->id, mount, username,
+ password, ipaddr, user_agent);
free (mount);
free (user_agent);
free (username);
@@ -219,6 +234,11 @@
char *stream_start_url;
char post [4096];
+ if (url->stream_start == NULL)
+ {
+ config_release_config ();
+ return AUTH_OK;
+ }
server = util_url_escape (config->hostname);
stream_start_url = strdup (url->stream_start);
/* we don't want this auth disappearing from under us while
@@ -255,6 +275,11 @@
char *stream_end_url;
char post [4096];
+ if (url->stream_end == NULL)
+ {
+ config_release_config ();
+ return AUTH_OK;
+ }
server = util_url_escape (config->hostname);
stream_end_url = strdup (url->stream_end);
/* we don't want this auth disappearing from under us while
Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c 2005-04-19 12:15:06 UTC (rev 9155)
+++ icecast/branches/kh/icecast/src/connection.c 2005-04-19 13:29:37 UTC (rev 9156)
@@ -481,6 +481,9 @@
return -1;
}
+ global.sources++;
+ global_unlock();
+
/* for relays, we don't yet have a client, however we do require one
* to retrieve the stream from. This is created here, quite late,
* because we can't use this client to return an error code/message,
@@ -491,15 +494,14 @@
source->client = client_create (con, parser);
if (source->client == NULL)
{
+ global_lock();
+ global.sources--;
global_unlock();
config_release_config();
return -1;
}
}
- global.sources++;
- global_unlock();
-
source_update_settings (config, source);
config_release_config();
Modified: icecast/branches/kh/icecast/src/yp.c
===================================================================
--- icecast/branches/kh/icecast/src/yp.c 2005-04-19 12:15:06 UTC (rev 9155)
+++ icecast/branches/kh/icecast/src/yp.c 2005-04-19 13:29:37 UTC (rev 9156)
@@ -516,6 +516,7 @@
yp->server_name = strdup ("");
yp->server_desc = strdup ("");
yp->server_genre = strdup ("");
+ yp->bitrate = strdup ("");
yp->server_type = strdup ("");
yp->cluster_password = strdup ("");
yp->url = strdup ("");
More information about the commits
mailing list