Commit 2c2576ed authored by Ed "oddsock" Zaleski's avatar Ed "oddsock" Zaleski

- fixed alot of yp logic. timeouts now work properly so the tolerance of

  the unavailability of yp servers is much much better now.

- new icecast config option <yp-url-timeout> to specify the timeout

- url encoding is now fixed so that the yp data is formatted much nicer (and is correct :))

- added url encoding for some fields that were not url-encoded

- modified util_dict_urlencode() to not url-encode the key (still does the value)

- new curl option (CURLOPT_NOSIGNAL) which prevents curl from using signals when
  timeouts are hit.  This new option needs curl 7.10 at least.

svn path=/trunk/icecast/; revision=4603
parent 801ab0bc
This diff is collapsed.
......@@ -519,8 +519,8 @@ int util_dict_set(util_dict *dict, const char *key, const char *val)
return 1;
}
/* given a dictionary, URL-encode each key and val and
stringify them in order as key=val&key=val... if val
/* given a dictionary, URL-encode each val and
stringify it in order as key=val&key=val... if val
is set, or just key&key if val is NULL.
TODO: Memory management needs overhaul. */
char *util_dict_urlencode(util_dict *dict, char delim)
......@@ -533,28 +533,19 @@ char *util_dict_urlencode(util_dict *dict, char delim)
/* encode key */
if (!dict->key)
continue;
if (!(enc = util_url_escape(dict->key))) {
if (res)
free(res);
return NULL;
}
if (start) {
if (!(res = malloc(strlen(enc) + 1))) {
free(enc);
if (!(res = malloc(strlen(dict->key) + 1))) {
return NULL;
}
sprintf(res, "%s", enc);
free(enc);
sprintf(res, "%s", dict->key);
start = 0;
} else {
if (!(tmp = realloc(res, strlen(res) + strlen(enc) + 2))) {
free(enc);
if (!(tmp = realloc(res, strlen(res) + strlen(dict->key) + 2))) {
free(res);
return NULL;
} else
res = tmp;
sprintf(res + strlen(res), "%c%s", delim, enc);
free(enc);
sprintf(res + strlen(res), "%c%s", delim, dict->key);
}
/* encode value */
......
......@@ -19,16 +19,21 @@
static int yp_submit_url(int curl_con, char *yp_url, char *url, char *type, int i)
{
int ret = 0;
int *timeout;
int timeout;
ice_config_t *config = config_get_config();
timeout = config->yp_url_timeout + i;
timeout = config->yp_url_timeout[i];
config_release_config();
/* If not specified, use a reasonable timeout
of 30 seconds */
if (timeout == 0) {
timeout = 30;
}
curl_easy_setopt(curl_get_handle(curl_con), CURLOPT_URL, yp_url);
curl_easy_setopt(curl_get_handle(curl_con), CURLOPT_POSTFIELDS, url);
curl_easy_setopt(curl_get_handle(curl_con), CURLOPT_TIMEOUT, timeout);
/* This is to force libcurl to not use signals for timeouts */
curl_easy_setopt(curl_get_handle(curl_con), CURLOPT_NOSIGNAL, 1);
/* get it! */
memset(curl_get_result(curl_con), 0, sizeof(struct curl_memory_struct));
memset(curl_get_header_result(curl_con), 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment