[xiph-cvs] cvs commit: icecast/src yp.c yp.h event.c
Karl Heyes
karl at xiph.org
Mon Jan 26 14:42:23 PST 2004
karl 04/01/26 17:42:23
Modified: src yp.c yp.h event.c
Log:
fix potential deadlock case at source stream startup
Revision Changes Path
1.15 +17 -12 icecast/src/yp.c
Index: yp.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/yp.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- yp.c 17 Nov 2003 21:36:03 -0000 1.14
+++ yp.c 26 Jan 2004 22:42:22 -0000 1.15
@@ -21,20 +21,25 @@
#define CATMODULE "yp"
+static int yp_url_timeout [MAX_YP_DIRECTORIES];
+
+void yp_recheck_config (ice_config_t *config)
+{
+ memcpy (&config->yp_url_timeout[0], yp_url_timeout, (sizeof yp_url_timeout));
+}
+
void yp_initialize()
{
+ ice_config_t *config = config_get_config();
+ yp_recheck_config (config);
+ config_release_config ();
thread_create("YP Touch Thread", yp_touch_thread,
(void *)NULL, THREAD_DETACHED);
}
static int yp_submit_url(int curl_con, char *yp_url, char *url, char *type,
- int i)
+ int timeout)
{
int ret = 0;
- int timeout;
- ice_config_t *config = config_get_config();
-
- timeout = config->yp_url_timeout[i];
- config_release_config();
/* If not specified, use a reasonable timeout
of 30 seconds */
if (timeout == 0) {
@@ -74,7 +79,6 @@
void *yp_touch_thread(void *arg)
{
yp_touch();
- thread_exit(0);
return NULL;
}
@@ -114,7 +118,7 @@
else {
/* specify URL to get */
ret = yp_submit_url(curl_con, source->ypdata[i]->yp_url,
- url, "yp_remove", i);
+ url, "yp_remove", yp_url_timeout[i]);
}
if (url) {
free(url);
@@ -197,6 +201,7 @@
if (source->ypdata[i]->sid != 0) {
if (strlen(source->ypdata[i]->sid) != 0) {
if (source->ypdata) {
+ struct tm tm;
url_size =
strlen("action=touch&sid=&st=&listeners=") + 1;
if (source->ypdata[i]->current_song) {
@@ -231,7 +236,7 @@
/* specify URL to get */
ret = yp_submit_url(curl_con,
source->ypdata[i]->yp_url,
- url, "yp_touch", i);
+ url, "yp_touch", yp_url_timeout[i]);
if (!ret) {
source->ypdata[i]->sid[0] = 0;
}
@@ -241,8 +246,8 @@
}
curl_release_connection(curl_con);
memset(tyme, '\000', sizeof(tyme));
- strftime(tyme, 128, "%Y-%m-%d %H:%M:%S",
- localtime(¤t_time));
+ localtime_r (¤t_time, &tm);
+ strftime(tyme, 128, "%Y-%m-%d %H:%M:%S", &tm);
stats_event(source->mount, "yp_last_touch", tyme);
source->ypdata[i]->yp_last_touch = current_time;
}
@@ -378,7 +383,7 @@
else {
/* specify URL to get */
ret = yp_submit_url(curl_con, source->ypdata[i]->yp_url,
- url, "yp_add", i);
+ url, "yp_add", yp_url_timeout[i]);
if (ret) {
if (strlen(curl_get_header_result(curl_con)->sid) > 0) {
<p><p>1.9 +5 -0 icecast/src/yp.h
Index: yp.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/yp.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- yp.h 8 Jul 2003 14:11:01 -0000 1.8
+++ yp.h 26 Jan 2004 22:42:22 -0000 1.9
@@ -43,6 +43,11 @@
void yp_destroy_ypdata(ypdata_t *ypdata);
void add_yp_info(struct source_tag *source, char *stat_name, void *info,
int type);
+#ifdef USE_YP
+void yp_recheck_config (ice_config_t *config);
+#else
+#define yp_recheck_config(x) do{}while(0)
+#endif
void yp_initialize();
#endif
<p><p>1.5 +2 -0 icecast/src/event.c
Index: event.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/event.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- event.c 21 Jul 2003 01:58:54 -0000 1.4
+++ event.c 26 Jan 2004 22:42:22 -0000 1.5
@@ -4,6 +4,7 @@
#include "event.h"
#include "cfgfile.h"
+#include "yp.h"
#include "refbuf.h"
#include "client.h"
@@ -44,6 +45,7 @@
config_clear(config);
config_set_config(&new_config);
restart_logging ();
+ yp_recheck_config (config);
config_release_config();
}
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list