1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-22 04:15:54 -04:00

Update: Convert Icecast to use libigloo

This commit is contained in:
Philipp Schafft 2018-10-26 14:52:56 +00:00
parent ddb0d0beb3
commit aade92a236
49 changed files with 640 additions and 640 deletions

View File

@ -127,14 +127,14 @@ AC_TYPE_UID_T
dnl Checks for required libraries
dnl
dnl permafrost
dnl igloo
dnl
PKG_CHECK_MODULES([PERMAFROST], [permafrost], [], [
AC_MSG_ERROR([${PERMAFROST_PKG_ERRORS}. permafrost is required.])
PKG_CHECK_MODULES([IGLOO], [igloo], [], [
AC_MSG_ERROR([${IGLOO_PKG_ERRORS}. igloo is required.])
])
CFLAGS="${CFLAGS} ${PERMAFROST_CFLAGS}"
LIBS="${LIBS} ${PERMAFROST_LIBS}"
CFLAGS="${CFLAGS} ${IGLOO_CFLAGS}"
LIBS="${LIBS} ${IGLOO_LIBS}"
dnl
dnl libxml2

View File

@ -242,14 +242,14 @@ int acl_set_method_str__callback(acl_t *acl,
acl_policy_t policy,
const char *str)
{
httpp_request_type_e method;
igloo_httpp_request_type_e method;
size_t i;
if (strcmp(str, "*") == 0) {
for (i = 0; i < (sizeof(acl->method)/sizeof(*acl->method)); i++)
acl->method[i] = policy;
} else {
method = httpp_str_to_method(str);
method = igloo_httpp_str_to_method(str);
if (method == httpp_req_unknown)
return -1;
@ -259,7 +259,7 @@ int acl_set_method_str__callback(acl_t *acl,
return 0;
}
acl_policy_t acl_test_method(acl_t * acl, httpp_request_type_e method)
acl_policy_t acl_test_method(acl_t * acl, igloo_httpp_request_type_e method)
{
if (!acl || method < httpp_req_none || method > httpp_req_unknown)
return ACL_POLICY_ERROR;

View File

@ -16,7 +16,7 @@
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <permafrost/httpp.h>
#include <igloo/httpp.h>
#include "icecasttypes.h"
#include "cfgfile.h"
@ -44,7 +44,7 @@ int acl_set_ANY_str(acl_t * acl, acl_policy_t policy, const char * str, int (*ca
/* HTTP Method specific functions */
int acl_set_method_str__callback(acl_t * acl, acl_policy_t policy, const char * str);
#define acl_set_method_str(acl,policy,str) acl_set_ANY_str((acl), (policy), (str), acl_set_method_str__callback)
acl_policy_t acl_test_method(acl_t * acl, httpp_request_type_e method);
acl_policy_t acl_test_method(acl_t * acl, igloo_httpp_request_type_e method);
/* admin/ interface specific functions */
int acl_set_admin_str__callbck(acl_t * acl, acl_policy_t policy, const char * str);

View File

@ -52,7 +52,7 @@
/* Helper macros */
#define COMMAND_REQUIRE(client,name,var) \
do { \
(var) = httpp_get_param((client)->parser, (name)); \
(var) = igloo_httpp_get_param((client)->parser, (name)); \
if((var) == NULL) { \
client_send_error_by_id(client, ICECAST_ERROR_ADMIN_MISSING_PARAMETER); \
return; \
@ -60,7 +60,7 @@
} while(0);
#define COMMAND_OPTIONAL(client,name,var) \
(var) = httpp_get_param((client)->parser, (name))
(var) = igloo_httpp_get_param((client)->parser, (name))
#define FALLBACK_RAW_REQUEST "fallbacks"
#define FALLBACK_HTML_REQUEST "fallbacks.xsl"
@ -329,7 +329,7 @@ xmlNodePtr admin_build_rootnode(xmlDocPtr doc, const char *name)
* doc even if the source is running */
xmlDocPtr admin_build_sourcelist(const char *mount)
{
avl_node *node;
igloo_avl_node *node;
source_t *source;
xmlNodePtr xmlnode, srcnode;
xmlDocPtr doc;
@ -344,12 +344,12 @@ xmlDocPtr admin_build_sourcelist(const char *mount)
xmlNewTextChild (xmlnode, NULL, XMLSTR("current_source"), XMLSTR(mount));
}
node = avl_get_first(global.source_tree);
node = igloo_avl_get_first(global.source_tree);
while(node) {
source = (source_t *)node->key;
if (mount && strcmp (mount, source->mount) == 0)
{
node = avl_get_next (node);
node = igloo_avl_get_next (node);
continue;
}
@ -390,7 +390,7 @@ xmlDocPtr admin_build_sourcelist(const char *mount)
XMLSTR(source->format->contenttype));
}
}
node = avl_get_next(node);
node = igloo_avl_get_next(node);
}
return(doc);
}
@ -516,19 +516,19 @@ void admin_handle_request(client_t *client, const char *uri)
if(mount != NULL) {
/* This is a mount request, handle it as such */
avl_tree_rlock(global.source_tree);
igloo_avl_tree_rlock(global.source_tree);
source = source_find_mount_raw(mount);
/* No Source found */
if (source == NULL) {
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
ICECAST_LOG_WARN("Admin command \"%H\" on non-existent source \"%H\"",
uri, mount);
client_send_error_by_id(client, ICECAST_ERROR_ADMIN_SOURCE_DOES_NOT_EXIST);
return;
} /* No Source running */
else if (source->running == 0 && source->on_demand == 0) {
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
ICECAST_LOG_INFO("Received admin command \"%H\" on unavailable mount \"%H\"",
uri, mount);
client_send_error_by_id(client, ICECAST_ERROR_ADMIN_SOURCE_IS_NOT_AVAILABLE);
@ -582,7 +582,7 @@ void admin_handle_request(client_t *client, const char *uri)
}
if (source) {
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
}
return;
}
@ -695,15 +695,15 @@ static inline xmlNodePtr __add_listener(client_t *client,
xmlNewTextChild(node, NULL, XMLSTR(mode == OMODE_LEGACY ? "IP" : "ip"), XMLSTR(client->con->ip));
tmp = httpp_getvar(client->parser, "user-agent");
tmp = igloo_httpp_getvar(client->parser, "user-agent");
if (tmp)
xmlNewTextChild(node, NULL, XMLSTR(mode == OMODE_LEGACY ? "UserAgent" : "useragent"), XMLSTR(tmp));
tmp = httpp_getvar(client->parser, "referer");
tmp = igloo_httpp_getvar(client->parser, "referer");
if (tmp)
xmlNewTextChild(node, NULL, XMLSTR("referer"), XMLSTR(tmp));
tmp = httpp_getvar(client->parser, "host");
tmp = igloo_httpp_getvar(client->parser, "host");
if (tmp)
xmlNewTextChild(node, NULL, XMLSTR("host"), XMLSTR(tmp));
@ -735,15 +735,15 @@ void admin_add_listeners_to_mount(source_t *source,
operation_mode mode)
{
time_t now = time(NULL);
avl_node *client_node;
igloo_avl_node *client_node;
avl_tree_rlock(source->client_tree);
client_node = avl_get_first(source->client_tree);
igloo_avl_tree_rlock(source->client_tree);
client_node = igloo_avl_get_first(source->client_tree);
while(client_node) {
__add_listener((client_t *)client_node->key, parent, now, mode);
client_node = avl_get_next(client_node);
client_node = igloo_avl_get_next(client_node);
}
avl_tree_unlock(source->client_tree);
igloo_avl_tree_unlock(source->client_tree);
}
static void command_show_listeners(client_t *client,
@ -1200,9 +1200,9 @@ static void command_list_mounts(client_t *client, source_t *source, admin_format
fserve_add_client (client, NULL);
} else {
xmlDocPtr doc;
avl_tree_rlock(global.source_tree);
igloo_avl_tree_rlock(global.source_tree);
doc = admin_build_sourcelist(NULL);
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
admin_send_response(doc, client, response,
LISTMOUNTS_HTML_REQUEST);

View File

@ -24,7 +24,7 @@
#include <errno.h>
#include <stdio.h>
#include <permafrost/httpp.h>
#include <igloo/httpp.h>
#include "auth.h"
#include "source.h"
@ -43,14 +43,14 @@
struct auth_stack_tag {
size_t refcount;
auth_t *auth;
mutex_t lock;
igloo_mutex_t lock;
auth_stack_t *next;
};
/* code */
static void __handle_auth_client(auth_t *auth, auth_client *auth_user);
static mutex_t _auth_lock; /* protects _current_id */
static igloo_mutex_t _auth_lock; /* protects _current_id */
static volatile unsigned long _current_id = 0;
static unsigned long _next_auth_id(void) {
@ -116,7 +116,7 @@ static auth_client *auth_client_setup (client_t *client)
if (client->username || client->password)
break;
header = httpp_getvar(client->parser, "authorization");
header = igloo_httpp_getvar(client->parser, "authorization");
if (header == NULL)
break;
@ -201,7 +201,7 @@ void auth_release (auth_t *authenticator) {
if (authenticator->running) {
authenticator->running = 0;
thread_mutex_unlock(&authenticator->lock);
thread_join(authenticator->thread);
igloo_thread_join(authenticator->thread);
thread_mutex_lock(&authenticator->lock);
}
@ -214,7 +214,7 @@ void auth_release (auth_t *authenticator) {
if (authenticator->management_url)
xmlFree (authenticator->management_url);
thread_mutex_unlock(&authenticator->lock);
thread_mutex_destroy(&authenticator->lock);
igloo_thread_mutex_destroy(&authenticator->lock);
if (authenticator->mount)
free(authenticator->mount);
acl_release(authenticator->acl);
@ -252,11 +252,11 @@ static void auth_client_free (auth_client *auth_user)
/* verify that the client is still connected. */
static int is_client_connected (client_t *client) {
/* As long as sock_active() is broken we need to disable this:
/* As long as igloo_sock_active() is broken we need to disable this:
int ret = 1;
if (client)
if (sock_active(client->con->sock) == 0)
if (igloo_sock_active(client->con->sock) == 0)
ret = 0;
return ret;
*/
@ -433,7 +433,7 @@ static void *auth_run_thread (void *arg)
} else {
thread_mutex_unlock(&auth->lock);
}
thread_sleep (150000);
igloo_thread_sleep (150000);
}
ICECAST_LOG_INFO("Authentication thread shutting down");
return NULL;
@ -715,7 +715,7 @@ static inline int auth_get_authenticator__filter_method(auth_t *auth, xmlNodePtr
while (cur) {
char *next = strstr(cur, ",");
httpp_request_type_e idx;
igloo_httpp_request_type_e idx;
if (next) {
*next = 0;
@ -731,7 +731,7 @@ static inline int auth_get_authenticator__filter_method(auth_t *auth, xmlNodePtr
break;
}
idx = httpp_str_to_method(cur);
idx = igloo_httpp_str_to_method(cur);
if (idx == httpp_req_unknown) {
ICECAST_LOG_ERROR("Can not add known method \"%H\" to role's %s", cur, name);
return -1;
@ -838,7 +838,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
method_inited = 1;
while (cur) {
httpp_request_type_e idx;
igloo_httpp_request_type_e idx;
next = strstr(cur, ",");
if (next) {
@ -853,7 +853,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
break;
}
idx = httpp_str_to_method(cur);
idx = igloo_httpp_str_to_method(cur);
if (idx == httpp_req_unknown) {
auth_release(auth);
return NULL;
@ -953,7 +953,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
auth->tailp = &auth->head;
if (!auth->immediate) {
auth->running = 1;
auth->thread = thread_create("auth thread", auth_run_thread, auth, THREAD_ATTACHED);
auth->thread = thread_create("auth thread", auth_run_thread, auth, igloo_THREAD_ATTACHED);
}
}
}
@ -1028,7 +1028,7 @@ void auth_initialise (void)
void auth_shutdown (void)
{
ICECAST_LOG_INFO("Auth shutdown");
thread_mutex_destroy(&_auth_lock);
igloo_thread_mutex_destroy(&_auth_lock);
}
/* authstack functions */
@ -1070,7 +1070,7 @@ void auth_stack_release(auth_stack_t *stack) {
auth_release(stack->auth);
auth_stack_release(stack->next);
thread_mutex_destroy(&stack->lock);
igloo_thread_mutex_destroy(&stack->lock);
free(stack);
}
@ -1186,7 +1186,7 @@ auth_t *auth_stack_getbyid(auth_stack_t *stack, unsigned long id) {
}
acl_t *auth_stack_get_anonymous_acl(auth_stack_t *stack, httpp_request_type_e method) {
acl_t *auth_stack_get_anonymous_acl(auth_stack_t *stack, igloo_httpp_request_type_e method) {
acl_t *ret = NULL;
if (!stack || method < 0 || method > httpp_req_unknown)

View File

@ -22,8 +22,8 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <permafrost/thread.h>
#include <permafrost/httpp.h>
#include <igloo/thread.h>
#include <igloo/httpp.h>
#include "icecasttypes.h"
#include "cfgfile.h"
@ -142,11 +142,11 @@ struct auth_tag
auth_result (*deleteuser)(auth_t *auth, const char *username);
auth_result (*listuser)(auth_t *auth, xmlNodePtr srcnode);
mutex_t lock;
igloo_mutex_t lock;
int running;
size_t refcount;
thread_type *thread;
igloo_thread_type *thread;
/* per-auth queue for clients */
auth_client *head, **tailp;
@ -200,6 +200,6 @@ int auth_stack_push(auth_stack_t **stack, auth_t *auth);
int auth_stack_append(auth_stack_t *stack, auth_stack_t *tail);
auth_t *auth_stack_get(auth_stack_t *stack);
auth_t *auth_stack_getbyid(auth_stack_t *stack, unsigned long id);
acl_t *auth_stack_get_anonymous_acl(auth_stack_t *stack, httpp_request_type_e method);
acl_t *auth_stack_get_anonymous_acl(auth_stack_t *stack, igloo_httpp_request_type_e method);
#endif

View File

@ -26,7 +26,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <permafrost/httpp.h>
#include <igloo/httpp.h>
#include "auth.h"
#include "source.h"
@ -53,8 +53,8 @@ typedef struct {
typedef struct {
char *filename;
rwlock_t file_rwlock;
avl_tree *users;
igloo_rwlock_t file_rwlock;
igloo_avl_tree *users;
time_t mtime;
} htpasswd_auth_state;
@ -63,8 +63,8 @@ static void htpasswd_clear(auth_t *self)
htpasswd_auth_state *state = self->state;
free(state->filename);
if (state->users)
avl_tree_free (state->users, _free_user);
thread_rwlock_destroy(&state->file_rwlock);
igloo_avl_tree_free (state->users, _free_user);
igloo_thread_rwlock_destroy(&state->file_rwlock);
free(state);
}
@ -109,7 +109,7 @@ static int _free_user(void *key)
static void htpasswd_recheckfile(htpasswd_auth_state *htpasswd)
{
FILE *passwdfile;
avl_tree *new_users;
igloo_avl_tree *new_users;
int num = 0;
struct stat file_stat;
char *sep;
@ -123,7 +123,7 @@ static void htpasswd_recheckfile(htpasswd_auth_state *htpasswd)
/* Create a dummy users tree for things to use later */
thread_rwlock_wlock (&htpasswd->file_rwlock);
if(!htpasswd->users)
htpasswd->users = avl_tree_new(compare_users, NULL);
htpasswd->users = igloo_avl_tree_new(compare_users, NULL);
thread_rwlock_unlock (&htpasswd->file_rwlock);
return;
@ -142,7 +142,7 @@ static void htpasswd_recheckfile(htpasswd_auth_state *htpasswd)
}
htpasswd->mtime = file_stat.st_mtime;
new_users = avl_tree_new (compare_users, NULL);
new_users = igloo_avl_tree_new (compare_users, NULL);
while (get_line(passwdfile, line, MAX_LINE_LEN)) {
int len;
@ -163,13 +163,13 @@ static void htpasswd_recheckfile(htpasswd_auth_state *htpasswd)
*sep = 0;
memcpy (entry->name, line, len);
entry->pass = entry->name + (sep-line) + 1;
avl_insert (new_users, entry);
igloo_avl_insert (new_users, entry);
}
fclose (passwdfile);
thread_rwlock_wlock (&htpasswd->file_rwlock);
if (htpasswd->users)
avl_tree_free (htpasswd->users, _free_user);
igloo_avl_tree_free (htpasswd->users, _free_user);
htpasswd->users = new_users;
thread_rwlock_unlock (&htpasswd->file_rwlock);
}
@ -199,7 +199,7 @@ static auth_result htpasswd_auth (auth_client *auth_user)
thread_rwlock_rlock (&htpasswd->file_rwlock);
entry.name = client->username;
if (avl_get_by_key (htpasswd->users, &entry, &result) == 0) {
if (igloo_avl_get_by_key (htpasswd->users, &entry, &result) == 0) {
htpasswd_user *found = result;
char *hashed_pw;
@ -278,7 +278,7 @@ static auth_result htpasswd_adduser (auth_t *auth, const char *username, const c
thread_rwlock_wlock (&state->file_rwlock);
entry.name = (char*)username;
if (avl_get_by_key (state->users, &entry, &result) == 0) {
if (igloo_avl_get_by_key (state->users, &entry, &result) == 0) {
thread_rwlock_unlock (&state->file_rwlock);
return AUTH_USEREXISTS;
}
@ -406,7 +406,7 @@ static auth_result htpasswd_userlist(auth_t *auth, xmlNodePtr srcnode)
{
htpasswd_auth_state *state;
xmlNodePtr newnode;
avl_node *node;
igloo_avl_node *node;
state = auth->state;
@ -423,12 +423,12 @@ static auth_result htpasswd_userlist(auth_t *auth, xmlNodePtr srcnode)
}
thread_rwlock_rlock(&state->file_rwlock);
node = avl_get_first(state->users);
node = igloo_avl_get_first(state->users);
while (node) {
htpasswd_user *user = (htpasswd_user *)node->key;
newnode = xmlNewChild(srcnode, NULL, XMLSTR("user"), NULL);
xmlNewTextChild(newnode, NULL, XMLSTR("username"), XMLSTR(user->name));
node = avl_get_next(node);
node = igloo_avl_get_next(node);
}
thread_rwlock_unlock(&state->file_rwlock);

View File

@ -75,7 +75,7 @@
#include "cfgfile.h"
#include "connection.h"
#include <permafrost/httpp.h>
#include <igloo/httpp.h>
#include "logging.h"
#define CATMODULE "auth_url"
@ -121,7 +121,7 @@ typedef struct {
typedef struct {
char *all_headers;
size_t all_headers_len;
http_parser_t *parser;
igloo_http_parser_t *parser;
} auth_user_url_t;
static inline const char * __str_or_default(const char *str, const char *def)
@ -187,15 +187,15 @@ static void handle_returned_header__complete(auth_client *auth_user)
if (au_url->parser)
return;
au_url->parser = httpp_create_parser();
httpp_initialize(au_url->parser, NULL);
au_url->parser = igloo_httpp_create_parser();
igloo_httpp_initialize(au_url->parser, NULL);
if (!httpp_parse_response(au_url->parser, au_url->all_headers, au_url->all_headers_len, NULL)) {
if (!igloo_httpp_parse_response(au_url->parser, au_url->all_headers, au_url->all_headers_len, NULL)) {
ICECAST_LOG_ERROR("Can not parse auth backend reply.");
return;
}
tmp = httpp_getvar(au_url->parser, HTTPP_VAR_ERROR_CODE);
tmp = igloo_httpp_getvar(au_url->parser, igloo_HTTPP_VAR_ERROR_CODE);
if (tmp[0] == '2') {
ICECAST_LOG_DEBUG("Got final status: %#H", tmp);
} else {
@ -207,14 +207,14 @@ static void handle_returned_header__complete(auth_client *auth_user)
}
if (url->header_auth) {
tmp = httpp_getvar(au_url->parser, url->header_auth);
tmp = igloo_httpp_getvar(au_url->parser, url->header_auth);
if (tmp) {
url->result = auth_str2result(tmp);
}
}
if (url->header_timelimit) {
tmp = httpp_getvar(au_url->parser, url->header_timelimit);
tmp = igloo_httpp_getvar(au_url->parser, url->header_timelimit);
if (tmp) {
long long int ret;
char *endptr;
@ -229,8 +229,8 @@ static void handle_returned_header__complete(auth_client *auth_user)
}
}
action = httpp_getvar(au_url->parser, __str_or_default(url->header_alter_action, DEFAULT_HEADER_NEW_ALTER_ACTION));
argument = httpp_getvar(au_url->parser, __str_or_default(url->header_alter_argument, DEFAULT_HEADER_NEW_ALTER_ARGUMENT));
action = igloo_httpp_getvar(au_url->parser, __str_or_default(url->header_alter_action, DEFAULT_HEADER_NEW_ALTER_ACTION));
argument = igloo_httpp_getvar(au_url->parser, __str_or_default(url->header_alter_argument, DEFAULT_HEADER_NEW_ALTER_ARGUMENT));
if (action && argument) {
if (auth_alter_client(auth_user->client->auth, auth_user, auth_str2alter(action), argument) != 0) {
@ -241,11 +241,11 @@ static void handle_returned_header__complete(auth_client *auth_user)
}
if (url->header_message) {
tmp = httpp_getvar(au_url->parser, url->header_message);
tmp = igloo_httpp_getvar(au_url->parser, url->header_message);
} else {
tmp = httpp_getvar(au_url->parser, DEFAULT_HEADER_NEW_MESSAGE);
tmp = igloo_httpp_getvar(au_url->parser, DEFAULT_HEADER_NEW_MESSAGE);
if (!tmp)
tmp = httpp_getvar(au_url->parser, DEFAULT_HEADER_OLD_MESSAGE);
tmp = igloo_httpp_getvar(au_url->parser, DEFAULT_HEADER_OLD_MESSAGE);
}
if (tmp) {
snprintf(url->errormsg, sizeof(url->errormsg), "%s", tmp);
@ -354,7 +354,7 @@ static auth_result url_remove_client(auth_client *auth_user)
port = config->port;
config_release_config();
agent = httpp_getvar(client->parser, "user-agent");
agent = igloo_httpp_getvar(client->parser, "user-agent");
if (agent) {
user_agent = util_url_escape(agent);
} else {
@ -374,9 +374,9 @@ static auth_result url_remove_client(auth_client *auth_user)
}
/* get the full uri (with query params if available) */
mountreq = httpp_getvar(client->parser, HTTPP_VAR_RAWURI);
mountreq = igloo_httpp_getvar(client->parser, igloo_HTTPP_VAR_RAWURI);
if (mountreq == NULL)
mountreq = httpp_getvar(client->parser, HTTPP_VAR_URI);
mountreq = igloo_httpp_getvar(client->parser, igloo_HTTPP_VAR_URI);
mount = util_url_escape(mountreq);
ipaddr = util_url_escape(client->con->ip);
@ -467,7 +467,7 @@ static auth_result url_add_client(auth_client *auth_user)
port = config->port;
config_release_config();
agent = httpp_getvar(client->parser, "user-agent");
agent = igloo_httpp_getvar(client->parser, "user-agent");
if (agent) {
user_agent = util_url_escape(agent);
} else {
@ -487,9 +487,9 @@ static auth_result url_add_client(auth_client *auth_user)
}
/* get the full uri (with query params if available) */
mountreq = httpp_getvar(client->parser, HTTPP_VAR_RAWURI);
mountreq = igloo_httpp_getvar(client->parser, igloo_HTTPP_VAR_RAWURI);
if (mountreq == NULL)
mountreq = httpp_getvar(client->parser, HTTPP_VAR_URI);
mountreq = igloo_httpp_getvar(client->parser, igloo_HTTPP_VAR_URI);
mount = util_url_escape(mountreq);
ipaddr = util_url_escape(client->con->ip);
@ -526,7 +526,7 @@ static auth_result url_add_client(auth_client *auth_user)
next_header++;
}
header_val = httpp_getvar (client->parser, cur_header);
header_val = igloo_httpp_getvar (client->parser, cur_header);
if (header_val) {
size_t left = sizeof(post) - post_offset;
int ret;

View File

@ -26,7 +26,7 @@
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <permafrost/thread.h>
#include <igloo/thread.h>
#include "cfgfile.h"
#include "global.h"
@ -237,8 +237,8 @@ static void create_locks(void)
static void release_locks(void)
{
thread_mutex_destroy(&_locks.relay_lock);
thread_rwlock_destroy(&_locks.config_lock);
igloo_thread_mutex_destroy(&_locks.relay_lock);
igloo_thread_rwlock_destroy(&_locks.config_lock);
}
void config_initialize(void)

View File

@ -23,8 +23,8 @@
#define MAX_YP_DIRECTORIES 25
#include <libxml/tree.h>
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include "icecasttypes.h"
#include "compat.h"
@ -279,8 +279,8 @@ struct ice_config_tag {
};
typedef struct {
rwlock_t config_lock;
mutex_t relay_lock;
igloo_rwlock_t config_lock;
igloo_mutex_t relay_lock;
} ice_config_locks;
void config_initialize(void);

View File

@ -26,9 +26,9 @@
#include <libxml/tree.h>
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <permafrost/httpp.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include <igloo/httpp.h>
#include "global.h"
#include "refobject.h"
@ -71,7 +71,7 @@ static inline void client_send_500(client_t *client, const char *message);
* client_t is returned just in case a message needs to be returned. Should
* be called with global lock held.
*/
int client_create(client_t **c_ptr, connection_t *con, http_parser_t *parser)
int client_create(client_t **c_ptr, connection_t *con, igloo_http_parser_t *parser)
{
ice_config_t *config;
client_t *client = (client_t *) calloc(1, sizeof(client_t));
@ -133,7 +133,7 @@ void client_complete(client_t *client)
}
if (!have) {
header = httpp_getvar(client->parser, "transfer-encoding");
header = igloo_httpp_getvar(client->parser, "transfer-encoding");
if (header) {
if (strcasecmp(header, "identity") != 0) {
client->request_body_length = -1; /* streaming */
@ -255,7 +255,7 @@ void client_destroy(client_t *client)
if (client->parser)
httpp_destroy(client->parser);
if (client->encoding)
httpp_encoding_release(client->encoding);
igloo_httpp_encoding_release(client->encoding);
global_lock();
global.clients--;
@ -304,7 +304,7 @@ int client_read_bytes(client_t *client, void *buf, unsigned len)
}
if (client->encoding) {
bytes = httpp_encoding_read(client->encoding, buf, len, reader, userdata);
bytes = igloo_httpp_encoding_read(client->encoding, buf, len, reader, userdata);
} else {
bytes = reader(userdata, buf, len);
}
@ -720,7 +720,7 @@ admin_format_t client_get_admin_format_by_content_negotiation(client_t *client)
if (!client || !client->parser)
return CLIENT_DEFAULT_ADMIN_FORMAT;
pref = util_http_select_best(httpp_getvar(client->parser, "accept"), "text/xml", "text/html", "text/plain", (const char*)NULL);
pref = util_http_select_best(igloo_httpp_getvar(client->parser, "accept"), "text/xml", "text/html", "text/plain", (const char*)NULL);
if (strcmp(pref, "text/xml") == 0) {
return ADMIN_FORMAT_RAW;
@ -813,7 +813,7 @@ int client_body_eof(client_t *client)
ret = 1;
} else if (client->encoding) {
ICECAST_LOG_DEBUG("Looking for body EOF with encoding (client=%p)", client);
ret = httpp_encoding_eof(client->encoding, (int(*)(void*))client_eof, client);
ret = igloo_httpp_encoding_eof(client->encoding, (int(*)(void*))client_eof, client);
} else {
ICECAST_LOG_DEBUG("Looking for body EOF without encoding (client=%p)", client);
ret = client_eof(client);
@ -957,7 +957,7 @@ ssize_t client_get_baseurl(client_t *client, listensocket_t *listensocket, char
suffix1 = "";
if (client) {
host = httpp_getvar(client->parser, "host");
host = igloo_httpp_getvar(client->parser, "host");
/* at least a couple of players (fb2k/winamp) are reported to send a
* host header but without the port number. So if we are missing the

View File

@ -19,8 +19,8 @@
#ifndef __CLIENT_H__
#define __CLIENT_H__
#include <permafrost/httpp.h>
#include <permafrost/encoding.h>
#include <igloo/httpp.h>
#include <igloo/encoding.h>
#include "icecasttypes.h"
#include "errors.h"
@ -70,10 +70,10 @@ struct _client_tag {
reuse_t reuse;
/* the client's http headers */
http_parser_t *parser;
igloo_http_parser_t *parser;
/* Transfer Encoding if any */
httpp_encoding_t *encoding;
igloo_httpp_encoding_t *encoding;
/* protocol client uses */
protocol_t protocol;
@ -139,7 +139,7 @@ struct _client_tag {
int (*check_buffer)(source_t *source, client_t *client);
};
int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser);
int client_create (client_t **c_ptr, connection_t *con, igloo_http_parser_t *parser);
void client_complete(client_t *client);
void client_destroy(client_t *client);
void client_send_error_by_id(client_t *client, icecast_error_id_t id);

View File

@ -33,10 +33,10 @@
#include <winsock2.h>
#endif
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <permafrost/sock.h>
#include <permafrost/httpp.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include <igloo/sock.h>
#include <igloo/httpp.h>
#include "compat.h"
#include "connection.h"
@ -90,7 +90,7 @@ typedef struct client_queue_tag {
struct client_queue_tag *next;
} client_queue_t;
static spin_t _connection_lock; // protects _current_id, _con_queue, _con_queue_tail
static igloo_spin_t _connection_lock; // protects _current_id, _con_queue, _con_queue_tail
static volatile connection_id_t _current_id = 0;
static int _initialized = 0;
@ -103,7 +103,7 @@ static tls_ctx_t *tls_ctx;
/* filtering client connection based on IP */
static matchfile_t *banned_ip, *allowed_ip;
rwlock_t _source_shutdown_rwlock;
igloo_rwlock_t _source_shutdown_rwlock;
static int _update_admin_command(client_t *client);
static void _handle_connection(void);
@ -114,7 +114,7 @@ void connection_initialize(void)
if (_initialized)
return;
thread_spin_create (&_connection_lock);
igloo_thread_spin_create (&_connection_lock);
thread_mutex_create(&move_clients_mutex);
thread_rwlock_create(&_source_shutdown_rwlock);
thread_cond_create(&global.shutdown_cond);
@ -137,10 +137,10 @@ void connection_shutdown(void)
matchfile_release(banned_ip);
matchfile_release(allowed_ip);
thread_cond_destroy(&global.shutdown_cond);
thread_rwlock_destroy(&_source_shutdown_rwlock);
thread_spin_destroy (&_connection_lock);
thread_mutex_destroy(&move_clients_mutex);
igloo_thread_cond_destroy(&global.shutdown_cond);
igloo_thread_rwlock_destroy(&_source_shutdown_rwlock);
igloo_thread_spin_destroy (&_connection_lock);
igloo_thread_mutex_destroy(&move_clients_mutex);
_initialized = 0;
}
@ -155,9 +155,9 @@ static connection_id_t _next_connection_id(void)
{
connection_id_t id;
thread_spin_lock(&_connection_lock);
igloo_thread_spin_lock(&_connection_lock);
id = _current_id++;
thread_spin_unlock(&_connection_lock);
igloo_thread_spin_unlock(&_connection_lock);
return id;
}
@ -231,19 +231,19 @@ static void get_tls_certificate(ice_config_t *config)
*/
static int connection_read(connection_t *con, void *buf, size_t len)
{
int bytes = sock_read_bytes(con->sock, buf, len);
int bytes = igloo_sock_read_bytes(con->sock, buf, len);
if (bytes == 0)
con->error = 1;
if (bytes == -1 && !sock_recoverable(sock_error()))
if (bytes == -1 && !igloo_sock_recoverable(igloo_sock_error()))
con->error = 1;
return bytes;
}
static int connection_send(connection_t *con, const void *buf, size_t len)
{
int bytes = sock_write_bytes(con->sock, buf, len);
int bytes = igloo_sock_write_bytes(con->sock, buf, len);
if (bytes < 0) {
if (!sock_recoverable(sock_error()))
if (!igloo_sock_recoverable(igloo_sock_error()))
con->error = 1;
} else {
con->sent_bytes += bytes;
@ -252,7 +252,7 @@ static int connection_send(connection_t *con, const void *buf, size_t len)
return bytes;
}
connection_t *connection_create(sock_t sock, listensocket_t *listensocket_real, listensocket_t* listensocket_effective, char *ip)
connection_t *connection_create(igloo_sock_t sock, listensocket_t *listensocket_real, listensocket_t* listensocket_effective, char *ip)
{
connection_t *con;
@ -399,10 +399,10 @@ int connection_read_put_back(connection_t *con, const void *buf, size_t len)
*/
static void _add_connection(client_queue_t *node)
{
thread_spin_lock(&_connection_lock);
igloo_thread_spin_lock(&_connection_lock);
*_con_queue_tail = node;
_con_queue_tail = (volatile client_queue_t **) &node->next;
thread_spin_unlock(&_connection_lock);
igloo_thread_spin_unlock(&_connection_lock);
}
@ -413,7 +413,7 @@ static client_queue_t *_get_connection(void)
{
client_queue_t *node = NULL;
thread_spin_lock(&_connection_lock);
igloo_thread_spin_lock(&_connection_lock);
if (_con_queue){
node = (client_queue_t *)_con_queue;
@ -423,7 +423,7 @@ static client_queue_t *_get_connection(void)
node->next = NULL;
}
thread_spin_unlock(&_connection_lock);
igloo_thread_spin_unlock(&_connection_lock);
return node;
}
@ -534,10 +534,10 @@ static void _add_body_client(client_queue_t *node)
{
ICECAST_LOG_DEBUG("Putting client %p in body queue.", node->client);
thread_spin_lock(&_connection_lock);
igloo_thread_spin_lock(&_connection_lock);
*_body_queue_tail = node;
_body_queue_tail = (volatile client_queue_t **) &node->next;
thread_spin_unlock(&_connection_lock);
igloo_thread_spin_unlock(&_connection_lock);
}
static client_slurp_result_t process_request_body_queue_one(client_queue_t *node, time_t timeout, size_t body_size_limit)
@ -560,7 +560,7 @@ static client_slurp_result_t process_request_body_queue_one(client_queue_t *node
if (node->bodybuffer) {
res = client_body_slurp(client, node->bodybuffer, &(node->bodybufferlen));
if (res == CLIENT_SLURP_SUCCESS) {
httpp_parse_postdata(client->parser, node->bodybuffer, node->bodybufferlen);
igloo_httpp_parse_postdata(client->parser, node->bodybuffer, node->bodybufferlen);
free(node->bodybuffer);
node->bodybuffer = NULL;
}
@ -665,14 +665,14 @@ void connection_queue(connection_t *con)
global_unlock();
client_send_error_by_id(client, ICECAST_ERROR_GEN_CLIENT_LIMIT);
/* don't be too eager as this is an imposed hard limit */
thread_sleep(400000);
igloo_thread_sleep(400000);
return;
}
/* setup client for reading incoming http */
client->refbuf->data[PER_CLIENT_REFBUF_SIZE-1] = '\000';
if (sock_set_blocking(client->con->sock, 0) || sock_set_nodelay(client->con->sock)) {
if (igloo_sock_set_blocking(client->con->sock, 0) || igloo_sock_set_nodelay(client->con->sock)) {
global_unlock();
ICECAST_LOG_WARN("Failed to set tcp options on client connection, dropping");
client_destroy(client);
@ -740,7 +740,7 @@ int connection_complete_source(source_t *source, int response)
format_type_t format_type;
/* setup format handler */
contenttype = httpp_getvar (source->parser, "content-type");
contenttype = igloo_httpp_getvar (source->parser, "content-type");
if (contenttype != NULL) {
format_type = format_get_type(contenttype);
@ -839,9 +839,9 @@ static inline void source_startup(client_t *client)
int status_to_send = 200;
ssize_t ret;
transfer_encoding = httpp_getvar(source->parser, "transfer-encoding");
if (transfer_encoding && strcasecmp(transfer_encoding, HTTPP_ENCODING_IDENTITY) != 0) {
client->encoding = httpp_encoding_new(transfer_encoding);
transfer_encoding = igloo_httpp_getvar(source->parser, "transfer-encoding");
if (transfer_encoding && strcasecmp(transfer_encoding, igloo_HTTPP_ENCODING_IDENTITY) != 0) {
client->encoding = igloo_httpp_encoding_new(transfer_encoding);
if (!client->encoding) {
client_send_error_by_id(client, ICECAST_ERROR_CON_UNIMPLEMENTED);
return;
@ -849,7 +849,7 @@ static inline void source_startup(client_t *client)
}
/* For PUT support we check for 100-continue and send back a 100 to stay in spec */
expectcontinue = httpp_getvar (source->parser, "expect");
expectcontinue = igloo_httpp_getvar (source->parser, "expect");
if (expectcontinue != NULL) {
#ifdef HAVE_STRCASESTR
@ -941,9 +941,9 @@ static int __add_listener_to_source(source_t *source, client_t *client)
memset(client->refbuf->data, 0, PER_CLIENT_REFBUF_SIZE);
/* lets add the client to the active list */
avl_tree_wlock(source->pending_tree);
avl_insert(source->pending_tree, client);
avl_tree_unlock(source->pending_tree);
igloo_avl_tree_wlock(source->pending_tree);
igloo_avl_insert(source->pending_tree, client);
igloo_avl_tree_unlock(source->pending_tree);
if (source->running == 0 && source->on_demand) {
/* enable on-demand relay to start, wake up the slave thread */
@ -957,10 +957,10 @@ static int __add_listener_to_source(source_t *source, client_t *client)
/* count the number of clients on a mount with same username and same role as the given one */
static inline ssize_t __count_user_role_on_mount (source_t *source, client_t *client) {
ssize_t ret = 0;
avl_node *node;
igloo_avl_node *node;
avl_tree_rlock(source->client_tree);
node = avl_get_first(source->client_tree);
igloo_avl_tree_rlock(source->client_tree);
node = igloo_avl_get_first(source->client_tree);
while (node) {
client_t *existing_client = (client_t *)node->key;
if (existing_client->username && client->username &&
@ -969,12 +969,12 @@ static inline ssize_t __count_user_role_on_mount (source_t *source, client_t *cl
strcmp(existing_client->role, client->role) == 0) {
ret++;
}
node = avl_get_next(node);
node = igloo_avl_get_next(node);
}
avl_tree_unlock(source->client_tree);
igloo_avl_tree_unlock(source->client_tree);
avl_tree_rlock(source->pending_tree);
node = avl_get_first(source->pending_tree);
igloo_avl_tree_rlock(source->pending_tree);
node = igloo_avl_get_first(source->pending_tree);
while (node) {
client_t *existing_client = (client_t *)node->key;
if (existing_client->username && client->username &&
@ -983,9 +983,9 @@ static inline ssize_t __count_user_role_on_mount (source_t *source, client_t *cl
strcmp(existing_client->role, client->role) == 0){
ret++;
}
node = avl_get_next(node);
node = igloo_avl_get_next(node);
}
avl_tree_unlock(source->pending_tree);
igloo_avl_tree_unlock(source->pending_tree);
return ret;
}
@ -1025,7 +1025,7 @@ static void _handle_get_request(client_t *client) {
return;
}
avl_tree_rlock(global.source_tree);
igloo_avl_tree_rlock(global.source_tree);
/* let's see if this is a source or just a random fserve file */
source = source_find_mount(client->uri);
if (source) {
@ -1058,10 +1058,10 @@ static void _handle_get_request(client_t *client) {
if (!in_error && __add_listener_to_source(source, client) == -1) {
client_send_error_by_id(client, ICECAST_ERROR_CON_rejecting_client_for_whatever_reason);
}
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
} else {
/* file */
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
fserve_client_create(client);
}
}
@ -1085,7 +1085,7 @@ static void _handle_shoutcast_compatible(client_queue_t *node)
{
char *http_compliant;
int http_compliant_len = 0;
http_parser_t *parser;
igloo_http_parser_t *parser;
const char *shoutcast_mount;
client_t *client = node->client;
ice_config_t *config;
@ -1144,9 +1144,9 @@ static void _handle_shoutcast_compatible(client_queue_t *node)
"SOURCE %s HTTP/1.0\r\n%s", shoutcast_mount, client->refbuf->data);
config_release_config();
parser = httpp_create_parser();
httpp_initialize(parser, NULL);
if (httpp_parse(parser, http_compliant, strlen(http_compliant))) {
parser = igloo_httpp_create_parser();
igloo_httpp_initialize(parser, NULL);
if (igloo_httpp_parse(parser, http_compliant, strlen(http_compliant))) {
client->refbuf->len = 0;
client->parser = parser;
client->protocol = ICECAST_PROTOCOL_SHOUTCAST;
@ -1167,7 +1167,7 @@ static void _handle_shoutcast_compatible(client_queue_t *node)
static int _handle_resources(client_t *client, char **uri)
{
const char *http_host = httpp_getvar(client->parser, "host");
const char *http_host = igloo_httpp_getvar(client->parser, "host");
char *serverhost = NULL;
int serverport = 0;
char *vhost = NULL;
@ -1399,7 +1399,7 @@ static void _handle_authentication_mount_generic(client_t *client, void *userdat
if (!mountproxy) {
int command_type = admin_get_command_type(client->admin_command);
if (command_type == ADMINTYPE_MOUNT || command_type == ADMINTYPE_HYBRID) {
const char *mount = httpp_get_param(client->parser, "mount");
const char *mount = igloo_httpp_get_param(client->parser, "mount");
if (mount)
mountproxy = __find_non_admin_mount(config, mount, type);
}
@ -1478,7 +1478,7 @@ static void __prepare_shoutcast_admin_cgi_request(client_t *client)
{
ice_config_t *config;
const char *sc_mount;
const char *pass = httpp_get_query_param(client->parser, "pass");
const char *pass = igloo_httpp_get_query_param(client->parser, "pass");
const listener_t *listener;
if (pass == NULL) {
@ -1500,10 +1500,10 @@ static void __prepare_shoutcast_admin_cgi_request(client_t *client)
if (listener && listener->shoutcast_mount)
sc_mount = listener->shoutcast_mount;
httpp_set_query_param(client->parser, "mount", sc_mount);
igloo_httpp_set_query_param(client->parser, "mount", sc_mount);
listensocket_release_listener(client->con->listensocket_effective);
httpp_setvar(client->parser, HTTPP_VAR_PROTOCOL, "ICY");
igloo_httpp_setvar(client->parser, igloo_HTTPP_VAR_PROTOCOL, "ICY");
client->password = strdup(pass);
config_release_config();
global_unlock();
@ -1557,7 +1557,7 @@ static int _update_admin_command(client_t *client)
*/
static void _handle_connection(void)
{
http_parser_t *parser;
igloo_http_parser_t *parser;
const char *rawuri;
client_queue_t *node;
@ -1579,11 +1579,11 @@ static void _handle_connection(void)
already_parsed = 1;
parser = client->parser;
} else {
parser = httpp_create_parser();
httpp_initialize(parser, NULL);
parser = igloo_httpp_create_parser();
igloo_httpp_initialize(parser, NULL);
client->parser = parser;
}
if (already_parsed || httpp_parse (parser, client->refbuf->data, node->offset)) {
if (already_parsed || igloo_httpp_parse (parser, client->refbuf->data, node->offset)) {
char *uri;
const char *upgrade, *connection;
@ -1615,25 +1615,25 @@ static void _handle_connection(void)
}
}
rawuri = httpp_getvar(parser, HTTPP_VAR_URI);
rawuri = igloo_httpp_getvar(parser, igloo_HTTPP_VAR_URI);
/* assign a port-based shoutcast mountpoint if required */
if (node->shoutcast_mount && strcmp (rawuri, "/admin.cgi") == 0)
httpp_set_query_param (client->parser, "mount", node->shoutcast_mount);
igloo_httpp_set_query_param (client->parser, "mount", node->shoutcast_mount);
free (node->bodybuffer);
free (node->shoutcast_mount);
free (node);
if (strcmp("ICE", httpp_getvar(parser, HTTPP_VAR_PROTOCOL)) &&
strcmp("HTTP", httpp_getvar(parser, HTTPP_VAR_PROTOCOL))) {
if (strcmp("ICE", igloo_httpp_getvar(parser, igloo_HTTPP_VAR_PROTOCOL)) &&
strcmp("HTTP", igloo_httpp_getvar(parser, igloo_HTTPP_VAR_PROTOCOL))) {
ICECAST_LOG_ERROR("Bad HTTP protocol detected");
client_destroy (client);
continue;
}
upgrade = httpp_getvar(parser, "upgrade");
connection = httpp_getvar(parser, "connection");
upgrade = igloo_httpp_getvar(parser, "upgrade");
connection = igloo_httpp_getvar(parser, "connection");
if (upgrade && connection && strcasecmp(connection, "upgrade") == 0) {
if (client->con->tlsmode == ICECAST_TLSMODE_DISABLED || client->con->tls || strstr(upgrade, "TLS/1.0") == NULL) {
client_send_error_by_id(client, ICECAST_ERROR_CON_UPGRADE_ERROR);
@ -1660,7 +1660,7 @@ static void _handle_connection(void)
continue;
}
client->mode = config_str_to_omode(httpp_get_param(client->parser, "omode"));
client->mode = config_str_to_omode(igloo_httpp_get_param(client->parser, "omode"));
if (_handle_resources(client, &uri) != 0) {
client_destroy (client);
@ -1740,7 +1740,7 @@ void connection_close(connection_t *con)
tls_unref(con->tls);
if (con->sock != -1) /* TODO: do not use magic */
sock_close(con->sock);
igloo_sock_close(con->sock);
if (con->ip)
free(con->ip);
if (con->readbuffer)

View File

@ -22,8 +22,8 @@
#include "icecasttypes.h"
#include "compat.h"
#include <permafrost/thread.h>
#include <permafrost/sock.h>
#include <igloo/thread.h>
#include <igloo/sock.h>
typedef unsigned long connection_id_t;
@ -41,7 +41,7 @@ struct connection_tag {
uint64_t sent_bytes;
/* Physical socket the client is connected on */
sock_t sock;
igloo_sock_t sock;
/* real and effective listen socket the connect used to connect. */
listensocket_t *listensocket_real;
listensocket_t *listensocket_effective;
@ -73,7 +73,7 @@ void connection_reread_config(ice_config_t *config);
void connection_accept_loop(void);
void connection_setup_sockets(ice_config_t *config);
void connection_close(connection_t *con);
connection_t *connection_create(sock_t sock, listensocket_t *listensocket_real, listensocket_t* listensocket_effective, char *ip);
connection_t *connection_create(igloo_sock_t sock, listensocket_t *listensocket_real, listensocket_t* listensocket_effective, char *ip);
int connection_complete_source(source_t *source, int response);
void connection_queue(connection_t *con);
void connection_queue_client(client_t *client);
@ -83,6 +83,6 @@ ssize_t connection_send_bytes(connection_t *con, const void *buf, size_t len);
ssize_t connection_read_bytes(connection_t *con, void *buf, size_t len);
int connection_read_put_back(connection_t *con, const void *buf, size_t len);
extern rwlock_t _source_shutdown_rwlock;
extern igloo_rwlock_t _source_shutdown_rwlock;
#endif /* __CONNECTION_H__ */

View File

@ -27,10 +27,10 @@
#define CATMODULE "event"
static mutex_t event_lock;
static igloo_mutex_t event_lock;
static event_t *event_queue = NULL;
static int event_running = 0;
static thread_type *event_thread = NULL;
static igloo_thread_type *event_thread = NULL;
/* work with event_t* */
static void event_addref(event_t *event) {
@ -185,7 +185,7 @@ static void *event_run_thread (void *arg) {
/* sleep if nothing todo and then try again */
if (!event) {
thread_sleep(150000);
igloo_thread_sleep(150000);
continue;
}
@ -208,7 +208,7 @@ void event_initialise(void) {
thread_mutex_unlock(&event_lock);
/* start thread */
event_thread = thread_create("events thread", event_run_thread, NULL, THREAD_ATTACHED);
event_thread = thread_create("events thread", event_run_thread, NULL, igloo_THREAD_ATTACHED);
}
void event_shutdown(void) {
@ -223,7 +223,7 @@ void event_shutdown(void) {
thread_mutex_unlock(&event_lock);
/* join thread as soon as it stopped */
thread_join(event_thread);
igloo_thread_join(event_thread);
/* shutdown everything */
thread_mutex_lock(&event_lock);
@ -235,7 +235,7 @@ void event_shutdown(void) {
event_release(event_queue_to_free);
/* destry mutex */
thread_mutex_destroy(&event_lock);
igloo_thread_mutex_destroy(&event_lock);
}
@ -313,7 +313,7 @@ void event_registration_release(event_registration_t *er) {
er->free(er->state);
thread_mutex_unlock(&er->lock);
thread_mutex_destroy(&er->lock);
igloo_thread_mutex_destroy(&er->lock);
free(er);
}
@ -406,7 +406,7 @@ void event_emit_clientevent(const char *trigger, client_t *client, const char *u
event->client_role = strdup(client->role);
if (client->username)
event->client_username = strdup(client->username);
tmp = httpp_getvar(client->parser, "user-agent");
tmp = igloo_httpp_getvar(client->parser, "user-agent");
if (tmp)
event->client_useragent = strdup(tmp);
}

View File

@ -13,7 +13,7 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <permafrost/thread.h>
#include <igloo/thread.h>
#include "icecasttypes.h"
@ -55,7 +55,7 @@ struct event_tag {
time_t connection_time; /* from client->con->con_time */
char *client_role; /* from client->role */
char *client_username; /* from client->username */
char *client_useragent; /* from httpp_getvar(client->parser, "user-agent") */
char *client_useragent; /* from igloo_httpp_getvar(client->parser, "user-agent") */
admin_command_id_t client_admin_command; /* from client->admin_command */
};
@ -66,7 +66,7 @@ struct event_registration_tag {
event_registration_t *next;
/* protection */
mutex_t lock;
igloo_mutex_t lock;
/* type of event */
char *type;

View File

@ -155,14 +155,14 @@ static inline void __setup_environ(ice_config_t *config, event_exec_t *self, eve
__update_environ("MOUNT_GENRE", mountinfo->stream_genre);
}
avl_tree_rlock(global.source_tree);
igloo_avl_tree_rlock(global.source_tree);
source = source_find_mount(event->uri);
if (source) {
__update_environ("SOURCE_MOUNTPOINT", source->mount);
__update_environ("SOURCE_PUBLIC", source->yp_public ? "true" : "false");
__update_environ("SROUCE_HIDDEN", source->hidden ? "true" : "false");
}
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
}
static inline void __setup_file_descriptors(ice_config_t *config) {

View File

@ -17,7 +17,7 @@
#include <stdlib.h>
#include <string.h>
#include <permafrost/thread.h>
#include <igloo/thread.h>
#include "fastevent.h"
@ -42,7 +42,7 @@ struct eventrow {
};
static struct eventrow fastevent_registrations[FASTEVENT_TYPE__END];
static rwlock_t fastevent_lock;
static igloo_rwlock_t fastevent_lock;
static inline struct eventrow * __get_row(fastevent_type_t type)
{
@ -138,7 +138,7 @@ int fastevent_shutdown(void)
fastevent_registrations[i].registrations = NULL;
}
thread_rwlock_unlock(&fastevent_lock);
thread_rwlock_destroy(&fastevent_lock);
igloo_thread_rwlock_destroy(&fastevent_lock);
return 0;
}

View File

@ -288,7 +288,7 @@ int format_advance_queue(source_t *source, client_t *client)
* calling functions will use a already freed client struct and
* cause a segfault!
*/
static inline ssize_t __print_var(char *str, size_t remaining, const char *format, const char *first, const http_var_t *var)
static inline ssize_t __print_var(char *str, size_t remaining, const char *format, const char *first, const igloo_http_var_t *var)
{
size_t i;
ssize_t done = 0;
@ -305,7 +305,7 @@ static inline ssize_t __print_var(char *str, size_t remaining, const char *forma
return done;
}
static inline const char *__find_bitrate(const http_var_t *var)
static inline const char *__find_bitrate(const igloo_http_var_t *var)
{
size_t i;
const char *ret;
@ -325,7 +325,7 @@ static int format_prepare_headers (source_t *source, client_t *client)
char *ptr;
int bytes;
int bitrate_filtered = 0;
avl_node *node;
igloo_avl_node *node;
remaining = client->refbuf->len;
ptr = client->refbuf->data;
@ -364,12 +364,12 @@ static int format_prepare_headers (source_t *source, client_t *client)
ptr += bytes;
/* iterate through source http headers and send to client */
avl_tree_rlock(source->parser->vars);
node = avl_get_first(source->parser->vars);
igloo_avl_tree_rlock(source->parser->vars);
node = igloo_avl_get_first(source->parser->vars);
while (node)
{
int next = 1;
http_var_t *var = (http_var_t *) node->key;
igloo_http_var_t *var = (igloo_http_var_t *) node->key;
bytes = 0;
if (!strcasecmp(var->name, "ice-audio-info"))
{
@ -437,9 +437,9 @@ static int format_prepare_headers (source_t *source, client_t *client)
remaining -= bytes;
ptr += bytes;
if (next)
node = avl_get_next(node);
node = igloo_avl_get_next(node);
}
avl_tree_unlock(source->parser->vars);
igloo_avl_tree_unlock(source->parser->vars);
bytes = snprintf(ptr, remaining, "\r\n");
if (bytes <= 0 || (size_t)bytes >= remaining) {

View File

@ -26,7 +26,7 @@
#include "refbuf.h"
#include "cfgfile.h"
#include <permafrost/httpp.h>
#include <igloo/httpp.h>
typedef enum _format_type_tag
{

View File

@ -209,7 +209,7 @@ int format_ebml_get_plugin(source_t *source)
plugin->set_tag = NULL;
plugin->apply_settings = NULL;
plugin->contenttype = httpp_getvar(source->parser, "content-type");
plugin->contenttype = igloo_httpp_getvar(source->parser, "content-type");
plugin->_state = ebml_source_state;
vorbis_comment_init(&plugin->vc);

View File

@ -37,7 +37,7 @@
#include "stats.h"
#include "format.h"
#include <permafrost/httpp.h>
#include <igloo/httpp.h>
#include "logging.h"
@ -88,7 +88,7 @@ int format_mp3_get_plugin(source_t *source)
plugin->set_tag = mp3_set_tag;
plugin->apply_settings = format_mp3_apply_settings;
plugin->contenttype = httpp_getvar(source->parser, "content-type");
plugin->contenttype = igloo_httpp_getvar(source->parser, "content-type");
if (plugin->contenttype == NULL) {
/* We default to MP3 audio for old clients without content types */
plugin->contenttype = "audio/mpeg";
@ -103,7 +103,7 @@ int format_mp3_get_plugin(source_t *source)
state->metadata = meta;
state->interval = -1;
metadata = httpp_getvar (source->parser, "icy-metaint");
metadata = igloo_httpp_getvar (source->parser, "icy-metaint");
if (metadata)
{
state->inline_metadata_interval = atoi (metadata);
@ -207,7 +207,7 @@ static void format_mp3_apply_settings (client_t *client, format_plugin_t *format
}
if (source_mp3->interval < 0)
{
const char *metadata = httpp_getvar (client->parser, "icy-metaint");
const char *metadata = igloo_httpp_getvar (client->parser, "icy-metaint");
source_mp3->interval = ICY_METADATA_INTERVAL;
if (metadata)
{
@ -449,7 +449,7 @@ static void format_mp3_free_plugin(format_plugin_t *self)
/* free the plugin instance */
mp3_state *state = self->_state;
thread_mutex_destroy(&state->url_lock);
igloo_thread_mutex_destroy(&state->url_lock);
free(self->charset);
refbuf_release(state->metadata);
refbuf_release(state->read_data);
@ -672,8 +672,8 @@ static int format_mp3_create_client_data(source_t *source, client_t *client)
/* hack for flash player, it wants a length. It has also been reported that the useragent
* appears as MSIE if run in internet explorer */
useragent = httpp_getvar (client->parser, "user-agent");
if (httpp_getvar(client->parser, "x-flash-version") ||
useragent = igloo_httpp_getvar (client->parser, "user-agent");
if (igloo_httpp_getvar(client->parser, "x-flash-version") ||
(useragent && strstr(useragent, "MSIE")))
{
bytes = snprintf (ptr, remaining, "Content-Length: 221183499\r\n");
@ -683,7 +683,7 @@ static int format_mp3_create_client_data(source_t *source, client_t *client)
client->format_data = client_mp3;
client->free_client_data = free_mp3_client_data;
metadata = httpp_getvar(client->parser, "icy-metadata");
metadata = igloo_httpp_getvar(client->parser, "icy-metadata");
if (metadata && atoi(metadata))
{
if (source_mp3->interval >= 0)

View File

@ -34,7 +34,7 @@ typedef struct {
refbuf_t *metadata;
refbuf_t *read_data;
int read_count;
mutex_t url_lock;
igloo_mutex_t url_lock;
unsigned build_metadata_len;
unsigned build_metadata_offset;

View File

@ -173,9 +173,9 @@ int format_ogg_get_plugin(source_t *source)
plugin->create_client_data = create_ogg_client_data;
plugin->free_plugin = format_ogg_free_plugin;
plugin->set_tag = NULL;
if (strcmp (httpp_getvar (source->parser, "content-type"), "application/x-ogg") == 0)
httpp_setvar (source->parser, "content-type", "application/ogg");
plugin->contenttype = httpp_getvar (source->parser, "content-type");
if (strcmp (igloo_httpp_getvar (source->parser, "content-type"), "application/x-ogg") == 0)
igloo_httpp_setvar (source->parser, "content-type", "application/ogg");
plugin->contenttype = igloo_httpp_getvar (source->parser, "content-type");
ogg_sync_init (&state->oy);
vorbis_comment_init(&plugin->vc);

View File

@ -42,10 +42,10 @@
#endif
#endif
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <permafrost/httpp.h>
#include <permafrost/sock.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include <igloo/httpp.h>
#include <igloo/sock.h>
#include "fserve.h"
#include "compat.h"
@ -71,8 +71,8 @@ static volatile int __inited = 0;
static fserve_t *active_list = NULL;
static fserve_t *pending_list = NULL;
static spin_t pending_lock;
static avl_tree *mimetypes = NULL;
static igloo_spin_t pending_lock;
static igloo_avl_tree *mimetypes = NULL;
static volatile int run_fserv = 0;
static unsigned int fserve_clients;
@ -82,7 +82,7 @@ static int client_tree_changed = 0;
static struct pollfd *ufds = NULL;
#else
static fd_set fds;
static sock_t fd_max = SOCK_ERROR;
static igloo_sock_t fd_max = igloo_SOCK_ERROR;
#endif
typedef struct {
@ -101,7 +101,7 @@ void fserve_initialize(void)
mimetypes = NULL;
active_list = NULL;
pending_list = NULL;
thread_spin_create (&pending_lock);
igloo_thread_spin_create (&pending_lock);
fserve_recheck_mime_types (config);
config_release_config();
@ -117,7 +117,7 @@ void fserve_shutdown(void)
if (!__inited)
return;
thread_spin_lock (&pending_lock);
igloo_thread_spin_lock (&pending_lock);
run_fserv = 0;
while (pending_list)
{
@ -134,10 +134,10 @@ void fserve_shutdown(void)
}
if (mimetypes)
avl_tree_free (mimetypes, _delete_mapping);
igloo_avl_tree_free (mimetypes, _delete_mapping);
thread_spin_unlock (&pending_lock);
thread_spin_destroy (&pending_lock);
igloo_thread_spin_unlock (&pending_lock);
igloo_thread_spin_destroy (&pending_lock);
ICECAST_LOG_INFO("file serving stopped");
}
@ -167,9 +167,9 @@ int fserve_client_waiting (void)
}
if (!ufds) {
thread_spin_lock (&pending_lock);
igloo_thread_spin_lock (&pending_lock);
run_fserv = 0;
thread_spin_unlock (&pending_lock);
igloo_thread_spin_unlock (&pending_lock);
return -1;
} else if (poll(ufds, fserve_clients, 200) > 0) {
/* mark any clients that are ready */
@ -195,21 +195,21 @@ int fserve_client_waiting(void)
if (client_tree_changed) {
client_tree_changed = 0;
FD_ZERO(&fds);
fd_max = SOCK_ERROR;
fd_max = igloo_SOCK_ERROR;
fclient = active_list;
while (fclient) {
FD_SET(fclient->client->con->sock, &fds);
if (fclient->client->con->sock > fd_max || fd_max == SOCK_ERROR)
if (fclient->client->con->sock > fd_max || fd_max == igloo_SOCK_ERROR)
fd_max = fclient->client->con->sock;
fclient = fclient->next;
}
}
/* hack for windows, select needs at least 1 descriptor */
if (fd_max == SOCK_ERROR)
if (fd_max == igloo_SOCK_ERROR)
{
thread_spin_lock (&pending_lock);
igloo_thread_spin_lock (&pending_lock);
run_fserv = 0;
thread_spin_unlock (&pending_lock);
igloo_thread_spin_unlock (&pending_lock);
return -1;
}
else
@ -247,7 +247,7 @@ static int wait_for_fds(void)
/* add any new clients here */
if (pending_list)
{
thread_spin_lock (&pending_lock);
igloo_thread_spin_lock (&pending_lock);
fclient = (fserve_t*)pending_list;
while (fclient)
@ -260,7 +260,7 @@ static int wait_for_fds(void)
fserve_clients++;
}
pending_list = NULL;
thread_spin_unlock(&pending_lock);
igloo_thread_spin_unlock(&pending_lock);
}
/* drop out of here if someone is ready */
ret = fserve_client_waiting();
@ -352,8 +352,8 @@ char *fserve_content_type(const char *path)
void *result;
char *type;
thread_spin_lock (&pending_lock);
if (mimetypes && !avl_get_by_key (mimetypes, &exttype, &result))
igloo_thread_spin_lock (&pending_lock);
if (mimetypes && !igloo_avl_get_by_key (mimetypes, &exttype, &result))
{
mime_type *mime = result;
type = strdup (mime->type);
@ -381,7 +381,7 @@ char *fserve_content_type(const char *path)
else
type = strdup ("application/octet-stream");
}
thread_spin_unlock (&pending_lock);
igloo_thread_spin_unlock (&pending_lock);
return type;
}
@ -519,7 +519,7 @@ int fserve_client_create (client_t *httpclient)
free (fullpath);
content_length = file_buf.st_size;
range = httpp_getvar (httpclient->parser, "range");
range = igloo_httpp_getvar (httpclient->parser, "range");
/* full http range handling is currently not done but we deal with the common case */
if (range != NULL) {
@ -622,16 +622,16 @@ fail:
*/
static void fserve_add_pending (fserve_t *fclient)
{
thread_spin_lock (&pending_lock);
igloo_thread_spin_lock (&pending_lock);
fclient->next = (fserve_t *)pending_list;
pending_list = fclient;
if (run_fserv == 0)
{
run_fserv = 1;
ICECAST_LOG_DEBUG("fserve handler waking up");
thread_create("File Serving Thread", fserv_thread_function, NULL, THREAD_DETACHED);
thread_create("File Serving Thread", fserv_thread_function, NULL, igloo_THREAD_DETACHED);
}
thread_spin_unlock (&pending_lock);
igloo_thread_spin_unlock (&pending_lock);
}
@ -703,7 +703,7 @@ void fserve_recheck_mime_types(ice_config_t *config)
char line[4096];
char *type, *ext, *cur;
mime_type *mapping;
avl_tree *new_mimetypes;
igloo_avl_tree *new_mimetypes;
if (config->mimetypes_fn == NULL)
return;
@ -714,7 +714,7 @@ void fserve_recheck_mime_types(ice_config_t *config)
return;
}
new_mimetypes = avl_tree_new(_compare_mappings, NULL);
new_mimetypes = igloo_avl_tree_new(_compare_mappings, NULL);
while(fgets(line, 4096, mimefile))
{
@ -751,18 +751,18 @@ void fserve_recheck_mime_types(ice_config_t *config)
mapping = malloc(sizeof(mime_type));
mapping->ext = strdup(ext);
mapping->type = strdup(type);
if (!avl_get_by_key (new_mimetypes, mapping, &tmp))
avl_delete (new_mimetypes, mapping, _delete_mapping);
avl_insert (new_mimetypes, mapping);
if (!igloo_avl_get_by_key (new_mimetypes, mapping, &tmp))
igloo_avl_delete (new_mimetypes, mapping, _delete_mapping);
igloo_avl_insert (new_mimetypes, mapping);
}
}
}
fclose(mimefile);
thread_spin_lock (&pending_lock);
igloo_thread_spin_lock (&pending_lock);
if (mimetypes)
avl_tree_free (mimetypes, _delete_mapping);
igloo_avl_tree_free (mimetypes, _delete_mapping);
mimetypes = new_mimetypes;
thread_spin_unlock (&pending_lock);
igloo_thread_spin_unlock (&pending_lock);
}

View File

@ -18,8 +18,8 @@
#include <string.h>
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include "global.h"
#include "refobject.h"
@ -28,7 +28,7 @@
ice_global_t global;
static mutex_t _global_mutex;
static igloo_mutex_t _global_mutex;
void global_initialize(void)
{
@ -38,16 +38,16 @@ void global_initialize(void)
global.running = 0;
global.clients = 0;
global.sources = 0;
global.source_tree = avl_tree_new(source_compare_sources, NULL);
global.source_tree = igloo_avl_tree_new(source_compare_sources, NULL);
global.modulecontainer = refobject_new(module_container_t);
thread_mutex_create(&_global_mutex);
}
void global_shutdown(void)
{
thread_mutex_destroy(&_global_mutex);
igloo_thread_mutex_destroy(&_global_mutex);
refobject_unref(global.modulecontainer);
avl_tree_free(global.source_tree, NULL);
igloo_avl_tree_free(global.source_tree, NULL);
}
void global_lock(void)

View File

@ -21,8 +21,8 @@
#define ICECAST_VERSION_STRING "Icecast " PACKAGE_VERSION
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include "icecasttypes.h"
typedef struct ice_global_tag
@ -35,7 +35,7 @@ typedef struct ice_global_tag
int clients;
int schedule_config_reread;
avl_tree *source_tree;
igloo_avl_tree *source_tree;
/* for locally defined relays */
relay_t *relays;
/* relays retrieved from master */
@ -43,7 +43,7 @@ typedef struct ice_global_tag
module_container_t *modulecontainer;
cond_t shutdown_cond;
igloo_cond_t shutdown_cond;
} ice_global_t;
extern ice_global_t global;

View File

@ -22,8 +22,8 @@
#include <string.h>
#include <permafrost/sock.h>
#include <permafrost/thread.h>
#include <igloo/sock.h>
#include <igloo/thread.h>
#include "listensocket.h"
#include "global.h"
@ -36,7 +36,7 @@
struct listensocket_container_tag {
refobject_base_t __base;
mutex_t lock;
igloo_mutex_t lock;
listensocket_t **sock;
int *sockref;
size_t sock_len;
@ -46,11 +46,11 @@ struct listensocket_container_tag {
struct listensocket_tag {
refobject_base_t __base;
size_t sockrefc;
mutex_t lock;
rwlock_t listener_rwlock;
igloo_mutex_t lock;
igloo_rwlock_t listener_rwlock;
listener_t *listener;
listener_t *listener_update;
sock_t sock;
igloo_sock_t sock;
};
static listensocket_t * listensocket_container_get_by_id(listensocket_container_t *self, const char *id);
@ -73,7 +73,7 @@ static inline const char * __string_default(const char *str, const char *def)
return str != NULL ? str : def;
}
static inline int __socket_listen(sock_t serversock, const listener_t *listener)
static inline int __socket_listen(igloo_sock_t serversock, const listener_t *listener)
{
int listen_backlog = listener->listen_backlog;
@ -84,7 +84,7 @@ static inline int __socket_listen(sock_t serversock, const listener_t *listener)
ICECAST_LOG_WARN("Listen backlog for listen socket on %s port %i is set insanely high. Limiting to sane range.", __string_default(listener->bind_address, "<ANY>"), listener->port);
}
return sock_listen(serversock, listen_backlog);
return igloo_sock_listen(serversock, listen_backlog);
}
static inline int __listener_cmp(const listener_t *a, const listener_t *b)
@ -147,7 +147,7 @@ static void __listensocket_container_free(refobject_t self, void **userdata)
thread_mutex_lock(&container->lock);
__listensocket_container_clear_sockets(container);
thread_mutex_unlock(&container->lock);
thread_mutex_destroy(&container->lock);
igloo_thread_mutex_destroy(&container->lock);
}
int __listensocket_container_new(refobject_t self, const refobject_type_t *type, va_list ap)
@ -525,9 +525,9 @@ static void __listensocket_free(refobject_t self, void **userdata)
thread_rwlock_wlock(&listensocket->listener_rwlock);
while ((listensocket->listener = config_clear_listener(listensocket->listener)));
thread_rwlock_unlock(&listensocket->listener_rwlock);
thread_rwlock_destroy(&listensocket->listener_rwlock);
igloo_thread_rwlock_destroy(&listensocket->listener_rwlock);
thread_mutex_unlock(&listensocket->lock);
thread_mutex_destroy(&listensocket->lock);
igloo_thread_mutex_destroy(&listensocket->lock);
}
REFOBJECT_DEFINE_TYPE(listensocket_t,
@ -544,7 +544,7 @@ static listensocket_t * listensocket_new(const listener_t *listener) {
if (!self)
return NULL;
self->sock = SOCK_ERROR;
self->sock = igloo_SOCK_ERROR;
thread_mutex_create(&self->lock);
thread_rwlock_create(&self->listener_rwlock);
@ -597,11 +597,11 @@ static int listensocket_apply_config__unlocked(listensocket_t *self
listener = self->listener;
}
if (self->sock != SOCK_ERROR) {
if (self->sock != igloo_SOCK_ERROR) {
if (listener->so_sndbuf)
sock_set_send_buffer(self->sock, listener->so_sndbuf);
igloo_sock_set_send_buffer(self->sock, listener->so_sndbuf);
sock_set_blocking(self->sock, 0);
igloo_sock_set_blocking(self->sock, 0);
__socket_listen(self->sock, listener);
}
@ -648,16 +648,16 @@ int listensocket_refsock(listensocket_t *self)
}
thread_rwlock_rlock(&self->listener_rwlock);
self->sock = sock_get_server_socket(self->listener->port, self->listener->bind_address);
self->sock = igloo_sock_get_server_socket(self->listener->port, self->listener->bind_address);
thread_rwlock_unlock(&self->listener_rwlock);
if (self->sock == SOCK_ERROR) {
if (self->sock == igloo_SOCK_ERROR) {
thread_mutex_unlock(&self->lock);
return -1;
}
if (__socket_listen(self->sock, self->listener) == 0) {
sock_close(self->sock);
self->sock = SOCK_ERROR;
igloo_sock_close(self->sock);
self->sock = igloo_SOCK_ERROR;
thread_rwlock_rlock(&self->listener_rwlock);
ICECAST_LOG_ERROR("Can not listen on socket: %s port %i", __string_default(self->listener->bind_address, "<ANY>"), self->listener->port);
thread_rwlock_unlock(&self->listener_rwlock);
@ -688,13 +688,13 @@ int listensocket_unrefsock(listensocket_t *self)
return 0;
}
if (self->sock == SOCK_ERROR) {
if (self->sock == igloo_SOCK_ERROR) {
thread_mutex_unlock(&self->lock);
return 0;
}
sock_close(self->sock);
self->sock = SOCK_ERROR;
igloo_sock_close(self->sock);
self->sock = igloo_SOCK_ERROR;
thread_mutex_unlock(&self->lock);
return 0;
@ -704,7 +704,7 @@ connection_t * listensocket_accept(listensocket_t *self, listensock
{
connection_t *con;
listensocket_t *effective = NULL;
sock_t sock;
igloo_sock_t sock;
char *ip;
if (!self)
@ -715,9 +715,9 @@ connection_t * listensocket_accept(listensocket_t *self, listensock
return NULL;
thread_mutex_lock(&self->lock);
sock = sock_accept(self->sock, ip, MAX_ADDR_LEN);
sock = igloo_sock_accept(self->sock, ip, MAX_ADDR_LEN);
thread_mutex_unlock(&self->lock);
if (sock == SOCK_ERROR) {
if (sock == igloo_SOCK_ERROR) {
free(ip);
return NULL;
}
@ -746,7 +746,7 @@ connection_t * listensocket_accept(listensocket_t *self, listensock
refobject_unref(effective);
if (con == NULL) {
sock_close(sock);
igloo_sock_close(sock);
free(ip);
return NULL;
}
@ -807,7 +807,7 @@ static inline int listensocket__poll_fill(listensocket_t *self, struct pollfd *p
return -1;
thread_mutex_lock(&self->lock);
if (self->sock == SOCK_ERROR) {
if (self->sock == igloo_SOCK_ERROR) {
thread_mutex_unlock(&self->lock);
return -1;
}
@ -828,7 +828,7 @@ static inline int listensocket__select_set(listensocket_t *self, fd_set *set, in
return -1;
thread_mutex_lock(&self->lock);
if (self->sock == SOCK_ERROR) {
if (self->sock == igloo_SOCK_ERROR) {
thread_mutex_unlock(&self->lock);
return -1;
}
@ -849,7 +849,7 @@ static inline int listensocket__select_isset(listensocket_t *self, fd_set *set)
return -1;
thread_mutex_lock(&self->lock);
if (self->sock == SOCK_ERROR) {
if (self->sock == igloo_SOCK_ERROR) {
thread_mutex_unlock(&self->lock);
return -1;
}

View File

@ -19,8 +19,8 @@
#include <time.h>
#include <string.h>
#include <permafrost/thread.h>
#include <permafrost/httpp.h>
#include <igloo/thread.h>
#include <igloo/httpp.h>
#include "logging.h"
#include "connection.h"
@ -118,7 +118,7 @@ int get_clf_time (char *buffer, unsigned len, struct tm *t)
** BYTES = client->con->sent_bytes
** REFERER = get from client->parser
** AGENT = get from client->parser
** TIME = timing_get_time() - client->con->con_time
** TIME = igloo_timing_get_time() - client->con->con_time
*/
void logging_access(client_t *client)
{
@ -146,23 +146,23 @@ void logging_access(client_t *client)
else
username = client->username;
referrer = httpp_getvar (client->parser, "referer");
referrer = igloo_httpp_getvar (client->parser, "referer");
if (referrer == NULL)
referrer = "-";
user_agent = httpp_getvar (client->parser, "user-agent");
user_agent = igloo_httpp_getvar (client->parser, "user-agent");
if (user_agent == NULL)
user_agent = "-";
log_write_direct (accesslog,
igloo_log_write_direct (accesslog,
"%s - %H [%s] \"%H %H %H/%H\" %d %llu \"% H\" \"% H\" %llu",
client->con->ip,
username,
datebuf,
httpp_getvar (client->parser, HTTPP_VAR_REQ_TYPE),
httpp_getvar (client->parser, HTTPP_VAR_URI),
httpp_getvar (client->parser, HTTPP_VAR_PROTOCOL),
httpp_getvar (client->parser, HTTPP_VAR_VERSION),
igloo_httpp_getvar (client->parser, igloo_HTTPP_VAR_REQ_TYPE),
igloo_httpp_getvar (client->parser, igloo_HTTPP_VAR_URI),
igloo_httpp_getvar (client->parser, igloo_HTTPP_VAR_PROTOCOL),
igloo_httpp_getvar (client->parser, igloo_HTTPP_VAR_VERSION),
client->respcode,
(long long unsigned int)client->con->sent_bytes,
referrer,
@ -194,7 +194,7 @@ void logging_playlist(const char *mount, const char *metadata, long listeners)
#endif
/* This format MAY CHANGE OVER TIME. We are looking into finding a good
standard format for this, if you have any ideas, please let us know */
log_write_direct (playlistlog, "%s|%s|%ld|%s",
igloo_log_write_direct (playlistlog, "%s|%s|%ld|%s",
datebuf,
mount,
listeners,
@ -213,7 +213,7 @@ void log_parse_failure (void *ctx, const char *fmt, ...)
eol = strrchr (line, '\n');
if (eol) *eol='\0';
va_end (ap);
log_write (errorlog, 2, (char*)ctx, "", "%s", line);
igloo_log_write (errorlog, 2, (char*)ctx, "", "%s", line);
}
@ -223,30 +223,30 @@ void restart_logging (ice_config_t *config)
{
char fn_error[FILENAME_MAX];
snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
log_set_filename (errorlog, fn_error);
log_set_level (errorlog, config->loglevel);
log_set_trigger (errorlog, config->logsize);
log_set_archive_timestamp(errorlog, config->logarchive);
log_reopen (errorlog);
igloo_log_set_filename (errorlog, fn_error);
igloo_log_set_level (errorlog, config->loglevel);
igloo_log_set_trigger (errorlog, config->logsize);
igloo_log_set_archive_timestamp(errorlog, config->logarchive);
igloo_log_reopen (errorlog);
}
if (strcmp (config->access_log, "-"))
{
char fn_error[FILENAME_MAX];
snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
log_set_filename (accesslog, fn_error);
log_set_trigger (accesslog, config->logsize);
log_set_archive_timestamp (accesslog, config->logarchive);
log_reopen (accesslog);
igloo_log_set_filename (accesslog, fn_error);
igloo_log_set_trigger (accesslog, config->logsize);
igloo_log_set_archive_timestamp (accesslog, config->logarchive);
igloo_log_reopen (accesslog);
}
if (config->playlist_log)
{
char fn_error[FILENAME_MAX];
snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->playlist_log);
log_set_filename (playlistlog, fn_error);
log_set_trigger (playlistlog, config->logsize);
log_set_archive_timestamp (playlistlog, config->logarchive);
log_reopen (playlistlog);
igloo_log_set_filename (playlistlog, fn_error);
igloo_log_set_trigger (playlistlog, config->logsize);
igloo_log_set_archive_timestamp (playlistlog, config->logarchive);
igloo_log_reopen (playlistlog);
}
}

View File

@ -14,7 +14,7 @@
#ifndef __LOGGING_H__
#define __LOGGING_H__
#include <permafrost/log.h>
#include <igloo/log.h>
#include "icecasttypes.h"
@ -39,7 +39,7 @@ extern int playlistlog;
** Variadic macros for logging
*/
#define ICECAST_LOG(level,...) log_write(errorlog, (level), CATMODULE "/", __func__, __VA_ARGS__)
#define ICECAST_LOG(level,...) igloo_log_write(errorlog, (level), CATMODULE "/", __func__, __VA_ARGS__)
#define ICECAST_LOG_ERROR(...) ICECAST_LOG(ICECAST_LOGLEVEL_ERROR, __VA_ARGS__)
#define ICECAST_LOG_WARN(...) ICECAST_LOG(ICECAST_LOGLEVEL_WARN, __VA_ARGS__)
#define ICECAST_LOG_INFO(...) ICECAST_LOG(ICECAST_LOGLEVEL_INFO, __VA_ARGS__)

View File

@ -44,10 +44,10 @@
#include <sys/utsname.h>
#endif
#include <permafrost/thread.h>
#include <permafrost/sock.h>
#include <permafrost/resolver.h>
#include <permafrost/httpp.h>
#include <igloo/thread.h>
#include <igloo/sock.h>
#include <igloo/resolver.h>
#include <igloo/httpp.h>
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
@ -115,9 +115,9 @@ static void _print_usage(void)
static void _stop_logging(void)
{
log_close(errorlog);
log_close(accesslog);
log_close(playlistlog);
igloo_log_close(errorlog);
igloo_log_close(accesslog);
igloo_log_close(playlistlog);
}
#ifndef FASTEVENT_ENABLED
@ -142,15 +142,15 @@ static refobject_t fastevent_reg;
static void initialize_subsystems(void)
{
log_initialize();
thread_initialize();
igloo_log_initialize();
igloo_thread_initialize();
global_initialize();
#ifndef FASTEVENT_ENABLED
fastevent_initialize();
fastevent_reg = fastevent_register(FASTEVENT_TYPE_SLOWEVENT, __fastevent_cb, NULL, NULL);
#endif
sock_initialize();
resolver_initialize();
igloo_sock_initialize();
igloo_resolver_initialize();
config_initialize();
tls_initialize();
connection_initialize();
@ -175,14 +175,14 @@ static void shutdown_subsystems(void)
connection_shutdown();
tls_shutdown();
config_shutdown();
resolver_shutdown();
sock_shutdown();
igloo_resolver_shutdown();
igloo_sock_shutdown();
#ifndef FASTEVENT_ENABLED
refobject_unref(fastevent_reg);
fastevent_shutdown();
#endif
global_shutdown();
thread_shutdown();
igloo_thread_shutdown();
#ifdef HAVE_CURL
icecast_curl_shutdown();
@ -190,7 +190,7 @@ static void shutdown_subsystems(void)
/* Now that these are done, we can stop the loggers. */
_stop_logging();
log_shutdown();
igloo_log_shutdown();
xslt_shutdown();
}
@ -259,11 +259,11 @@ static int _parse_config_opts(int argc, char **argv, char *filename, size_t size
}
static int _start_logging_stdout(void) {
errorlog = log_open_file(stderr);
errorlog = igloo_log_open_file(stderr);
if ( errorlog < 0 )
return 0;
log_set_level(errorlog, ICECAST_LOGLEVEL_WARN);
igloo_log_set_level(errorlog, ICECAST_LOGLEVEL_WARN);
return 1;
}
@ -282,11 +282,11 @@ static int _start_logging(void)
/* this is already in place because of _start_logging_stdout() */
} else {
snprintf(fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
errorlog = log_open(fn_error);
errorlog = igloo_log_open(fn_error);
log_to_stderr = 0;
if (config->logsize)
log_set_trigger (errorlog, config->logsize);
log_set_archive_timestamp(errorlog, config->logarchive);
igloo_log_set_trigger (errorlog, config->logsize);
igloo_log_set_archive_timestamp(errorlog, config->logarchive);
}
if (errorlog < 0) {
@ -297,18 +297,18 @@ static int _start_logging(void)
strerror(errno));
_fatal_error(buf);
}
log_set_level(errorlog, config->loglevel);
igloo_log_set_level(errorlog, config->loglevel);
if(strcmp(config->access_log, "-") == 0) {
accesslog = log_open_file(stderr);
accesslog = igloo_log_open_file(stderr);
log_to_stderr = 1;
} else {
snprintf(fn_access, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
accesslog = log_open(fn_access);
accesslog = igloo_log_open(fn_access);
log_to_stderr = 0;
if (config->logsize)
log_set_trigger (accesslog, config->logsize);
log_set_archive_timestamp(accesslog, config->logarchive);
igloo_log_set_trigger (accesslog, config->logsize);
igloo_log_set_archive_timestamp(accesslog, config->logarchive);
}
if (accesslog < 0) {
@ -322,7 +322,7 @@ static int _start_logging(void)
if(config->playlist_log) {
snprintf(fn_playlist, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->playlist_log);
playlistlog = log_open(fn_playlist);
playlistlog = igloo_log_open(fn_playlist);
if (playlistlog < 0) {
buf[sizeof(buf)-1] = 0;
snprintf(buf, sizeof(buf)-1,
@ -333,15 +333,15 @@ static int _start_logging(void)
}
log_to_stderr = 0;
if (config->logsize)
log_set_trigger (playlistlog, config->logsize);
log_set_archive_timestamp(playlistlog, config->logarchive);
igloo_log_set_trigger (playlistlog, config->logsize);
igloo_log_set_archive_timestamp(playlistlog, config->logarchive);
} else {
playlistlog = -1;
}
log_set_level(errorlog, config->loglevel);
log_set_level(accesslog, 4);
log_set_level(playlistlog, 4);
igloo_log_set_level(errorlog, config->loglevel);
igloo_log_set_level(accesslog, 4);
igloo_log_set_level(playlistlog, 4);
if (errorlog >= 0 && accesslog >= 0) return 1;

View File

@ -19,7 +19,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <permafrost/avl.h>
#include <igloo/avl.h>
#include "matchfile.h"
#include "logging.h"
@ -35,7 +35,7 @@ struct matchfile_tag {
time_t file_recheck;
time_t file_mtime;
avl_tree *contents;
igloo_avl_tree *contents;
};
static int __func_free(void *x) {
@ -52,7 +52,7 @@ static void __func_recheck(matchfile_t *file) {
time_t now = time(NULL);
struct stat file_stat;
FILE *input = NULL;
avl_tree *new_contents;
igloo_avl_tree *new_contents;
char line[MAX_LINE_LEN];
if (now < file->file_recheck)
@ -76,7 +76,7 @@ static void __func_recheck(matchfile_t *file) {
return;
}
new_contents = avl_tree_new(__func_compare, NULL);
new_contents = igloo_avl_tree_new(__func_compare, NULL);
while (get_line(input, line, MAX_LINE_LEN)) {
char *str;
@ -85,12 +85,12 @@ static void __func_recheck(matchfile_t *file) {
continue;
str = strdup(line);
if (str)
avl_insert(new_contents, str);
igloo_avl_insert(new_contents, str);
}
fclose(input);
if (file->contents) avl_tree_free(file->contents, __func_free);
if (file->contents) igloo_avl_tree_free(file->contents, __func_free);
file->contents = new_contents;
}
@ -139,14 +139,14 @@ int matchfile_release(matchfile_t *file) {
return 0;
if (file->contents)
avl_tree_free(file->contents, __func_free);
igloo_avl_tree_free(file->contents, __func_free);
free(file->filename);
free(file);
return 0;
}
/* we are not const char *key because of avl_get_by_key()... */
/* we are not const char *key because of igloo_avl_get_by_key()... */
int matchfile_match(matchfile_t *file, const char *key) {
void *result;
@ -159,7 +159,7 @@ int matchfile_match(matchfile_t *file, const char *key) {
if (!file->contents)
return 0;
return avl_get_by_key(file->contents, (void*)key, &result) == 0 ? 1 : 0;
return igloo_avl_get_by_key(file->contents, (void*)key, &result) == 0 ? 1 : 0;
}
int matchfile_match_allow_deny(matchfile_t *allow, matchfile_t *deny, const char *key) {

View File

@ -13,8 +13,8 @@
#include <stdlib.h>
#include <string.h>
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include "refobject.h"
#include "module.h"
@ -22,7 +22,7 @@
struct module_tag {
refobject_base_t __base;
mutex_t lock;
igloo_mutex_t lock;
const module_client_handler_t *client_handlers;
size_t client_handlers_len;
module_setup_handler_t freecb;
@ -34,8 +34,8 @@ struct module_tag {
struct module_container_tag {
refobject_base_t __base;
mutex_t lock;
avl_tree *module;
igloo_mutex_t lock;
igloo_avl_tree *module;
};
static int compare_refobject_t_name(void *arg, void *a, void *b)
@ -46,8 +46,8 @@ static int compare_refobject_t_name(void *arg, void *a, void *b)
static void __module_container_free(refobject_t self, void **userdata)
{
module_container_t *cont = REFOBJECT_TO_TYPE(self, module_container_t *);
thread_mutex_destroy(&(cont->lock));
avl_tree_free(cont->module, (avl_free_key_fun_type)refobject_unref);
igloo_thread_mutex_destroy(&(cont->lock));
igloo_avl_tree_free(cont->module, (igloo_avl_free_key_fun_type)refobject_unref);
}
int __module_container_new(refobject_t self, const refobject_type_t *type, va_list ap)
@ -56,7 +56,7 @@ int __module_container_new(refobject_t self, const refobject_type_t *type, va_li
thread_mutex_create(&(ret->lock));
ret->module = avl_tree_new(compare_refobject_t_name, NULL);
ret->module = igloo_avl_tree_new(compare_refobject_t_name, NULL);
return 0;
}
@ -75,7 +75,7 @@ int module_container_add_module(module_container_t *self, mo
return -1;
thread_mutex_lock(&(self->lock));
avl_insert(self->module, module);
igloo_avl_insert(self->module, module);
thread_mutex_unlock(&(self->lock));
return 0;
@ -93,7 +93,7 @@ int module_container_delete_module(module_container_t *self,
return -1;
thread_mutex_lock(&(self->lock));
avl_delete(self->module, module, (avl_free_key_fun_type)refobject_unref);
igloo_avl_delete(self->module, module, (igloo_avl_free_key_fun_type)refobject_unref);
thread_mutex_unlock(&(self->lock));
refobject_unref(module);
@ -112,7 +112,7 @@ module_t * module_container_get_module(module_container_t *self, co
search = refobject_new__new(refobject_base_t, NULL, name, NULL);
thread_mutex_lock(&(self->lock));
if (avl_get_by_key(self->module, REFOBJECT_TO_TYPE(search, void *), (void**)&ret) != 0) {
if (igloo_avl_get_by_key(self->module, REFOBJECT_TO_TYPE(search, void *), (void**)&ret) != 0) {
ret = NULL;
}
thread_mutex_unlock(&(self->lock));
@ -126,7 +126,7 @@ module_t * module_container_get_module(module_container_t *self, co
xmlNodePtr module_container_get_modulelist_as_xml(module_container_t *self)
{
xmlNodePtr root;
avl_node *avlnode;
igloo_avl_node *avlnode;
if (!self)
return NULL;
@ -136,7 +136,7 @@ xmlNodePtr module_container_get_modulelist_as_xml(module_co
return NULL;
thread_mutex_lock(&(self->lock));
avlnode = avl_get_first(self->module);
avlnode = igloo_avl_get_first(self->module);
while (avlnode) {
module_t *module = avlnode->key;
xmlNodePtr node = xmlNewChild(root, NULL, XMLSTR("module"), NULL);
@ -147,7 +147,7 @@ xmlNodePtr module_container_get_modulelist_as_xml(module_co
if (module->management_link_title)
xmlSetProp(node, XMLSTR("management-title"), XMLSTR(module->management_link_title));
avlnode = avl_get_next(avlnode);
avlnode = igloo_avl_get_next(avlnode);
}
thread_mutex_unlock(&(self->lock));
@ -167,7 +167,7 @@ static void __module_free(refobject_t self, void **userdata)
free(mod->management_link_url);
free(mod->management_link_title);
thread_mutex_destroy(&(mod->lock));
igloo_thread_mutex_destroy(&(mod->lock));
}
REFOBJECT_DEFINE_TYPE(module_t,

View File

@ -13,7 +13,7 @@
#include <stdlib.h>
#include <string.h>
#include <permafrost/thread.h>
#include <igloo/thread.h>
#include "refobject.h"
@ -136,7 +136,7 @@ int refobject_unref(refobject_t self)
free(base->name);
thread_mutex_unlock(&(base->lock));
thread_mutex_destroy(&(base->lock));
igloo_thread_mutex_destroy(&(base->lock));
free(base);

View File

@ -20,7 +20,7 @@
#include <stdarg.h>
#include <permafrost/thread.h>
#include <igloo/thread.h>
#include "icecasttypes.h"
#include "compat.h"
@ -162,7 +162,7 @@ struct refobject_type_tag {
struct refobject_base_tag {
const refobject_type_t* type;
size_t refc;
mutex_t lock;
igloo_mutex_t lock;
void *userdata;
char *name;
refobject_t associated;

View File

@ -16,8 +16,8 @@
#include <string.h>
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include "reportxml.h"
#include "refobject.h"
@ -59,9 +59,9 @@ struct reportxml_database_tag {
/* base object */
refobject_base_t __base;
/* the lock used to ensure the database object is thread safe. */
mutex_t lock;
igloo_mutex_t lock;
/* The tree of definitions */
avl_tree *definitions;
igloo_avl_tree *definitions;
};
/* The nodeattr structure is used to store definition of node attributes */
@ -959,9 +959,9 @@ static void __database_free(refobject_t self, void **userdata)
reportxml_database_t *db = REFOBJECT_TO_TYPE(self, reportxml_database_t *);
if (db->definitions)
avl_tree_free(db->definitions, (avl_free_key_fun_type)refobject_unref);
igloo_avl_tree_free(db->definitions, (igloo_avl_free_key_fun_type)refobject_unref);
thread_mutex_destroy(&(db->lock));
igloo_thread_mutex_destroy(&(db->lock));
}
static int __compare_definitions(void *arg, void *a, void *b)
@ -990,7 +990,7 @@ static int __database_new(refobject_t self, const refobject_type_t *type, va_lis
thread_mutex_create(&(ret->lock));
ret->definitions = avl_tree_new(__compare_definitions, NULL);
ret->definitions = igloo_avl_tree_new(__compare_definitions, NULL);
if (!ret->definitions)
return -1;
@ -1041,7 +1041,7 @@ int reportxml_database_add_report(reportxml_database_t *db,
if (!copy)
continue;
avl_insert(db->definitions, copy);
igloo_avl_insert(db->definitions, copy);
}
thread_mutex_unlock(&(db->lock));
@ -1159,7 +1159,7 @@ static reportxml_node_t * __reportxml_database_build_node_ext(reportxml_dat
}
thread_mutex_lock(&(db->lock));
if (avl_get_by_key(db->definitions, REFOBJECT_TO_TYPE(search, void *), (void**)&found) != 0) {
if (igloo_avl_get_by_key(db->definitions, REFOBJECT_TO_TYPE(search, void *), (void**)&found) != 0) {
thread_mutex_unlock(&(db->lock));
refobject_unref(search);
return NULL;

View File

@ -17,9 +17,9 @@
#include <signal.h>
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <permafrost/httpp.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include <igloo/httpp.h>
#include "global.h"
#include "connection.h"

View File

@ -39,10 +39,10 @@
#include <libxml/uri.h>
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <permafrost/sock.h>
#include <permafrost/httpp.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include <igloo/sock.h>
#include <igloo/httpp.h>
#include "slave.h"
#include "cfgfile.h"
@ -64,17 +64,17 @@ struct relay_tag {
int running;
int cleanup;
time_t start;
thread_type *thread;
igloo_thread_type *thread;
relay_t *next;
};
static void *_slave_thread(void *arg);
static thread_type *_slave_thread_id;
static igloo_thread_type *_slave_thread_id;
static int slave_running = 0;
static volatile int update_settings = 0;
static volatile int update_all_mounts = 0;
static volatile unsigned int max_interval = 0;
static mutex_t _slave_mutex; // protects slave_running, update_settings, update_all_mounts, max_interval
static igloo_mutex_t _slave_mutex; // protects slave_running, update_settings, update_all_mounts, max_interval
static inline void relay_config_upstream_free (relay_config_upstream_t *upstream)
{
@ -218,7 +218,7 @@ void slave_initialize(void)
slave_running = 1;
max_interval = 0;
thread_mutex_create (&_slave_mutex);
_slave_thread_id = thread_create("Slave Thread", _slave_thread, NULL, THREAD_ATTACHED);
_slave_thread_id = thread_create("Slave Thread", _slave_thread, NULL, igloo_THREAD_ATTACHED);
}
@ -233,7 +233,7 @@ void slave_shutdown(void)
thread_mutex_unlock(&_slave_mutex);
ICECAST_LOG_DEBUG("waiting for slave thread");
thread_join (_slave_thread_id);
igloo_thread_join (_slave_thread_id);
}
@ -246,7 +246,7 @@ static client_t *open_relay_connection (relay_t *relay, relay_config_upstream_t
int redirects = 0;
char *server_id = NULL;
ice_config_t *config;
http_parser_t *parser = NULL;
igloo_http_parser_t *parser = NULL;
connection_t *con=NULL;
char *server = strdup (_GET_UPSTREAM_SETTING(server));
char *mount = strdup (_GET_UPSTREAM_SETTING(mount));
@ -279,12 +279,12 @@ static client_t *open_relay_connection (relay_t *relay, relay_config_upstream_t
while (redirects < 10)
{
sock_t streamsock;
igloo_sock_t streamsock;
ICECAST_LOG_INFO("connecting to %s:%d", server, port);
streamsock = sock_connect_wto_bind (server, port, _GET_UPSTREAM_SETTING(bind), 10);
if (streamsock == SOCK_ERROR)
streamsock = igloo_sock_connect_wto_bind (server, port, _GET_UPSTREAM_SETTING(bind), 10);
if (streamsock == igloo_SOCK_ERROR)
{
ICECAST_LOG_WARN("Failed to connect to %s:%d", server, port);
break;
@ -296,7 +296,7 @@ static client_t *open_relay_connection (relay_t *relay, relay_config_upstream_t
* state so (the typical case). It's harmless in the vorbis case. If
* we don't send in this header then relay will not have mp3 metadata.
*/
sock_write(streamsock, "GET %s HTTP/1.0\r\n"
igloo_sock_write(streamsock, "GET %s HTTP/1.0\r\n"
"User-Agent: %s\r\n"
"Host: %s\r\n"
"%s"
@ -313,21 +313,21 @@ static client_t *open_relay_connection (relay_t *relay, relay_config_upstream_t
ICECAST_LOG_ERROR("Header read failed for %s (%s:%d%s)", relay->config->localmount, server, port, mount);
break;
}
parser = httpp_create_parser();
httpp_initialize (parser, NULL);
if (! httpp_parse_response (parser, header, strlen(header), relay->config->localmount))
parser = igloo_httpp_create_parser();
igloo_httpp_initialize (parser, NULL);
if (! igloo_httpp_parse_response (parser, header, strlen(header), relay->config->localmount))
{
ICECAST_LOG_ERROR("Error parsing relay request for %s (%s:%d%s)", relay->config->localmount,
server, port, mount);
break;
}
if (strcmp (httpp_getvar (parser, HTTPP_VAR_ERROR_CODE), "302") == 0)
if (strcmp (igloo_httpp_getvar (parser, igloo_HTTPP_VAR_ERROR_CODE), "302") == 0)
{
/* better retry the connection again but with different details */
const char *uri, *mountpoint;
int len;
uri = httpp_getvar (parser, "location");
uri = igloo_httpp_getvar (parser, "location");
ICECAST_LOG_INFO("redirect received %s", uri);
if (strncmp (uri, "http://", 7) != 0)
break;
@ -355,10 +355,10 @@ static client_t *open_relay_connection (relay_t *relay, relay_config_upstream_t
{
client_t *client = NULL;
if (httpp_getvar (parser, HTTPP_VAR_ERROR_MESSAGE))
if (igloo_httpp_getvar (parser, igloo_HTTPP_VAR_ERROR_MESSAGE))
{
ICECAST_LOG_ERROR("Error from relay request: %s (%s)", relay->config->localmount,
httpp_getvar(parser, HTTPP_VAR_ERROR_MESSAGE));
igloo_httpp_getvar(parser, igloo_HTTPP_VAR_ERROR_MESSAGE));
break;
}
global_lock ();
@ -372,7 +372,7 @@ static client_t *open_relay_connection (relay_t *relay, relay_config_upstream_t
break;
}
global_unlock ();
sock_set_blocking (streamsock, 0);
igloo_sock_set_blocking (streamsock, 0);
client_set_queue (client, NULL);
client_complete(client);
free (server);
@ -464,13 +464,13 @@ static void *start_relay_stream (void *arg)
source_t *fallback_source;
ICECAST_LOG_DEBUG("failed relay, fallback to %s", relay->source->fallback_mount);
avl_tree_rlock(global.source_tree);
igloo_avl_tree_rlock(global.source_tree);
fallback_source = source_find_mount(relay->source->fallback_mount);
if (fallback_source != NULL)
source_move_clients(relay->source, fallback_source);
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
}
source_clear_source(relay->source);
@ -540,14 +540,14 @@ static void check_relay_stream (relay_t *relay)
if (source->fallback_mount && source->fallback_override)
{
source_t *fallback;
avl_tree_rlock (global.source_tree);
igloo_avl_tree_rlock (global.source_tree);
fallback = source_find_mount (source->fallback_mount);
if (fallback && fallback->running && fallback->listeners)
{
ICECAST_LOG_DEBUG("fallback running %d with %lu listeners", fallback->running, fallback->listeners);
source->on_demand_req = 1;
}
avl_tree_unlock (global.source_tree);
igloo_avl_tree_unlock (global.source_tree);
}
if (source->on_demand_req == 0)
break;
@ -556,7 +556,7 @@ static void check_relay_stream (relay_t *relay)
relay->start = time(NULL) + 5;
relay->running = 1;
relay->thread = thread_create ("Relay Thread", start_relay_stream,
relay, THREAD_ATTACHED);
relay, igloo_THREAD_ATTACHED);
return;
} while (0);
@ -566,7 +566,7 @@ static void check_relay_stream (relay_t *relay)
if (relay->thread)
{
ICECAST_LOG_DEBUG("waiting for relay thread for \"%s\"", relay->config->localmount);
thread_join (relay->thread);
igloo_thread_join (relay->thread);
relay->thread = NULL;
}
relay->cleanup = 0;
@ -717,7 +717,7 @@ static void relay_check_streams (relay_t *to_start,
ICECAST_LOG_DEBUG("source shutdown request on \"%s\"", to_free->config->localmount);
to_free->running = 0;
to_free->source->running = 0;
thread_join (to_free->thread);
igloo_thread_join (to_free->thread);
}
else
stats_event (to_free->config->localmount, NULL, NULL);
@ -740,7 +740,7 @@ static int update_from_master(ice_config_t *config)
{
char *master = NULL, *password = NULL, *username= NULL;
int port;
sock_t mastersock;
igloo_sock_t mastersock;
int ret = 0;
char buf[256];
do
@ -767,9 +767,9 @@ static int update_from_master(ice_config_t *config)
on_demand = config->on_demand;
ret = 1;
config_release_config();
mastersock = sock_connect_wto(master, port, 10);
mastersock = igloo_sock_connect_wto(master, port, 10);
if (mastersock == SOCK_ERROR)
if (mastersock == igloo_SOCK_ERROR)
{
ICECAST_LOG_WARN("Relay slave failed to contact master server to fetch stream list");
break;
@ -779,29 +779,29 @@ static int update_from_master(ice_config_t *config)
authheader = malloc(len);
snprintf (authheader, len, "%s:%s", username, password);
data = util_base64_encode(authheader, len);
sock_write (mastersock,
igloo_sock_write (mastersock,
"GET /admin/streamlist.txt HTTP/1.0\r\n"
"Authorization: Basic %s\r\n"
"\r\n", data);
free(authheader);
free(data);
if (sock_read_line(mastersock, buf, sizeof(buf)) == 0 ||
if (igloo_sock_read_line(mastersock, buf, sizeof(buf)) == 0 ||
((strncmp (buf, "HTTP/1.0 200", 12) != 0) && (strncmp (buf, "HTTP/1.1 200", 12) != 0)))
{
sock_close (mastersock);
igloo_sock_close (mastersock);
ICECAST_LOG_WARN("Master rejected streamlist request");
break;
} else {
ICECAST_LOG_INFO("Master accepted streamlist request");
}
while (sock_read_line(mastersock, buf, sizeof(buf)))
while (igloo_sock_read_line(mastersock, buf, sizeof(buf)))
{
if (!strlen(buf))
break;
}
while (sock_read_line(mastersock, buf, sizeof(buf)))
while (igloo_sock_read_line(mastersock, buf, sizeof(buf)))
{
relay_config_t *c = NULL;
relay_config_t **n;
@ -844,7 +844,7 @@ static int update_from_master(ice_config_t *config)
}
xmlFreeURI(parsed_uri);
}
sock_close (mastersock);
igloo_sock_close (mastersock);
thread_mutex_lock (&(config_locks()->relay_lock));
cleanup_relays = update_relays (&global.master_relays, new_relays, new_relays_length);
@ -901,7 +901,7 @@ static void *_slave_thread(void *arg)
}
global_unlock();
thread_sleep(1000000);
igloo_thread_sleep(1000000);
thread_mutex_lock(&_slave_mutex);
if (slave_running == 0) {
thread_mutex_unlock(&_slave_mutex);

View File

@ -14,7 +14,7 @@
#ifndef __SLAVE_H__
#define __SLAVE_H__
#include <permafrost/thread.h>
#include <igloo/thread.h>
#include "icecasttypes.h"
#include "cfgfile.h"

View File

@ -39,9 +39,9 @@
#define snprintf _snprintf
#endif
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <permafrost/httpp.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include <igloo/httpp.h>
#include "source.h"
#include "compat.h"
@ -66,7 +66,7 @@
#define MAX_FALLBACK_DEPTH 10
mutex_t move_clients_mutex;
igloo_mutex_t move_clients_mutex;
/* avl tree helper */
static int _compare_clients(void *compare_arg, void *a, void *b);
@ -88,7 +88,7 @@ source_t *source_reserve (const char *mount)
do
{
avl_tree_wlock (global.source_tree);
igloo_avl_tree_wlock (global.source_tree);
src = source_find_mount_raw (mount);
if (src)
{
@ -100,8 +100,8 @@ source_t *source_reserve (const char *mount)
if (src == NULL)
break;
src->client_tree = avl_tree_new(_compare_clients, NULL);
src->pending_tree = avl_tree_new(_compare_clients, NULL);
src->client_tree = igloo_avl_tree_new(_compare_clients, NULL);
src->pending_tree = igloo_avl_tree_new(_compare_clients, NULL);
src->history = playlist_new(10 /* DOCUMENT: default is max_tracks=10. */);
/* make duplicates for strings or similar */
@ -109,11 +109,11 @@ source_t *source_reserve (const char *mount)
src->max_listeners = -1;
thread_mutex_create(&src->lock);
avl_insert(global.source_tree, src);
igloo_avl_insert(global.source_tree, src);
} while (0);
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
return src;
}
@ -124,7 +124,7 @@ source_t *source_reserve (const char *mount)
source_t *source_find_mount_raw(const char *mount)
{
source_t *source;
avl_node *node;
igloo_avl_node *node;
int cmp;
if (!mount) {
@ -205,7 +205,7 @@ void source_clear_source (source_t *source)
ICECAST_LOG_DEBUG("clearing source \"%s\"", source->mount);
avl_tree_wlock (source->pending_tree);
igloo_avl_tree_wlock (source->pending_tree);
client_destroy(source->client);
source->client = NULL;
source->parser = NULL;
@ -223,17 +223,17 @@ void source_clear_source (source_t *source)
}
/* lets kick off any clients that are left on here */
avl_tree_wlock (source->client_tree);
igloo_avl_tree_wlock (source->client_tree);
c=0;
while (1)
{
avl_node *node = avl_get_first (source->client_tree);
igloo_avl_node *node = igloo_avl_get_first (source->client_tree);
if (node)
{
client_t *client = node->key;
if (client->respcode == 200)
c++; /* only count clients that have had some processing */
avl_delete (source->client_tree, client, _free_client);
igloo_avl_delete (source->client_tree, client, _free_client);
continue;
}
break;
@ -243,12 +243,12 @@ void source_clear_source (source_t *source)
stats_event_sub (NULL, "listeners", source->listeners);
ICECAST_LOG_INFO("%d active listeners on %s released", c, source->mount);
}
avl_tree_unlock (source->client_tree);
igloo_avl_tree_unlock (source->client_tree);
while (avl_get_first (source->pending_tree))
while (igloo_avl_get_first (source->pending_tree))
{
avl_delete (source->pending_tree,
avl_get_first(source->pending_tree)->key, _free_client);
igloo_avl_delete (source->pending_tree,
igloo_avl_get_first(source->pending_tree)->key, _free_client);
}
if (source->format && source->format->free_plugin)
@ -298,7 +298,7 @@ void source_clear_source (source_t *source)
}
source->on_demand_req = 0;
avl_tree_unlock (source->pending_tree);
igloo_avl_tree_unlock (source->pending_tree);
}
@ -306,12 +306,12 @@ void source_clear_source (source_t *source)
void source_free_source (source_t *source)
{
ICECAST_LOG_DEBUG("freeing source \"%s\"", source->mount);
avl_tree_wlock (global.source_tree);
avl_delete (global.source_tree, source, NULL);
avl_tree_unlock (global.source_tree);
igloo_avl_tree_wlock (global.source_tree);
igloo_avl_delete (global.source_tree, source, NULL);
igloo_avl_tree_unlock (global.source_tree);
avl_tree_free(source->pending_tree, _free_client);
avl_tree_free(source->client_tree, _free_client);
igloo_avl_tree_free(source->pending_tree, _free_client);
igloo_avl_tree_free(source->client_tree, _free_client);
/* make sure all YP entries have gone */
yp_remove (source->mount);
@ -332,14 +332,14 @@ client_t *source_find_client(source_t *source, int id)
fakeclient.con = &fakecon;
fakeclient.con->id = id;
avl_tree_rlock(source->client_tree);
if(avl_get_by_key(source->client_tree, &fakeclient, &result) == 0)
igloo_avl_tree_rlock(source->client_tree);
if(igloo_avl_get_by_key(source->client_tree, &fakeclient, &result) == 0)
{
avl_tree_unlock(source->client_tree);
igloo_avl_tree_unlock(source->client_tree);
return result;
}
avl_tree_unlock(source->client_tree);
igloo_avl_tree_unlock(source->client_tree);
return NULL;
}
@ -362,11 +362,11 @@ void source_move_clients(source_t *source, source_t *dest)
/* if the destination is not running then we can't move clients */
avl_tree_wlock (dest->pending_tree);
igloo_avl_tree_wlock (dest->pending_tree);
if (dest->running == 0 && dest->on_demand == 0)
{
ICECAST_LOG_WARN("destination mount %s not running, unable to move clients ", dest->mount);
avl_tree_unlock (dest->pending_tree);
igloo_avl_tree_unlock (dest->pending_tree);
thread_mutex_unlock (&move_clients_mutex);
return;
}
@ -377,8 +377,8 @@ void source_move_clients(source_t *source, source_t *dest)
/* we need to move the client and pending trees - we must take the
* locks in this order to avoid deadlocks */
avl_tree_wlock(source->pending_tree);
avl_tree_wlock(source->client_tree);
igloo_avl_tree_wlock(source->pending_tree);
igloo_avl_tree_wlock(source->client_tree);
if (source->on_demand == 0 && source->format == NULL)
{
@ -396,11 +396,11 @@ void source_move_clients(source_t *source, source_t *dest)
while (1)
{
avl_node *node = avl_get_first (source->pending_tree);
igloo_avl_node *node = igloo_avl_get_first (source->pending_tree);
if (node == NULL)
break;
client = (client_t *)(node->key);
avl_delete (source->pending_tree, client, NULL);
igloo_avl_delete (source->pending_tree, client, NULL);
/* when switching a client to a different queue, be wary of the
* refbuf it's referring to, if it's http headers then we need
@ -414,18 +414,18 @@ void source_move_clients(source_t *source, source_t *dest)
client->intro_offset = -1;
}
avl_insert (dest->pending_tree, (void *)client);
igloo_avl_insert (dest->pending_tree, (void *)client);
count++;
}
while (1)
{
avl_node *node = avl_get_first (source->client_tree);
igloo_avl_node *node = igloo_avl_get_first (source->client_tree);
if (node == NULL)
break;
client = (client_t *)(node->key);
avl_delete (source->client_tree, client, NULL);
igloo_avl_delete (source->client_tree, client, NULL);
/* when switching a client to a different queue, be wary of the
* refbuf it's referring to, if it's http headers then we need
@ -438,7 +438,7 @@ void source_move_clients(source_t *source, source_t *dest)
if (source->con == NULL)
client->intro_offset = -1;
}
avl_insert (dest->pending_tree, (void *)client);
igloo_avl_insert (dest->pending_tree, (void *)client);
count++;
}
ICECAST_LOG_INFO("passing %lu listeners to \"%s\"", count, dest->mount);
@ -448,14 +448,14 @@ void source_move_clients(source_t *source, source_t *dest)
} while (0);
avl_tree_unlock (source->pending_tree);
avl_tree_unlock (source->client_tree);
igloo_avl_tree_unlock (source->pending_tree);
igloo_avl_tree_unlock (source->client_tree);
/* see if we need to wake up an on-demand relay */
if (dest->running == 0 && dest->on_demand && count)
dest->on_demand_req = 1;
avl_tree_unlock (dest->pending_tree);
igloo_avl_tree_unlock (dest->pending_tree);
thread_mutex_unlock (&move_clients_mutex);
}
@ -480,7 +480,7 @@ static refbuf_t *get_next_buffer (source_t *source)
fds = util_timed_wait_for_fd (source->con->sock, delay);
else
{
thread_sleep (delay*1000);
igloo_thread_sleep (delay*1000);
source->last_read = current;
}
@ -494,7 +494,7 @@ static refbuf_t *get_next_buffer (source_t *source)
}
if (fds < 0)
{
if (! sock_recoverable (sock_error()))
if (! igloo_sock_recoverable (igloo_sock_error()))
{
ICECAST_LOG_WARN("Error while waiting on socket, Disconnecting source");
source->running = 0;
@ -619,7 +619,7 @@ static void source_init (source_t *source)
char listenurl[512];
const char *str;
str = httpp_getvar(source->parser, "ice-audio-info");
str = igloo_httpp_getvar(source->parser, "ice-audio-info");
source->audio_info = util_dict_new();
if (str)
{
@ -670,13 +670,13 @@ static void source_init (source_t *source)
{
source_t *fallback_source;
avl_tree_rlock(global.source_tree);
igloo_avl_tree_rlock(global.source_tree);
fallback_source = source_find_mount(source->fallback_mount);
if (fallback_source)
source_move_clients (fallback_source, source);
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
}
}
@ -685,7 +685,7 @@ void source_main (source_t *source)
{
refbuf_t *refbuf;
client_t *client;
avl_node *client_node;
igloo_avl_node *client_node;
source_init (source);
@ -739,31 +739,31 @@ void source_main (source_t *source)
thread_mutex_unlock(&source->lock);
/* acquire write lock on pending_tree */
avl_tree_wlock(source->pending_tree);
igloo_avl_tree_wlock(source->pending_tree);
/* acquire write lock on client_tree */
avl_tree_wlock(source->client_tree);
igloo_avl_tree_wlock(source->client_tree);
client_node = avl_get_first(source->client_tree);
client_node = igloo_avl_get_first(source->client_tree);
while (client_node) {
client = (client_t *) client_node->key;
send_to_listener(source, client, remove_from_q);
if (client->con->error) {
client_node = avl_get_next(client_node);
client_node = igloo_avl_get_next(client_node);
if (client->respcode == 200)
stats_event_dec(NULL, "listeners");
avl_delete(source->client_tree, (void *) client, _free_client);
igloo_avl_delete(source->client_tree, (void *) client, _free_client);
source->listeners--;
ICECAST_LOG_DEBUG("Client removed");
continue;
}
client_node = avl_get_next(client_node);
client_node = igloo_avl_get_next(client_node);
}
/** add pending clients **/
client_node = avl_get_first(source->pending_tree);
client_node = igloo_avl_get_first(source->pending_tree);
while (client_node) {
if(source->max_listeners != -1 &&
@ -775,8 +775,8 @@ void source_main (source_t *source)
* why they were disconnected
*/
client = (client_t *)client_node->key;
client_node = avl_get_next(client_node);
avl_delete(source->pending_tree, (void *)client, _free_client);
client_node = igloo_avl_get_next(client_node);
igloo_avl_delete(source->pending_tree, (void *)client, _free_client);
ICECAST_LOG_INFO("Client deleted, exceeding maximum listeners for this "
"mountpoint (%s).", source->mount);
@ -784,24 +784,24 @@ void source_main (source_t *source)
}
/* Otherwise, the client is accepted, add it */
avl_insert(source->client_tree, client_node->key);
igloo_avl_insert(source->client_tree, client_node->key);
source->listeners++;
ICECAST_LOG_DEBUG("Client added for mountpoint (%s)", source->mount);
stats_event_inc(source->mount, "connections");
client_node = avl_get_next(client_node);
client_node = igloo_avl_get_next(client_node);
}
/** clear pending tree **/
while (avl_get_first(source->pending_tree)) {
avl_delete(source->pending_tree,
avl_get_first(source->pending_tree)->key,
while (igloo_avl_get_first(source->pending_tree)) {
igloo_avl_delete(source->pending_tree,
igloo_avl_get_first(source->pending_tree)->key,
source_remove_client);
}
/* release write lock on pending_tree */
avl_tree_unlock(source->pending_tree);
igloo_avl_tree_unlock(source->pending_tree);
/* update the stats if need be */
if (source->listeners != source->prev_listeners)
@ -845,7 +845,7 @@ void source_main (source_t *source)
}
/* release write lock on client_tree */
avl_tree_unlock(source->client_tree);
igloo_avl_tree_unlock(source->client_tree);
}
source_shutdown (source);
}
@ -869,13 +869,13 @@ static void source_shutdown (source_t *source)
{
source_t *fallback_source;
avl_tree_rlock(global.source_tree);
igloo_avl_tree_rlock(global.source_tree);
fallback_source = source_find_mount(source->fallback_mount);
if (fallback_source != NULL)
source_move_clients(source, fallback_source);
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
}
/* delete this sources stats */
@ -883,7 +883,7 @@ static void source_shutdown (source_t *source)
if (source->client && source->parser) {
/* For PUT support we check for 100-continue and send back a final 200. */
const char *expectcontinue = httpp_getvar(source->parser, "expect");
const char *expectcontinue = igloo_httpp_getvar(source->parser, "expect");
if (expectcontinue != NULL) {
#ifdef HAVE_STRCASESTR
@ -998,11 +998,11 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr
{
const char *str;
int val;
http_parser_t *parser = NULL;
igloo_http_parser_t *parser = NULL;
acl_t *acl = NULL;
ICECAST_LOG_DEBUG("Applying mount information for \"%s\"", source->mount);
avl_tree_rlock (source->client_tree);
igloo_avl_tree_rlock (source->client_tree);
stats_event_args (source->mount, "listener_peak", "%lu", source->peak_listeners);
if (mountinfo)
@ -1028,14 +1028,14 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr
else
{
do {
str = httpp_getvar (parser, "ice-public");
str = igloo_httpp_getvar (parser, "ice-public");
if (str) break;
str = httpp_getvar (parser, "icy-pub");
str = igloo_httpp_getvar (parser, "icy-pub");
if (str) break;
str = httpp_getvar (parser, "x-audiocast-public");
str = igloo_httpp_getvar (parser, "x-audiocast-public");
if (str) break;
/* handle header from icecast v2 release */
str = httpp_getvar (parser, "icy-public");
str = igloo_httpp_getvar (parser, "icy-public");
if (str) break;
str = "0";
} while (0);
@ -1058,11 +1058,11 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr
else
{
do {
str = httpp_getvar (parser, "ice-name");
str = igloo_httpp_getvar (parser, "ice-name");
if (str) break;
str = httpp_getvar (parser, "icy-name");
str = igloo_httpp_getvar (parser, "icy-name");
if (str) break;
str = httpp_getvar (parser, "x-audiocast-name");
str = igloo_httpp_getvar (parser, "x-audiocast-name");
if (str) break;
str = "Unspecified name";
} while (0);
@ -1076,11 +1076,11 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr
else
{
do {
str = httpp_getvar (parser, "ice-description");
str = igloo_httpp_getvar (parser, "ice-description");
if (str) break;
str = httpp_getvar (parser, "icy-description");
str = igloo_httpp_getvar (parser, "icy-description");
if (str) break;
str = httpp_getvar (parser, "x-audiocast-description");
str = igloo_httpp_getvar (parser, "x-audiocast-description");
if (str) break;
str = "Unspecified description";
} while (0);
@ -1094,11 +1094,11 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr
else
{
do {
str = httpp_getvar (parser, "ice-url");
str = igloo_httpp_getvar (parser, "ice-url");
if (str) break;
str = httpp_getvar (parser, "icy-url");
str = igloo_httpp_getvar (parser, "icy-url");
if (str) break;
str = httpp_getvar (parser, "x-audiocast-url");
str = igloo_httpp_getvar (parser, "x-audiocast-url");
if (str) break;
} while (0);
if (str && source->format)
@ -1111,11 +1111,11 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr
else
{
do {
str = httpp_getvar (parser, "ice-genre");
str = igloo_httpp_getvar (parser, "ice-genre");
if (str) break;
str = httpp_getvar (parser, "icy-genre");
str = igloo_httpp_getvar (parser, "icy-genre");
if (str) break;
str = httpp_getvar (parser, "x-audiocast-genre");
str = igloo_httpp_getvar (parser, "x-audiocast-genre");
if (str) break;
str = "various";
} while (0);
@ -1129,11 +1129,11 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr
else
{
do {
str = httpp_getvar (parser, "ice-bitrate");
str = igloo_httpp_getvar (parser, "ice-bitrate");
if (str) break;
str = httpp_getvar (parser, "icy-br");
str = igloo_httpp_getvar (parser, "icy-br");
if (str) break;
str = httpp_getvar (parser, "x-audiocast-bitrate");
str = igloo_httpp_getvar (parser, "x-audiocast-bitrate");
} while (0);
}
stats_event (source->mount, "bitrate", str);
@ -1217,7 +1217,7 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr
if (mountinfo && mountinfo->max_history > 0)
playlist_set_max_tracks(source->history, mountinfo->max_history);
avl_tree_unlock(source->client_tree);
igloo_avl_tree_unlock(source->client_tree);
}
@ -1320,12 +1320,12 @@ void source_client_callback (client_t *client, void *arg)
client->refbuf->len = 0;
stats_event (source->mount, "source_ip", source->client->con->ip);
agent = httpp_getvar (source->client->parser, "user-agent");
agent = igloo_httpp_getvar (source->client->parser, "user-agent");
if (agent)
stats_event (source->mount, "user_agent", agent);
thread_create ("Source Thread", source_client_thread,
source, THREAD_DETACHED);
source, igloo_THREAD_DETACHED);
}
static void *source_fallback_file (void *arg)
@ -1337,7 +1337,7 @@ static void *source_fallback_file (void *arg)
FILE *file = NULL;
source_t *source = NULL;
ice_config_t *config;
http_parser_t *parser;
igloo_http_parser_t *parser;
do
{
@ -1369,9 +1369,9 @@ static void *source_fallback_file (void *arg)
}
ICECAST_LOG_INFO("mountpoint %s is reserved", mount);
type = fserve_content_type (mount);
parser = httpp_create_parser();
httpp_initialize (parser, NULL);
httpp_setvar (parser, "content-type", type);
parser = igloo_httpp_create_parser();
igloo_httpp_initialize (parser, NULL);
igloo_httpp_setvar (parser, "content-type", type);
free (type);
source->hidden = 1;
@ -1400,7 +1400,7 @@ void source_recheck_mounts (int update_all)
ice_config_t *config;
mount_proxy *mount;
avl_tree_rlock (global.source_tree);
igloo_avl_tree_rlock (global.source_tree);
config = config_get_config();
mount = config->mounts;
@ -1444,10 +1444,10 @@ void source_recheck_mounts (int update_all)
if (fallback == NULL)
{
thread_create ("Fallback file thread", source_fallback_file,
strdup (mount->fallback_mount), THREAD_DETACHED);
strdup (mount->fallback_mount), igloo_THREAD_DETACHED);
}
}
}
avl_tree_unlock (global.source_tree);
igloo_avl_tree_unlock (global.source_tree);
config_release_config();
}

View File

@ -16,8 +16,8 @@
#include <stdio.h>
#include <permafrost/thread.h>
#include <permafrost/httpp.h>
#include <igloo/thread.h>
#include <igloo/httpp.h>
#include "icecasttypes.h"
#include "yp.h"
@ -26,10 +26,10 @@
#include "playlist.h"
struct source_tag {
mutex_t lock;
igloo_mutex_t lock;
client_t *client;
connection_t *con;
http_parser_t *parser;
igloo_http_parser_t *parser;
time_t client_stats_update;
char *mount;
@ -43,10 +43,10 @@ struct source_tag {
struct _format_plugin_tag *format;
avl_tree *client_tree;
avl_tree *pending_tree;
igloo_avl_tree *client_tree;
igloo_avl_tree *pending_tree;
rwlock_t *shutdown_rwlock;
igloo_rwlock_t *shutdown_rwlock;
util_dict *audio_info;
FILE *intro_file;
@ -99,6 +99,6 @@ int source_remove_client(void *key);
void source_main(source_t *source);
void source_recheck_mounts (int update_all);
extern mutex_t move_clients_mutex;
extern igloo_mutex_t move_clients_mutex;
#endif

View File

@ -25,10 +25,10 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <permafrost/httpp.h>
#include <permafrost/sock.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include <igloo/httpp.h>
#include <igloo/sock.h>
#include "stats.h"
#include "connection.h"
@ -68,20 +68,20 @@ typedef struct _event_queue_tag
typedef struct _event_listener_tag
{
event_queue_t queue;
mutex_t mutex;
igloo_mutex_t mutex;
struct _event_listener_tag *next;
} event_listener_t;
static volatile int _stats_running = 0;
static thread_type *_stats_thread_id;
static igloo_thread_type *_stats_thread_id;
static volatile int _stats_threads = 0;
static stats_t _stats;
static mutex_t _stats_mutex;
static igloo_mutex_t _stats_mutex;
static event_queue_t _global_event_queue;
mutex_t _global_event_mutex;
igloo_mutex_t _global_event_mutex;
static volatile event_listener_t *_event_listeners;
@ -92,8 +92,8 @@ static int _compare_source_stats(void *a, void *b, void *arg);
static int _free_stats(void *key);
static int _free_source_stats(void *key);
static void _add_event_to_queue(stats_event_t *event, event_queue_t *queue);
static stats_node_t *_find_node(avl_tree *tree, const char *name);
static stats_source_t *_find_source(avl_tree *tree, const char *source);
static stats_node_t *_find_node(igloo_avl_tree *tree, const char *name);
static stats_source_t *_find_source(igloo_avl_tree *tree, const char *source);
static void _free_event(stats_event_t *event);
static stats_event_t *_get_event_from_queue(event_queue_t *queue);
static void __add_metadata(xmlNodePtr node, const char *tag);
@ -131,8 +131,8 @@ void stats_initialize(void)
_event_listeners = NULL;
/* set up global struct */
_stats.global_tree = avl_tree_new(_compare_stats, NULL);
_stats.source_tree = avl_tree_new(_compare_source_stats, NULL);
_stats.global_tree = igloo_avl_tree_new(_compare_stats, NULL);
_stats.source_tree = igloo_avl_tree_new(_compare_source_stats, NULL);
/* set up global mutex */
thread_mutex_create(&_stats_mutex);
@ -143,7 +143,7 @@ void stats_initialize(void)
/* fire off the stats thread */
_stats_running = 1;
_stats_thread_id = thread_create("Stats Thread", _stats_thread, NULL, THREAD_ATTACHED);
_stats_thread_id = thread_create("Stats Thread", _stats_thread, NULL, igloo_THREAD_ATTACHED);
}
void stats_shutdown(void)
@ -157,11 +157,11 @@ void stats_shutdown(void)
thread_mutex_lock(&_stats_mutex);
_stats_running = 0;
thread_mutex_unlock(&_stats_mutex);
thread_join(_stats_thread_id);
igloo_thread_join(_stats_thread_id);
/* wait for other threads to shut down */
do {
thread_sleep(300000);
igloo_thread_sleep(300000);
thread_mutex_lock(&_stats_mutex);
n = _stats_threads;
thread_mutex_unlock(&_stats_mutex);
@ -171,11 +171,11 @@ void stats_shutdown(void)
/* free the queues */
/* destroy the queue mutexes */
thread_mutex_destroy(&_global_event_mutex);
igloo_thread_mutex_destroy(&_global_event_mutex);
thread_mutex_destroy(&_stats_mutex);
avl_tree_free(_stats.source_tree, _free_source_stats);
avl_tree_free(_stats.global_tree, _free_stats);
igloo_thread_mutex_destroy(&_stats_mutex);
igloo_avl_tree_free(_stats.source_tree, _free_source_stats);
igloo_avl_tree_free(_stats.global_tree, _free_stats);
while (1)
{
@ -365,12 +365,12 @@ void stats_event_dec(const char *source, const char *name)
}
/* note: you must call this function only when you have exclusive access
** to the avl_tree
** to the igloo_avl_tree
*/
static stats_node_t *_find_node(avl_tree *stats_tree, const char *name)
static stats_node_t *_find_node(igloo_avl_tree *stats_tree, const char *name)
{
stats_node_t *stats;
avl_node *node;
igloo_avl_node *node;
int cmp;
/* get the root node */
@ -392,12 +392,12 @@ static stats_node_t *_find_node(avl_tree *stats_tree, const char *name)
}
/* note: you must call this function only when you have exclusive access
** to the avl_tree
** to the igloo_avl_tree
*/
static stats_source_t *_find_source(avl_tree *source_tree, const char *source)
static stats_source_t *_find_source(igloo_avl_tree *source_tree, const char *source)
{
stats_source_t *stats;
avl_node *node;
igloo_avl_node *node;
int cmp;
/* get the root node */
@ -498,7 +498,7 @@ static void process_global_event (stats_event_t *event)
/* we're deleting */
node = _find_node(_stats.global_tree, event->name);
if (node != NULL)
avl_delete(_stats.global_tree, (void *)node, _free_stats);
igloo_avl_delete(_stats.global_tree, (void *)node, _free_stats);
return;
}
node = _find_node(_stats.global_tree, event->name);
@ -513,7 +513,7 @@ static void process_global_event (stats_event_t *event)
node->name = (char *)strdup(event->name);
node->value = (char *)strdup(event->value);
avl_insert(_stats.global_tree, (void *)node);
igloo_avl_insert(_stats.global_tree, (void *)node);
}
}
@ -530,13 +530,13 @@ static void process_source_event (stats_event_t *event)
return;
ICECAST_LOG_DEBUG("new source stat %s", event->source);
snode->source = (char *)strdup(event->source);
snode->stats_tree = avl_tree_new(_compare_stats, NULL);
snode->stats_tree = igloo_avl_tree_new(_compare_stats, NULL);
if (event->action == STATS_EVENT_HIDDEN)
snode->hidden = 1;
else
snode->hidden = 0;
avl_insert(_stats.source_tree, (void *) snode);
igloo_avl_insert(_stats.source_tree, (void *) snode);
}
if (event->name)
{
@ -554,14 +554,14 @@ static void process_source_event (stats_event_t *event)
node->value = (char *)strdup(event->value);
node->hidden = snode->hidden;
avl_insert(snode->stats_tree, (void *)node);
igloo_avl_insert(snode->stats_tree, (void *)node);
}
return;
}
if (event->action == STATS_EVENT_REMOVE)
{
ICECAST_LOG_DEBUG("delete node %s", event->name);
avl_delete(snode->stats_tree, (void *)node, _free_stats);
igloo_avl_delete(snode->stats_tree, (void *)node, _free_stats);
return;
}
modify_node_event (node, event);
@ -569,7 +569,7 @@ static void process_source_event (stats_event_t *event)
}
if (event->action == STATS_EVENT_HIDDEN)
{
avl_node *node = avl_get_first (snode->stats_tree);
igloo_avl_node *node = igloo_avl_get_first (snode->stats_tree);
if (event->value)
snode->hidden = 1;
@ -579,14 +579,14 @@ static void process_source_event (stats_event_t *event)
{
stats_node_t *stats = (stats_node_t*)node->key;
stats->hidden = snode->hidden;
node = avl_get_next (node);
node = igloo_avl_get_next (node);
}
return;
}
if (event->action == STATS_EVENT_REMOVE)
{
ICECAST_LOG_DEBUG("delete source node %s", event->source);
avl_delete(_stats.source_tree, (void *)snode, _free_source_stats);
igloo_avl_delete(_stats.source_tree, (void *)snode, _free_source_stats);
}
}
@ -742,7 +742,7 @@ static void *_stats_thread(void *arg)
thread_mutex_unlock(&_global_event_mutex);
}
thread_sleep(300000);
igloo_thread_sleep(300000);
}
return NULL;
@ -839,7 +839,7 @@ static inline void __add_authstack (auth_stack_t *stack, xmlNodePtr parent) {
}
}
static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, int hidden, client_t *client) {
avl_node *avlnode;
igloo_avl_node *avlnode;
xmlNodePtr ret = NULL;
ice_config_t *config;
@ -849,16 +849,16 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i
thread_mutex_lock(&_stats_mutex);
/* general stats first */
avlnode = avl_get_first(_stats.global_tree);
avlnode = igloo_avl_get_first(_stats.global_tree);
while (avlnode) {
stats_node_t *stat = avlnode->key;
if (stat->hidden <= hidden)
xmlNewTextChild (root, NULL, XMLSTR(stat->name), XMLSTR(stat->value));
avlnode = avl_get_next (avlnode);
avlnode = igloo_avl_get_next (avlnode);
}
/* now per mount stats */
avlnode = avl_get_first(_stats.source_tree);
avlnode = igloo_avl_get_first(_stats.source_tree);
while (avlnode) {
stats_source_t *source = (stats_source_t *)avlnode->key;
@ -871,7 +871,7 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i
mount_proxy *mountproxy;
int i;
avl_node *avlnode2 = avl_get_first (source->stats_tree);
igloo_avl_node *avlnode2 = igloo_avl_get_first (source->stats_tree);
xmlNodePtr xmlnode = xmlNewTextChild (root, NULL, XMLSTR("source"), NULL);
xmlSetProp (xmlnode, XMLSTR("mount"), XMLSTR(source->source));
@ -887,11 +887,11 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i
} else {
xmlNewTextChild (xmlnode, NULL, XMLSTR(stat->name), XMLSTR(stat->value));
}
avlnode2 = avl_get_next (avlnode2);
avlnode2 = igloo_avl_get_next (avlnode2);
}
avl_tree_rlock(global.source_tree);
igloo_avl_tree_rlock(global.source_tree);
source_real = source_find_mount_raw(source->source);
if (source_real) {
history = playlist_render_xspf(source_real->history);
@ -904,14 +904,14 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i
__add_metadata(metadata, source_real->format->vc.user_comments[i]);
}
}
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
config = config_get_config();
mountproxy = config_find_mount(config, source->source, MOUNT_TYPE_NORMAL);
__add_authstack(mountproxy->authstack, xmlnode);
config_release_config();
}
avlnode = avl_get_next (avlnode);
avlnode = igloo_avl_get_next (avlnode);
}
thread_mutex_unlock(&_stats_mutex);
return ret;
@ -925,8 +925,8 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i
*/
static void _register_listener (event_listener_t *listener)
{
avl_node *node;
avl_node *node2;
igloo_avl_node *node;
igloo_avl_node *node2;
stats_event_t *event;
stats_source_t *source;
@ -935,27 +935,27 @@ static void _register_listener (event_listener_t *listener)
/* first we fill our queue with the current stats */
/* start with the global stats */
node = avl_get_first(_stats.global_tree);
node = igloo_avl_get_first(_stats.global_tree);
while (node) {
event = _make_event_from_node((stats_node_t *) node->key, NULL);
_add_event_to_queue(event, &listener->queue);
node = avl_get_next(node);
node = igloo_avl_get_next(node);
}
/* now the stats for each source */
node = avl_get_first(_stats.source_tree);
node = igloo_avl_get_first(_stats.source_tree);
while (node) {
source = (stats_source_t *)node->key;
node2 = avl_get_first(source->stats_tree);
node2 = igloo_avl_get_first(source->stats_tree);
while (node2) {
event = _make_event_from_node((stats_node_t *)node2->key, source->source);
_add_event_to_queue (event, &listener->queue);
node2 = avl_get_next(node2);
node2 = igloo_avl_get_next(node2);
}
node = avl_get_next(node);
node = igloo_avl_get_next(node);
}
/* now we register to receive future event notices */
@ -1003,7 +1003,7 @@ void *stats_connection(void *arg)
_free_event(event);
continue;
}
thread_sleep (500000);
igloo_thread_sleep (500000);
}
thread_mutex_lock(&_stats_mutex);
@ -1012,7 +1012,7 @@ void *stats_connection(void *arg)
stats_event_args (NULL, "stats", "%d", _stats_threads);
thread_mutex_unlock(&_stats_mutex);
thread_mutex_destroy (&listener.mutex);
igloo_thread_mutex_destroy (&listener.mutex);
client_destroy (client);
ICECAST_LOG_INFO("stats client finished");
@ -1030,7 +1030,7 @@ void stats_callback (client_t *client, void *notused)
return;
}
client_set_queue (client, NULL);
thread_create("Stats Connection", stats_connection, (void *)client, THREAD_DETACHED);
thread_create("Stats Connection", stats_connection, (void *)client, igloo_THREAD_DETACHED);
}
@ -1046,7 +1046,7 @@ void stats_transform_xslt(client_t *client)
{
xmlDocPtr doc;
char *xslpath = util_get_path_from_normalised_uri(client->uri);
const char *mount = httpp_get_param(client->parser, "mount");
const char *mount = igloo_httpp_get_param(client->parser, "mount");
doc = stats_get_xml(0, mount, client);
@ -1096,10 +1096,10 @@ xmlDocPtr stats_get_xml(int show_hidden, const char *show_mount, client_t *clien
node = _dump_stats_to_doc(node, show_mount, show_hidden, client);
if (show_mount && node) {
avl_tree_rlock(global.source_tree);
igloo_avl_tree_rlock(global.source_tree);
source = source_find_mount_raw(show_mount);
admin_add_listeners_to_mount(source, node, client->mode);
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
}
return doc;
@ -1139,7 +1139,7 @@ static int _free_stats(void *key)
static int _free_source_stats(void *key)
{
stats_source_t *node = (stats_source_t *)key;
avl_tree_free(node->stats_tree, _free_stats);
igloo_avl_tree_free(node->stats_tree, _free_stats);
free(node->source);
free(node);
@ -1158,14 +1158,14 @@ static void _free_event(stats_event_t *event)
refbuf_t *stats_get_streams (void)
{
#define STREAMLIST_BLKSIZE 4096
avl_node *node;
igloo_avl_node *node;
unsigned int remaining = STREAMLIST_BLKSIZE;
refbuf_t *start = refbuf_new (remaining), *cur = start;
char *buffer = cur->data;
/* now the stats for each source */
thread_mutex_lock (&_stats_mutex);
node = avl_get_first(_stats.source_tree);
node = igloo_avl_get_first(_stats.source_tree);
while (node)
{
int ret;
@ -1188,7 +1188,7 @@ refbuf_t *stats_get_streams (void)
remaining -= ret;
}
}
node = avl_get_next(node);
node = igloo_avl_get_next(node);
}
thread_mutex_unlock(&_stats_mutex);
cur->len = STREAMLIST_BLKSIZE - remaining;
@ -1203,10 +1203,10 @@ refbuf_t *stats_get_streams (void)
*/
void stats_clear_virtual_mounts (void)
{
avl_node *snode;
igloo_avl_node *snode;
thread_mutex_lock (&_stats_mutex);
snode = avl_get_first(_stats.source_tree);
snode = igloo_avl_get_first(_stats.source_tree);
while (snode)
{
stats_source_t *src = (stats_source_t *)snode->key;
@ -1215,13 +1215,13 @@ void stats_clear_virtual_mounts (void)
if (source == NULL)
{
/* no source_t is reserved so remove them now */
snode = avl_get_next (snode);
snode = igloo_avl_get_next (snode);
ICECAST_LOG_DEBUG("releasing %s stats", src->source);
avl_delete (_stats.source_tree, src, _free_source_stats);
igloo_avl_delete (_stats.source_tree, src, _free_source_stats);
continue;
}
snode = avl_get_next (snode);
snode = igloo_avl_get_next (snode);
}
thread_mutex_unlock (&_stats_mutex);
}

View File

@ -43,12 +43,12 @@ typedef struct _stats_source_tag
{
char *source;
int hidden;
avl_tree *stats_tree;
igloo_avl_tree *stats_tree;
} stats_source_t;
typedef struct _stats_tag
{
avl_tree *global_tree;
igloo_avl_tree *global_tree;
/* global stats
start_time
@ -60,7 +60,7 @@ typedef struct _stats_tag
total_source_connections
*/
avl_tree *source_tree;
igloo_avl_tree *source_tree;
/* stats by source, and for stats
start_time

View File

@ -201,7 +201,7 @@ void tls_set_incoming(tls_t *tls)
SSL_set_accept_state(tls->ssl);
}
void tls_set_socket(tls_t *tls, sock_t sock)
void tls_set_socket(tls_t *tls, igloo_sock_t sock)
{
if (!tls)
return;
@ -289,7 +289,7 @@ void tls_unref(tls_t *tls)
void tls_set_incoming(tls_t *tls)
{
}
void tls_set_socket(tls_t *tls, sock_t sock)
void tls_set_socket(tls_t *tls, igloo_sock_t sock)
{
}

View File

@ -9,7 +9,7 @@
#ifndef __TLS_H__
#define __TLS_H__
#include <permafrost/sock.h>
#include <igloo/sock.h>
/* Do we have TLS Support? */
#if defined(HAVE_OPENSSL)
@ -35,7 +35,7 @@ void tls_ref(tls_t *tls);
void tls_unref(tls_t *tls);
void tls_set_incoming(tls_t *tls);
void tls_set_socket(tls_t *tls, sock_t sock);
void tls_set_socket(tls_t *tls, igloo_sock_t sock);
int tls_want_io(tls_t *tls);

View File

@ -39,8 +39,8 @@
#include <windows.h>
#endif
#include <permafrost/sock.h>
#include <permafrost/thread.h>
#include <igloo/sock.h>
#include <igloo/thread.h>
#include "util.h"
#include "compat.h"
@ -118,7 +118,7 @@ static const signed char base64decode[256] = {
* 0 if no activity occurs
* < 0 for error.
*/
int util_timed_wait_for_fd(sock_t fd, int timeout)
int util_timed_wait_for_fd(igloo_sock_t fd, int timeout)
{
#ifdef HAVE_POLL
struct pollfd ufds;
@ -144,7 +144,7 @@ int util_timed_wait_for_fd(sock_t fd, int timeout)
#endif
}
int util_read_header(sock_t sock, char *buff, unsigned long len, int entire)
int util_read_header(igloo_sock_t sock, char *buff, unsigned long len, int entire)
{
int read_bytes, ret;
unsigned long pos;
@ -1419,7 +1419,7 @@ char *util_dict_urlencode(util_dict *dict, char delim)
#ifndef HAVE_LOCALTIME_R
struct tm *localtime_r (const time_t *timep, struct tm *result)
{
static mutex_t localtime_lock;
static igloo_mutex_t localtime_lock;
static int initialised = 0;
struct tm *tm;

View File

@ -17,7 +17,7 @@
/* for FILE* */
#include <stdio.h>
#include <permafrost/sock.h>
#include <igloo/sock.h>
#include "icecasttypes.h"
#define UNKNOWN_CONTENT 0
@ -29,8 +29,8 @@
#define MAX_LINE_LEN 512
int util_timed_wait_for_fd(sock_t fd, int timeout);
int util_read_header(sock_t sock, char *buff, unsigned long len, int entire);
int util_timed_wait_for_fd(igloo_sock_t fd, int timeout);
int util_read_header(igloo_sock_t sock, char *buff, unsigned long len, int entire);
int util_check_valid_extension(const char *uri);
char *util_get_extension(const char *path);
char *util_get_path_from_uri(char *uri);

View File

@ -41,10 +41,10 @@
#define snprintf _snprintf
#endif
#include <permafrost/thread.h>
#include <permafrost/avl.h>
#include <permafrost/httpp.h>
#include <permafrost/sock.h>
#include <igloo/thread.h>
#include <igloo/avl.h>
#include <igloo/httpp.h>
#include <igloo/sock.h>
#include "xslt.h"
#include "refbuf.h"
@ -96,7 +96,7 @@ int xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len, xmlDocPtr r
#define CACHESIZE 3
static stylesheet_cache_t cache[CACHESIZE];
static mutex_t xsltlock;
static igloo_mutex_t xsltlock;
/* Reference to the original xslt loader func */
static xsltDocLoaderFunc xslt_loader;
@ -118,7 +118,7 @@ void xslt_shutdown(void) {
xslt_clear_cache();
thread_mutex_destroy (&xsltlock);
igloo_thread_mutex_destroy (&xsltlock);
xmlCleanupParser();
xsltCleanupGlobals();
if (admin_URI)

View File

@ -20,7 +20,7 @@
#include <string.h>
#include <stdlib.h>
#include <permafrost/thread.h>
#include <igloo/thread.h>
#include "yp.h"
#include "global.h"
@ -82,14 +82,14 @@ typedef struct ypdata_tag
} ypdata_t;
static rwlock_t yp_lock;
static mutex_t yp_pending_lock;
static igloo_rwlock_t yp_lock;
static igloo_mutex_t yp_pending_lock;
static volatile struct yp_server *active_yps = NULL, *pending_yps = NULL;
static volatile int yp_update = 0;
static int yp_running;
static time_t now;
static thread_type *yp_thread;
static igloo_thread_type *yp_thread;
static volatile unsigned client_limit = 0;
static volatile char *server_version = NULL;
@ -286,7 +286,7 @@ void yp_initialize(void)
yp_recheck_config (config);
config_release_config ();
yp_thread = thread_create("YP Touch Thread", yp_update_thread,
(void *)NULL, THREAD_ATTACHED);
(void *)NULL, igloo_THREAD_ATTACHED);
}
@ -645,7 +645,7 @@ static void check_servers (void)
/* add new server entries */
while (pending_yps)
{
avl_node *node;
igloo_avl_node *node;
server = (struct yp_server *)pending_yps;
pending_yps = server->next;
@ -655,8 +655,8 @@ static void check_servers (void)
active_yps = server;
/* new YP server configured, need to populate with existing sources */
avl_tree_rlock (global.source_tree);
node = avl_get_first (global.source_tree);
igloo_avl_tree_rlock (global.source_tree);
node = igloo_avl_get_first (global.source_tree);
while (node)
{
ypdata_t *yp;
@ -670,9 +670,9 @@ static void check_servers (void)
yp->next = server->mounts;
server->mounts = yp;
}
node = avl_get_next (node);
node = igloo_avl_get_next (node);
}
avl_tree_unlock (global.source_tree);
igloo_avl_tree_unlock (global.source_tree);
}
}
@ -732,7 +732,7 @@ static void *yp_update_thread(void *arg)
while (running) {
struct yp_server *server;
thread_sleep (200000);
igloo_thread_sleep (200000);
/* do the YP communication */
thread_rwlock_rlock (&yp_lock);
@ -762,8 +762,8 @@ static void *yp_update_thread(void *arg)
running = yp_running;
thread_rwlock_unlock(&yp_lock);
}
thread_rwlock_destroy (&yp_lock);
thread_mutex_destroy (&yp_pending_lock);
igloo_thread_rwlock_destroy (&yp_lock);
igloo_thread_mutex_destroy (&yp_pending_lock);
/* free server and ypdata left */
while (active_yps)
{
@ -995,7 +995,7 @@ void yp_shutdown (void)
thread_rwlock_unlock(&yp_lock);
if (yp_thread)
thread_join (yp_thread);
igloo_thread_join (yp_thread);
free ((char*)server_version);
server_version = NULL;
ICECAST_LOG_INFO("YP thread down");