0
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2025-06-30 22:18:19 -04:00

avoid aliasing issues, and make sure each server can take a seperate

default interval as defined in the xml

svn path=/icecast/trunk/icecast/; revision=8101
This commit is contained in:
Karl Heyes 2004-10-25 21:10:10 +00:00
parent 82c116a72d
commit bc9ab55cbb
3 changed files with 21 additions and 18 deletions

View File

@ -215,7 +215,7 @@ void config_clear(ice_config_t *c)
free(dirnode); free(dirnode);
dirnode = nextdirnode; dirnode = nextdirnode;
} }
#ifdef HAVE_YP #ifdef USE_YP
i = 0; i = 0;
while (i < c->num_yp_directories) while (i < c->num_yp_directories)
{ {
@ -746,7 +746,8 @@ static void _parse_directory(xmlDocPtr doc, xmlNodePtr node,
_add_server(doc, node->xmlChildrenNode, configuration); _add_server(doc, node->xmlChildrenNode, configuration);
} else if (strcmp(node->name, "touch-interval") == 0) { } else if (strcmp(node->name, "touch-interval") == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
configuration->touch_interval = atoi(tmp); configuration->yp_touch_interval[configuration->num_yp_directories] =
atoi(tmp);
if (tmp) xmlFree(tmp); if (tmp) xmlFree(tmp);
} }
} while ((node = node->next)); } while ((node = node->next));

View File

@ -135,6 +135,7 @@ typedef struct ice_config_tag
char *group; char *group;
char *yp_url[MAX_YP_DIRECTORIES]; char *yp_url[MAX_YP_DIRECTORIES];
int yp_url_timeout[MAX_YP_DIRECTORIES]; int yp_url_timeout[MAX_YP_DIRECTORIES];
int yp_touch_interval[MAX_YP_DIRECTORIES];
int num_yp_directories; int num_yp_directories;
} ice_config_t; } ice_config_t;

View File

@ -84,8 +84,8 @@ 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;
static struct yp_server *active_yps = NULL, *pending_yps = NULL; static volatile struct yp_server *active_yps = NULL, *pending_yps = NULL;
static 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;
@ -153,14 +153,14 @@ static struct yp_server *find_yp_server (const char *url)
{ {
struct yp_server *server; struct yp_server *server;
server = active_yps; server = (struct yp_server *)active_yps;
while (server) while (server)
{ {
if (strcmp (server->url, url) == 0) if (strcmp (server->url, url) == 0)
return server; return server;
server = server->next; server = server->next;
} }
server = pending_yps; server = (struct yp_server *)pending_yps;
while (server) while (server)
{ {
if (strcmp (server->url, url) == 0) if (strcmp (server->url, url) == 0)
@ -208,7 +208,7 @@ void yp_recheck_config (ice_config_t *config)
DEBUG0("Updating YP configuration"); DEBUG0("Updating YP configuration");
thread_rwlock_rlock (&yp_lock); thread_rwlock_rlock (&yp_lock);
server = active_yps; server = (struct yp_server *)active_yps;
while (server) while (server)
{ {
server->remove = 1; server->remove = 1;
@ -230,7 +230,7 @@ void yp_recheck_config (ice_config_t *config)
} }
server->url = strdup (config->yp_url[i]); server->url = strdup (config->yp_url[i]);
server->url_timeout = config->yp_url_timeout[i]; server->url_timeout = config->yp_url_timeout[i];
server->touch_interval = config->touch_interval; server->touch_interval = config->yp_touch_interval[i];
server->curl = curl_easy_init(); server->curl = curl_easy_init();
if (server->curl == NULL) if (server->curl == NULL)
{ {
@ -246,7 +246,7 @@ void yp_recheck_config (ice_config_t *config)
curl_easy_setopt (server->curl, CURLOPT_TIMEOUT, server->url_timeout); curl_easy_setopt (server->curl, CURLOPT_TIMEOUT, server->url_timeout);
curl_easy_setopt (server->curl, CURLOPT_NOSIGNAL, 1L); curl_easy_setopt (server->curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt (server->curl, CURLOPT_ERRORBUFFER, &(server->curl_error[0])); curl_easy_setopt (server->curl, CURLOPT_ERRORBUFFER, &(server->curl_error[0]));
server->next = pending_yps; server->next = (struct yp_server *)pending_yps;
pending_yps = server; pending_yps = server;
INFO3 ("Adding new YP server \"%s\" (timeout %ds, default interval %ds)", INFO3 ("Adding new YP server \"%s\" (timeout %ds, default interval %ds)",
server->url, server->url_timeout, server->touch_interval); server->url, server->url_timeout, server->touch_interval);
@ -536,7 +536,8 @@ static ypdata_t *create_yp_entry (source_t *source)
/* Check for changes in the YP servers configured */ /* Check for changes in the YP servers configured */
static void check_servers () static void check_servers ()
{ {
struct yp_server *server = active_yps, **server_p = &active_yps; struct yp_server *server = (struct yp_server *)active_yps,
**server_p = (struct yp_server **)&active_yps;
while (server) while (server)
{ {
@ -557,11 +558,11 @@ static void check_servers ()
{ {
avl_node *node; avl_node *node;
server = pending_yps; server = (struct yp_server *)pending_yps;
pending_yps = server->next; pending_yps = server->next;
DEBUG1("Add pending yps %s", server->url); DEBUG1("Add pending yps %s", server->url);
server->next = active_yps; server->next = (struct yp_server *)active_yps;
active_yps = server; active_yps = server;
/* new YP server configured, need to populate with existing sources */ /* new YP server configured, need to populate with existing sources */
@ -644,7 +645,7 @@ static void *yp_update_thread(void *arg)
/* do the YP communication */ /* do the YP communication */
thread_rwlock_rlock (&yp_lock); thread_rwlock_rlock (&yp_lock);
server = active_yps; server = (struct yp_server *)active_yps;
while (server) while (server)
{ {
/* DEBUG1 ("trying %s", server->url); */ /* DEBUG1 ("trying %s", server->url); */
@ -658,7 +659,7 @@ static void *yp_update_thread(void *arg)
{ {
thread_rwlock_wlock (&yp_lock); thread_rwlock_wlock (&yp_lock);
check_servers (); check_servers ();
server = active_yps; server = (struct yp_server *)active_yps;
while (server) while (server)
{ {
/* DEBUG1 ("Checking yps %s", server->url); */ /* DEBUG1 ("Checking yps %s", server->url); */
@ -675,7 +676,7 @@ static void *yp_update_thread(void *arg)
/* free server and ypdata left */ /* free server and ypdata left */
while (active_yps) while (active_yps)
{ {
struct yp_server *server = active_yps; struct yp_server *server = (struct yp_server *)active_yps;
active_yps = server->next; active_yps = server->next;
destroy_yp_server (server); destroy_yp_server (server);
} }
@ -826,7 +827,7 @@ void yp_add (source_t *source)
/* make sure we don't race against another yp_add */ /* make sure we don't race against another yp_add */
thread_mutex_lock (&yp_pending_lock); thread_mutex_lock (&yp_pending_lock);
server = active_yps; server = (struct yp_server *)active_yps;
while (server) while (server)
{ {
ypdata_t *yp; ypdata_t *yp;
@ -852,7 +853,7 @@ void yp_add (source_t *source)
/* Mark an existing entry in the YP list as to be marked for deletion */ /* Mark an existing entry in the YP list as to be marked for deletion */
void yp_remove (const char *mount) void yp_remove (const char *mount)
{ {
struct yp_server *server = active_yps; struct yp_server *server = (struct yp_server *)active_yps;
thread_rwlock_rlock (&yp_lock); thread_rwlock_rlock (&yp_lock);
while (server) while (server)
@ -874,7 +875,7 @@ void yp_remove (const char *mount)
* attempt */ * attempt */
void yp_touch (const char *mount) void yp_touch (const char *mount)
{ {
struct yp_server *server = active_yps; struct yp_server *server = (struct yp_server *)active_yps;
time_t trigger; time_t trigger;
ypdata_t *search_list = NULL; ypdata_t *search_list = NULL;