1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Fix: Corrected namespace for threading part

This commit is contained in:
Philipp Schafft 2018-11-01 09:22:15 +00:00
parent aade92a236
commit 6f40700abd
21 changed files with 335 additions and 335 deletions

View File

@ -56,9 +56,9 @@ static volatile unsigned long _current_id = 0;
static unsigned long _next_auth_id(void) {
unsigned long id;
thread_mutex_lock(&_auth_lock);
igloo_thread_mutex_lock(&_auth_lock);
id = _current_id++;
thread_mutex_unlock(&_auth_lock);
igloo_thread_mutex_unlock(&_auth_lock);
return id;
}
@ -169,12 +169,12 @@ static void queue_auth_client (auth_client *auth_user)
if (auth->immediate) {
__handle_auth_client(auth, auth_user);
} else {
thread_mutex_lock (&auth->lock);
igloo_thread_mutex_lock (&auth->lock);
*auth->tailp = auth_user;
auth->tailp = &auth_user->next;
auth->pending_count++;
ICECAST_LOG_INFO("auth on %s has %d pending", auth->mount, auth->pending_count);
thread_mutex_unlock (&auth->lock);
igloo_thread_mutex_unlock (&auth->lock);
}
}
@ -188,21 +188,21 @@ void auth_release (auth_t *authenticator) {
if (authenticator == NULL)
return;
thread_mutex_lock(&authenticator->lock);
igloo_thread_mutex_lock(&authenticator->lock);
authenticator->refcount--;
ICECAST_LOG_DEBUG("...refcount on auth_t %s is now %d", authenticator->mount, (int)authenticator->refcount);
if (authenticator->refcount)
{
thread_mutex_unlock(&authenticator->lock);
igloo_thread_mutex_unlock(&authenticator->lock);
return;
}
/* cleanup auth thread attached to this auth */
if (authenticator->running) {
authenticator->running = 0;
thread_mutex_unlock(&authenticator->lock);
igloo_thread_mutex_unlock(&authenticator->lock);
igloo_thread_join(authenticator->thread);
thread_mutex_lock(&authenticator->lock);
igloo_thread_mutex_lock(&authenticator->lock);
}
if (authenticator->free)
@ -213,7 +213,7 @@ void auth_release (auth_t *authenticator) {
xmlFree (authenticator->role);
if (authenticator->management_url)
xmlFree (authenticator->management_url);
thread_mutex_unlock(&authenticator->lock);
igloo_thread_mutex_unlock(&authenticator->lock);
igloo_thread_mutex_destroy(&authenticator->lock);
if (authenticator->mount)
free(authenticator->mount);
@ -234,10 +234,10 @@ void auth_addref (auth_t *authenticator) {
if (authenticator == NULL)
return;
thread_mutex_lock (&authenticator->lock);
igloo_thread_mutex_lock (&authenticator->lock);
authenticator->refcount++;
ICECAST_LOG_DEBUG("...refcount on auth_t %s is now %d", authenticator->mount, (int)authenticator->refcount);
thread_mutex_unlock (&authenticator->lock);
igloo_thread_mutex_unlock (&authenticator->lock);
}
static void auth_client_free (auth_client *auth_user)
@ -402,10 +402,10 @@ static void *auth_run_thread (void *arg)
ICECAST_LOG_INFO("Authentication thread started");
while (1) {
thread_mutex_lock(&auth->lock);
igloo_thread_mutex_lock(&auth->lock);
if (!auth->running) {
thread_mutex_unlock(&auth->lock);
igloo_thread_mutex_unlock(&auth->lock);
break;
}
@ -416,7 +416,7 @@ static void *auth_run_thread (void *arg)
auth_user = (auth_client*)auth->head;
if (auth_user == NULL)
{
thread_mutex_unlock (&auth->lock);
igloo_thread_mutex_unlock (&auth->lock);
continue;
}
ICECAST_LOG_DEBUG("%d client(s) pending on %s (role %s)", auth->pending_count, auth->mount, auth->role);
@ -424,14 +424,14 @@ static void *auth_run_thread (void *arg)
if (auth->head == NULL)
auth->tailp = &auth->head;
auth->pending_count--;
thread_mutex_unlock(&auth->lock);
igloo_thread_mutex_unlock(&auth->lock);
auth_user->next = NULL;
__handle_auth_client(auth, auth_user);
continue;
} else {
thread_mutex_unlock(&auth->lock);
igloo_thread_mutex_unlock(&auth->lock);
}
igloo_thread_sleep (150000);
}
@ -806,7 +806,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
if (auth == NULL)
return NULL;
thread_mutex_create(&auth->lock);
igloo_thread_mutex_create(&auth->lock);
auth->refcount = 1;
auth->id = _next_auth_id();
auth->type = (char*)xmlGetProp(node, XMLSTR("type"));
@ -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, igloo_THREAD_ATTACHED);
auth->thread = igloo_thread_create("auth thread", auth_run_thread, auth, igloo_THREAD_ATTACHED);
}
}
}
@ -1022,7 +1022,7 @@ auth_alter_t auth_str2alter(const char *str)
void auth_initialise (void)
{
thread_mutex_create(&_auth_lock);
igloo_thread_mutex_create(&_auth_lock);
}
void auth_shutdown (void)
@ -1061,9 +1061,9 @@ void auth_stack_release(auth_stack_t *stack) {
if (!stack)
return;
thread_mutex_lock(&stack->lock);
igloo_thread_mutex_lock(&stack->lock);
stack->refcount--;
thread_mutex_unlock(&stack->lock);
igloo_thread_mutex_unlock(&stack->lock);
if (stack->refcount)
return;
@ -1077,19 +1077,19 @@ void auth_stack_release(auth_stack_t *stack) {
void auth_stack_addref(auth_stack_t *stack) {
if (!stack)
return;
thread_mutex_lock(&stack->lock);
igloo_thread_mutex_lock(&stack->lock);
stack->refcount++;
thread_mutex_unlock(&stack->lock);
igloo_thread_mutex_unlock(&stack->lock);
}
int auth_stack_next(auth_stack_t **stack) {
auth_stack_t *next;
if (!stack || !*stack)
return -1;
thread_mutex_lock(&(*stack)->lock);
igloo_thread_mutex_lock(&(*stack)->lock);
next = (*stack)->next;
auth_stack_addref(next);
thread_mutex_unlock(&(*stack)->lock);
igloo_thread_mutex_unlock(&(*stack)->lock);
auth_stack_release(*stack);
*stack = next;
if (!next)
@ -1107,7 +1107,7 @@ int auth_stack_push(auth_stack_t **stack, auth_t *auth) {
if (!next) {
return -1;
}
thread_mutex_create(&next->lock);
igloo_thread_mutex_create(&next->lock);
next->refcount = 1;
next->auth = auth;
auth_addref(auth);
@ -1129,21 +1129,21 @@ int auth_stack_append(auth_stack_t *stack, auth_stack_t *tail) {
return -1;
auth_stack_addref(cur = stack);
thread_mutex_lock(&cur->lock);
igloo_thread_mutex_lock(&cur->lock);
while (1) {
next = cur->next;
if (!cur->next)
break;
auth_stack_addref(next);
thread_mutex_unlock(&cur->lock);
igloo_thread_mutex_unlock(&cur->lock);
auth_stack_release(cur);
cur = next;
thread_mutex_lock(&cur->lock);
igloo_thread_mutex_lock(&cur->lock);
}
auth_stack_addref(cur->next = tail);
thread_mutex_unlock(&cur->lock);
igloo_thread_mutex_unlock(&cur->lock);
auth_stack_release(cur);
return 0;
@ -1155,9 +1155,9 @@ auth_t *auth_stack_get(auth_stack_t *stack) {
if (!stack)
return NULL;
thread_mutex_lock(&stack->lock);
igloo_thread_mutex_lock(&stack->lock);
auth_addref(auth = stack->auth);
thread_mutex_unlock(&stack->lock);
igloo_thread_mutex_unlock(&stack->lock);
return auth;
}

View File

@ -121,10 +121,10 @@ static void htpasswd_recheckfile(htpasswd_auth_state *htpasswd)
ICECAST_LOG_WARN("failed to check status of %s", htpasswd->filename);
/* Create a dummy users tree for things to use later */
thread_rwlock_wlock (&htpasswd->file_rwlock);
igloo_thread_rwlock_wlock (&htpasswd->file_rwlock);
if(!htpasswd->users)
htpasswd->users = igloo_avl_tree_new(compare_users, NULL);
thread_rwlock_unlock (&htpasswd->file_rwlock);
igloo_thread_rwlock_unlock (&htpasswd->file_rwlock);
return;
}
@ -167,11 +167,11 @@ static void htpasswd_recheckfile(htpasswd_auth_state *htpasswd)
}
fclose (passwdfile);
thread_rwlock_wlock (&htpasswd->file_rwlock);
igloo_thread_rwlock_wlock (&htpasswd->file_rwlock);
if (htpasswd->users)
igloo_avl_tree_free (htpasswd->users, _free_user);
htpasswd->users = new_users;
thread_rwlock_unlock (&htpasswd->file_rwlock);
igloo_thread_rwlock_unlock (&htpasswd->file_rwlock);
}
@ -197,13 +197,13 @@ static auth_result htpasswd_auth (auth_client *auth_user)
return AUTH_NOMATCH;
}
thread_rwlock_rlock (&htpasswd->file_rwlock);
igloo_thread_rwlock_rlock (&htpasswd->file_rwlock);
entry.name = client->username;
if (igloo_avl_get_by_key (htpasswd->users, &entry, &result) == 0) {
htpasswd_user *found = result;
char *hashed_pw;
thread_rwlock_unlock (&htpasswd->file_rwlock);
igloo_thread_rwlock_unlock (&htpasswd->file_rwlock);
hashed_pw = get_hash (client->password, strlen (client->password));
if (strcmp (found->pass, hashed_pw) == 0) {
free (hashed_pw);
@ -214,7 +214,7 @@ static auth_result htpasswd_auth (auth_client *auth_user)
return AUTH_FAILED;
}
ICECAST_LOG_DEBUG("no such username: %s", client->username);
thread_rwlock_unlock (&htpasswd->file_rwlock);
igloo_thread_rwlock_unlock (&htpasswd->file_rwlock);
return AUTH_NOMATCH;
}
@ -248,7 +248,7 @@ int auth_get_htpasswd_auth (auth_t *authenticator, config_options_t *options)
authenticator->state = state;
thread_rwlock_create(&state->file_rwlock);
igloo_thread_rwlock_create(&state->file_rwlock);
htpasswd_recheckfile(state);
return 0;
@ -275,18 +275,18 @@ static auth_result htpasswd_adduser (auth_t *auth, const char *username, const c
return AUTH_FAILED;
}
thread_rwlock_wlock (&state->file_rwlock);
igloo_thread_rwlock_wlock (&state->file_rwlock);
entry.name = (char*)username;
if (igloo_avl_get_by_key (state->users, &entry, &result) == 0) {
thread_rwlock_unlock (&state->file_rwlock);
igloo_thread_rwlock_unlock (&state->file_rwlock);
return AUTH_USEREXISTS;
}
passwdfile = fopen(state->filename, "ab");
if (passwdfile == NULL) {
thread_rwlock_unlock (&state->file_rwlock);
igloo_thread_rwlock_unlock (&state->file_rwlock);
ICECAST_LOG_WARN("Failed to open authentication database \"%s\": %s",
state->filename, strerror(errno));
return AUTH_FAILED;
@ -299,7 +299,7 @@ static auth_result htpasswd_adduser (auth_t *auth, const char *username, const c
}
fclose(passwdfile);
thread_rwlock_unlock (&state->file_rwlock);
igloo_thread_rwlock_unlock (&state->file_rwlock);
return AUTH_USERADDED;
}
@ -328,13 +328,13 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
return AUTH_FAILED;
}
thread_rwlock_wlock (&state->file_rwlock);
igloo_thread_rwlock_wlock (&state->file_rwlock);
passwdfile = fopen(state->filename, "rb");
if(passwdfile == NULL) {
ICECAST_LOG_WARN("Failed to open authentication database \"%s\": %s",
state->filename, strerror(errno));
thread_rwlock_unlock (&state->file_rwlock);
igloo_thread_rwlock_unlock (&state->file_rwlock);
return AUTH_FAILED;
}
tmpfile_len = strlen(state->filename) + 6;
@ -344,7 +344,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
ICECAST_LOG_WARN("temp file \"%s\" exists, rejecting operation", tmpfile);
free (tmpfile);
fclose (passwdfile);
thread_rwlock_unlock (&state->file_rwlock);
igloo_thread_rwlock_unlock (&state->file_rwlock);
return AUTH_FAILED;
}
@ -355,7 +355,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
tmpfile, strerror(errno));
fclose(passwdfile);
free(tmpfile);
thread_rwlock_unlock (&state->file_rwlock);
igloo_thread_rwlock_unlock (&state->file_rwlock);
return AUTH_FAILED;
}
@ -395,7 +395,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
}
}
free(tmpfile);
thread_rwlock_unlock(&state->file_rwlock);
igloo_thread_rwlock_unlock(&state->file_rwlock);
htpasswd_recheckfile(state);
return AUTH_USERDELETED;
@ -422,7 +422,7 @@ static auth_result htpasswd_userlist(auth_t *auth, xmlNodePtr srcnode)
return AUTH_FAILED;
}
thread_rwlock_rlock(&state->file_rwlock);
igloo_thread_rwlock_rlock(&state->file_rwlock);
node = igloo_avl_get_first(state->users);
while (node) {
htpasswd_user *user = (htpasswd_user *)node->key;
@ -430,7 +430,7 @@ static auth_result htpasswd_userlist(auth_t *auth, xmlNodePtr srcnode)
xmlNewTextChild(newnode, NULL, XMLSTR("username"), XMLSTR(user->name));
node = igloo_avl_get_next(node);
}
thread_rwlock_unlock(&state->file_rwlock);
igloo_thread_rwlock_unlock(&state->file_rwlock);
return AUTH_OK;
}

View File

@ -231,8 +231,8 @@ char * config_href_to_id(const char *href)
static void create_locks(void)
{
thread_mutex_create(&_locks.relay_lock);
thread_rwlock_create(&_locks.config_lock);
igloo_thread_mutex_create(&_locks.relay_lock);
igloo_thread_rwlock_create(&_locks.config_lock);
}
static void release_locks(void)
@ -692,12 +692,12 @@ void config_clear(ice_config_t *c)
while ((c->listen_sock = config_clear_listener(c->listen_sock)));
thread_mutex_lock(&(_locks.relay_lock));
igloo_thread_mutex_lock(&(_locks.relay_lock));
for (i = 0; i < c->relay_length; i++) {
relay_config_free(c->relay[i]);
}
free(c->relay);
thread_mutex_unlock(&(_locks.relay_lock));
igloo_thread_mutex_unlock(&(_locks.relay_lock));
mount = c->mounts;
while (mount) {
@ -821,18 +821,18 @@ ice_config_locks *config_locks(void)
void config_release_config(void)
{
thread_rwlock_unlock(&(_locks.config_lock));
igloo_thread_rwlock_unlock(&(_locks.config_lock));
}
ice_config_t *config_get_config(void)
{
thread_rwlock_rlock(&(_locks.config_lock));
igloo_thread_rwlock_rlock(&(_locks.config_lock));
return &_current_configuration;
}
ice_config_t *config_grab_config(void)
{
thread_rwlock_wlock(&(_locks.config_lock));
igloo_thread_rwlock_wlock(&(_locks.config_lock));
return &_current_configuration;
}

View File

@ -414,13 +414,13 @@ void client_send_204(client_t *client)
/* We get a source_t* here as this is likely a reply to OPTIONS and we want
* to have as much infos as possible in that case.
*/
avl_tree_rlock(global.source_tree);
igloo_avl_tree_rlock(global.source_tree);
source = source_find_mount_raw(client->uri);
ret = util_http_build_header(client->refbuf->data, PER_CLIENT_REFBUF_SIZE, 0,
0, 204, NULL,
NULL, NULL,
NULL, source, client);
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
snprintf(client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
"Content-Length: 0\r\n\r\n");

View File

@ -115,9 +115,9 @@ void connection_initialize(void)
return;
igloo_thread_spin_create (&_connection_lock);
thread_mutex_create(&move_clients_mutex);
thread_rwlock_create(&_source_shutdown_rwlock);
thread_cond_create(&global.shutdown_cond);
igloo_thread_mutex_create(&move_clients_mutex);
igloo_thread_rwlock_create(&_source_shutdown_rwlock);
igloo_thread_cond_create(&global.shutdown_cond);
_req_queue = NULL;
_req_queue_tail = &_req_queue;
_con_queue = NULL;
@ -715,11 +715,11 @@ void connection_accept_loop(void)
}
/* Give all the other threads notification to shut down */
thread_cond_broadcast(&global.shutdown_cond);
igloo_thread_cond_broadcast(&global.shutdown_cond);
/* wait for all the sources to shutdown */
thread_rwlock_wlock(&_source_shutdown_rwlock);
thread_rwlock_unlock(&_source_shutdown_rwlock);
igloo_thread_rwlock_wlock(&_source_shutdown_rwlock);
igloo_thread_rwlock_unlock(&_source_shutdown_rwlock);
}
@ -1069,14 +1069,14 @@ static void _handle_get_request(client_t *client) {
static void _handle_delete_request(client_t *client) {
source_t *source;
avl_tree_wlock(global.source_tree);
igloo_avl_tree_wlock(global.source_tree);
source = source_find_mount_raw(client->uri);
if (source) {
source->running = 0;
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
client_send_204(client);
} else {
avl_tree_unlock(global.source_tree);
igloo_avl_tree_unlock(global.source_tree);
client_send_error_by_id(client, ICECAST_ERROR_CON_UNKNOWN_REQUEST);
}
}

View File

@ -36,9 +36,9 @@ static igloo_thread_type *event_thread = NULL;
static void event_addref(event_t *event) {
if (!event)
return;
thread_mutex_lock(&event_lock);
igloo_thread_mutex_lock(&event_lock);
event->refcount++;
thread_mutex_unlock(&event_lock);
igloo_thread_mutex_unlock(&event_lock);
}
static void event_release(event_t *event) {
@ -48,10 +48,10 @@ static void event_release(event_t *event) {
if (!event)
return;
thread_mutex_lock(&event_lock);
igloo_thread_mutex_lock(&event_lock);
event->refcount--;
if (event->refcount) {
thread_mutex_unlock(&event_lock);
igloo_thread_mutex_unlock(&event_lock);
return;
}
@ -66,7 +66,7 @@ static void event_release(event_t *event) {
free(event->client_useragent);
to_free = event->next;
free(event);
thread_mutex_unlock(&event_lock);
igloo_thread_mutex_unlock(&event_lock);
if (to_free)
event_release(to_free);
@ -144,7 +144,7 @@ static inline void _try_registrations(event_registration_t *er, event_t *event)
if (!er)
return;
thread_mutex_lock(&er->lock);
igloo_thread_mutex_lock(&er->lock);
while (1) {
/* try registration */
_try_event(er, event);
@ -153,14 +153,14 @@ static inline void _try_registrations(event_registration_t *er, event_t *event)
if (er->next) {
event_registration_t *next = er->next;
thread_mutex_lock(&next->lock);
thread_mutex_unlock(&er->lock);
igloo_thread_mutex_lock(&next->lock);
igloo_thread_mutex_unlock(&er->lock);
er = next;
} else {
break;
}
}
thread_mutex_unlock(&er->lock);
igloo_thread_mutex_unlock(&er->lock);
}
static void *event_run_thread (void *arg) {
@ -172,7 +172,7 @@ static void *event_run_thread (void *arg) {
event_t *event;
size_t i;
thread_mutex_lock(&event_lock);
igloo_thread_mutex_lock(&event_lock);
running = event_running;
if (event_queue) {
event = event_queue;
@ -181,7 +181,7 @@ static void *event_run_thread (void *arg) {
} else {
event = NULL;
}
thread_mutex_unlock(&event_lock);
igloo_thread_mutex_unlock(&event_lock);
/* sleep if nothing todo and then try again */
if (!event) {
@ -200,15 +200,15 @@ static void *event_run_thread (void *arg) {
void event_initialise(void) {
/* create mutex */
thread_mutex_create(&event_lock);
igloo_thread_mutex_create(&event_lock);
/* initialise everything */
thread_mutex_lock(&event_lock);
igloo_thread_mutex_lock(&event_lock);
event_running = 1;
thread_mutex_unlock(&event_lock);
igloo_thread_mutex_unlock(&event_lock);
/* start thread */
event_thread = thread_create("events thread", event_run_thread, NULL, igloo_THREAD_ATTACHED);
event_thread = igloo_thread_create("events thread", event_run_thread, NULL, igloo_THREAD_ATTACHED);
}
void event_shutdown(void) {
@ -218,19 +218,19 @@ void event_shutdown(void) {
if (!event_running)
return;
thread_mutex_lock(&event_lock);
igloo_thread_mutex_lock(&event_lock);
event_running = 0;
thread_mutex_unlock(&event_lock);
igloo_thread_mutex_unlock(&event_lock);
/* join thread as soon as it stopped */
igloo_thread_join(event_thread);
/* shutdown everything */
thread_mutex_lock(&event_lock);
igloo_thread_mutex_lock(&event_lock);
event_thread = NULL;
event_queue_to_free = event_queue;
event_queue = NULL;
thread_mutex_unlock(&event_lock);
igloo_thread_mutex_unlock(&event_lock);
event_release(event_queue_to_free);
@ -287,19 +287,19 @@ event_registration_t * event_new_from_xml_node(xmlNodePtr node) {
void event_registration_addref(event_registration_t * er) {
if(!er)
return;
thread_mutex_lock(&er->lock);
igloo_thread_mutex_lock(&er->lock);
er->refcount++;
thread_mutex_unlock(&er->lock);
igloo_thread_mutex_unlock(&er->lock);
}
void event_registration_release(event_registration_t *er) {
if(!er)
return;
thread_mutex_lock(&er->lock);
igloo_thread_mutex_lock(&er->lock);
er->refcount--;
if (er->refcount) {
thread_mutex_unlock(&er->lock);
igloo_thread_mutex_unlock(&er->lock);
return;
}
@ -312,7 +312,7 @@ void event_registration_release(event_registration_t *er) {
if (er->free)
er->free(er->state);
thread_mutex_unlock(&er->lock);
igloo_thread_mutex_unlock(&er->lock);
igloo_thread_mutex_destroy(&er->lock);
free(er);
}
@ -329,21 +329,21 @@ void event_registration_push(event_registration_t **er, event_registration_t *ta
}
event_registration_addref(cur = *er);
thread_mutex_lock(&cur->lock);
igloo_thread_mutex_lock(&cur->lock);
while (1) {
next = cur->next;
if (!cur->next)
break;
event_registration_addref(next);
thread_mutex_unlock(&cur->lock);
igloo_thread_mutex_unlock(&cur->lock);
event_registration_release(cur);
cur = next;
thread_mutex_lock(&cur->lock);
igloo_thread_mutex_lock(&cur->lock);
}
event_registration_addref(cur->next = tail);
thread_mutex_unlock(&cur->lock);
igloo_thread_mutex_unlock(&cur->lock);
event_registration_release(cur);
}
@ -351,9 +351,9 @@ void event_registration_push(event_registration_t **er, event_registration_t *ta
void event_emit(event_t *event) {
fastevent_emit(FASTEVENT_TYPE_SLOWEVENT, FASTEVENT_FLAG_NONE, FASTEVENT_DATATYPE_EVENT, event);
event_addref(event);
thread_mutex_lock(&event_lock);
igloo_thread_mutex_lock(&event_lock);
event_push(&event_queue, event);
thread_mutex_unlock(&event_lock);
igloo_thread_mutex_unlock(&event_lock);
}
/* this function needs to extract all the info from the client, source and mount object

View File

@ -103,12 +103,12 @@ static void __unregister(refobject_t self, void **userdata)
(void)userdata;
thread_rwlock_wlock(&fastevent_lock);
igloo_thread_rwlock_wlock(&fastevent_lock);
row = __get_row(registration->type);
if (__remove_from_row(row, registration) != 0) {
ICECAST_LOG_ERROR("Can not remove fast event from row. BUG.");
}
thread_rwlock_unlock(&fastevent_lock);
igloo_thread_rwlock_unlock(&fastevent_lock);
if (registration->freecb)
registration->freecb(&(registration->userdata));
@ -119,7 +119,7 @@ static void __unregister(refobject_t self, void **userdata)
int fastevent_initialize(void)
{
thread_rwlock_create(&fastevent_lock);
igloo_thread_rwlock_create(&fastevent_lock);
return 0;
}
@ -127,7 +127,7 @@ int fastevent_shutdown(void)
{
size_t i;
thread_rwlock_wlock(&fastevent_lock);
igloo_thread_rwlock_wlock(&fastevent_lock);
for (i = 0; i < FASTEVENT_TYPE__END; i++) {
if (fastevent_registrations[i].used) {
ICECAST_LOG_ERROR("Subsystem shutdown but elements still in use. BUG.");
@ -137,7 +137,7 @@ int fastevent_shutdown(void)
free(fastevent_registrations[i].registrations);
fastevent_registrations[i].registrations = NULL;
}
thread_rwlock_unlock(&fastevent_lock);
igloo_thread_rwlock_unlock(&fastevent_lock);
igloo_thread_rwlock_destroy(&fastevent_lock);
return 0;
@ -155,18 +155,18 @@ refobject_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fasteve
if (cb == NULL)
return REFOBJECT_NULL;
thread_rwlock_wlock(&fastevent_lock);
igloo_thread_rwlock_wlock(&fastevent_lock);
row = __get_row(type);
if (row == NULL) {
thread_rwlock_unlock(&fastevent_lock);
igloo_thread_rwlock_unlock(&fastevent_lock);
return REFOBJECT_NULL;
}
registration = refobject_new__new(fastevent_registration_t, NULL, NULL, NULL);
if (!registration) {
thread_rwlock_unlock(&fastevent_lock);
igloo_thread_rwlock_unlock(&fastevent_lock);
return REFOBJECT_NULL;
}
@ -176,12 +176,12 @@ refobject_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fasteve
registration->userdata = userdata;
if (__add_to_row(row, registration) != 0) {
thread_rwlock_unlock(&fastevent_lock);
igloo_thread_rwlock_unlock(&fastevent_lock);
refobject_unref(REFOBJECT_FROM_TYPE(registration));
return REFOBJECT_NULL;
}
thread_rwlock_unlock(&fastevent_lock);
igloo_thread_rwlock_unlock(&fastevent_lock);
return REFOBJECT_FROM_TYPE(registration);
}
@ -193,10 +193,10 @@ void fastevent_emit(fastevent_type_t type, fastevent_flag_t flags, fastevent_dat
ICECAST_LOG_DEBUG("event: type=%i, flags=%i, datatype=%i, ...", (int)type, (int)flags, (int)datatype);
thread_rwlock_rlock(&fastevent_lock);
igloo_thread_rwlock_rlock(&fastevent_lock);
row = __get_row(type);
if (row == NULL || row->used == 0) {
thread_rwlock_unlock(&fastevent_lock);
igloo_thread_rwlock_unlock(&fastevent_lock);
return;
}
@ -208,7 +208,7 @@ void fastevent_emit(fastevent_type_t type, fastevent_flag_t flags, fastevent_dat
va_end(apx);
}
thread_rwlock_unlock(&fastevent_lock);
igloo_thread_rwlock_unlock(&fastevent_lock);
va_end(ap);
}

View File

@ -428,7 +428,7 @@ static int format_prepare_headers (source_t *source, client_t *client)
}
if (bytes < 0 || (size_t)bytes >= remaining) {
avl_tree_unlock(source->parser->vars);
igloo_avl_tree_unlock(source->parser->vars);
ICECAST_LOG_ERROR("Can not allocate headers for client %p", client);
client->respcode = 500;
return -1;

View File

@ -117,7 +117,7 @@ int format_mp3_get_plugin(source_t *source)
vorbis_comment_init(&plugin->vc);
source->format = plugin;
thread_mutex_create(&state->url_lock);
igloo_thread_mutex_create(&state->url_lock);
return 0;
}
@ -129,12 +129,12 @@ static void mp3_set_tag (format_plugin_t *plugin, const char *tag, const char *i
char *value = NULL;
/* protect against multiple updaters */
thread_mutex_lock (&source_mp3->url_lock);
igloo_thread_mutex_lock (&source_mp3->url_lock);
if (tag==NULL)
{
source_mp3->update_metadata = 1;
thread_mutex_unlock (&source_mp3->url_lock);
igloo_thread_mutex_unlock (&source_mp3->url_lock);
return;
}
@ -156,7 +156,7 @@ static void mp3_set_tag (format_plugin_t *plugin, const char *tag, const char *i
format_set_vorbiscomment(plugin, tag, value);
free (value);
thread_mutex_unlock (&source_mp3->url_lock);
igloo_thread_mutex_unlock (&source_mp3->url_lock);
}
@ -242,7 +242,7 @@ static void mp3_set_title(source_t *source)
mp3_state *source_mp3 = source->format->_state;
/* make sure the url data does not disappear from under us */
thread_mutex_lock (&source_mp3->url_lock);
igloo_thread_mutex_lock (&source_mp3->url_lock);
/* work out message length */
if (url_artist)
@ -262,7 +262,7 @@ static void mp3_set_title(source_t *source)
#define MAX_META_LEN 255*16
if (len > MAX_META_LEN)
{
thread_mutex_unlock (&source_mp3->url_lock);
igloo_thread_mutex_unlock (&source_mp3->url_lock);
ICECAST_LOG_WARN("Metadata too long at %d chars", len);
return;
}
@ -308,7 +308,7 @@ static void mp3_set_title(source_t *source)
refbuf_release (source_mp3->metadata);
source_mp3->metadata = p;
}
thread_mutex_unlock (&source_mp3->url_lock);
igloo_thread_mutex_unlock (&source_mp3->url_lock);
}

View File

@ -629,7 +629,7 @@ static void fserve_add_pending (fserve_t *fclient)
{
run_fserv = 1;
ICECAST_LOG_DEBUG("fserve handler waking up");
thread_create("File Serving Thread", fserv_thread_function, NULL, igloo_THREAD_DETACHED);
igloo_thread_create("File Serving Thread", fserv_thread_function, NULL, igloo_THREAD_DETACHED);
}
igloo_thread_spin_unlock (&pending_lock);
}

View File

@ -40,7 +40,7 @@ void global_initialize(void)
global.sources = 0;
global.source_tree = igloo_avl_tree_new(source_compare_sources, NULL);
global.modulecontainer = refobject_new(module_container_t);
thread_mutex_create(&_global_mutex);
igloo_thread_mutex_create(&_global_mutex);
}
void global_shutdown(void)
@ -52,10 +52,10 @@ void global_shutdown(void)
void global_lock(void)
{
thread_mutex_lock(&_global_mutex);
igloo_thread_mutex_lock(&_global_mutex);
}
void global_unlock(void)
{
thread_mutex_unlock(&_global_mutex);
igloo_thread_mutex_unlock(&_global_mutex);
}

View File

@ -144,9 +144,9 @@ static void __listensocket_container_clear_sockets(listensocket_container_t *sel
static void __listensocket_container_free(refobject_t self, void **userdata)
{
listensocket_container_t *container = REFOBJECT_TO_TYPE(self, listensocket_container_t *);
thread_mutex_lock(&container->lock);
igloo_thread_mutex_lock(&container->lock);
__listensocket_container_clear_sockets(container);
thread_mutex_unlock(&container->lock);
igloo_thread_mutex_unlock(&container->lock);
igloo_thread_mutex_destroy(&container->lock);
}
@ -159,7 +159,7 @@ int __listensocket_container_new(refobject_t self, const refobject_type_t *type,
ret->sockcount_cb = NULL;
ret->sockcount_userdata = NULL;
thread_mutex_create(&ret->lock);
igloo_thread_mutex_create(&ret->lock);
return 0;
}
@ -201,9 +201,9 @@ int listensocket_container_configure(listensocket_contai
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
ret = listensocket_container_configure__unlocked(self, config);
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return ret;
}
@ -276,7 +276,7 @@ int listensocket_container_configure_and_setup(listensoc
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
cb = self->sockcount_cb;
self->sockcount_cb = NULL;
@ -288,7 +288,7 @@ int listensocket_container_configure_and_setup(listensoc
self->sockcount_cb = cb;
__call_sockcount_cb(self);
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return ret;
}
@ -300,9 +300,9 @@ int listensocket_container_setup(listensocket_container_
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
ret = listensocket_container_setup__unlocked(self);
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return ret;
}
@ -432,10 +432,10 @@ connection_t * listensocket_container_accept(listensocket_container
if (!self)
return NULL;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
ls = listensocket_container_accept__inner(self, timeout);
refobject_ref(ls);
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
ret = listensocket_accept(ls, self);
refobject_unref(ls);
@ -448,10 +448,10 @@ int listensocket_container_set_sockcount_cb(listensocket
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
self->sockcount_cb = cb;
self->sockcount_userdata = userdata;
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return 0;
}
@ -463,9 +463,9 @@ ssize_t listensocket_container_sockcount(listensocket_contai
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
ret = listensocket_container_sockcount__unlocked(self);
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return ret;
}
@ -513,7 +513,7 @@ static void __listensocket_free(refobject_t self, void **userdata)
{
listensocket_t *listensocket = REFOBJECT_TO_TYPE(self, listensocket_t *);
thread_mutex_lock(&listensocket->lock);
igloo_thread_mutex_lock(&listensocket->lock);
if (listensocket->sockrefc) {
ICECAST_LOG_ERROR("BUG: listensocket->sockrefc == 0 && listensocket->sockrefc == %zu", listensocket->sockrefc);
@ -522,11 +522,11 @@ static void __listensocket_free(refobject_t self, void **userdata)
}
while ((listensocket->listener_update = config_clear_listener(listensocket->listener_update)));
thread_rwlock_wlock(&listensocket->listener_rwlock);
igloo_thread_rwlock_wlock(&listensocket->listener_rwlock);
while ((listensocket->listener = config_clear_listener(listensocket->listener)));
thread_rwlock_unlock(&listensocket->listener_rwlock);
igloo_thread_rwlock_unlock(&listensocket->listener_rwlock);
igloo_thread_rwlock_destroy(&listensocket->listener_rwlock);
thread_mutex_unlock(&listensocket->lock);
igloo_thread_mutex_unlock(&listensocket->lock);
igloo_thread_mutex_destroy(&listensocket->lock);
}
@ -546,8 +546,8 @@ static listensocket_t * listensocket_new(const listener_t *listener) {
self->sock = igloo_SOCK_ERROR;
thread_mutex_create(&self->lock);
thread_rwlock_create(&self->listener_rwlock);
igloo_thread_mutex_create(&self->lock);
igloo_thread_rwlock_create(&self->listener_rwlock);
self->listener = config_copy_listener_one(listener);
if (self->listener == NULL) {
@ -565,9 +565,9 @@ static int listensocket_apply_config(listensocket_t *self)
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
ret = listensocket_apply_config__unlocked(self);
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return ret;
}
@ -579,7 +579,7 @@ static int listensocket_apply_config__unlocked(listensocket_t *self
if (!self)
return -1;
thread_rwlock_wlock(&self->listener_rwlock);
igloo_thread_rwlock_wlock(&self->listener_rwlock);
if (self->listener_update) {
if (__listener_cmp(self->listener, self->listener_update) != 1) {
ICECAST_LOG_ERROR("Tried to apply incomplete configuration to listensocket: bind address missmatch: have %s:%i, got %s:%i",
@ -588,7 +588,7 @@ static int listensocket_apply_config__unlocked(listensocket_t *self
__string_default(self->listener_update->bind_address, "<ANY>"),
self->listener_update->port
);
thread_rwlock_unlock(&self->listener_rwlock);
igloo_thread_rwlock_unlock(&self->listener_rwlock);
return -1;
}
@ -612,7 +612,7 @@ static int listensocket_apply_config__unlocked(listensocket_t *self
self->listener_update = NULL;
}
thread_rwlock_unlock(&self->listener_rwlock);
igloo_thread_rwlock_unlock(&self->listener_rwlock);
return 0;
}
@ -628,10 +628,10 @@ static int listensocket_set_update(listensocket_t *self, const list
if (n == NULL)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
while ((self->listener_update = config_clear_listener(self->listener_update)));
self->listener_update = n;
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return 0;
}
@ -640,38 +640,38 @@ int listensocket_refsock(listensocket_t *self)
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
if (self->sockrefc) {
self->sockrefc++;
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return 0;
}
thread_rwlock_rlock(&self->listener_rwlock);
igloo_thread_rwlock_rlock(&self->listener_rwlock);
self->sock = igloo_sock_get_server_socket(self->listener->port, self->listener->bind_address);
thread_rwlock_unlock(&self->listener_rwlock);
igloo_thread_rwlock_unlock(&self->listener_rwlock);
if (self->sock == igloo_SOCK_ERROR) {
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return -1;
}
if (__socket_listen(self->sock, self->listener) == 0) {
igloo_sock_close(self->sock);
self->sock = igloo_SOCK_ERROR;
thread_rwlock_rlock(&self->listener_rwlock);
igloo_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);
thread_mutex_unlock(&self->lock);
igloo_thread_rwlock_unlock(&self->listener_rwlock);
igloo_thread_mutex_unlock(&self->lock);
return -1;
}
if (listensocket_apply_config__unlocked(self) == -1) {
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return -1;
}
self->sockrefc++;
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return 0;
}
@ -681,21 +681,21 @@ int listensocket_unrefsock(listensocket_t *self)
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
self->sockrefc--;
if (self->sockrefc) {
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return 0;
}
if (self->sock == igloo_SOCK_ERROR) {
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return 0;
}
igloo_sock_close(self->sock);
self->sock = igloo_SOCK_ERROR;
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return 0;
}
@ -714,9 +714,9 @@ connection_t * listensocket_accept(listensocket_t *self, listensock
if (!ip)
return NULL;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
sock = igloo_sock_accept(self->sock, ip, MAX_ADDR_LEN);
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
if (sock == igloo_SOCK_ERROR) {
free(ip);
return NULL;
@ -761,10 +761,10 @@ const listener_t * listensocket_get_listener(listensocket_t *self)
if (!self)
return NULL;
thread_mutex_lock(&self->lock);
thread_rwlock_rlock(&self->listener_rwlock);
igloo_thread_mutex_lock(&self->lock);
igloo_thread_rwlock_rlock(&self->listener_rwlock);
ret = self->listener;
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return ret;
}
@ -781,7 +781,7 @@ int listensocket_release_listener(listensocket_t *self)
* waiting for a wlock to be come available.
* -- ph3-der-loewe, 2018-05-11
*/
thread_rwlock_unlock(&self->listener_rwlock);
igloo_thread_rwlock_unlock(&self->listener_rwlock);
return 0;
}
@ -793,9 +793,9 @@ listener_type_t listensocket_get_type(listensocket_t *self)
if (!self)
return LISTENER_TYPE_ERROR;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
ret = self->listener->type;
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return ret;
}
@ -806,9 +806,9 @@ static inline int listensocket__poll_fill(listensocket_t *self, struct pollfd *p
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
if (self->sock == igloo_SOCK_ERROR) {
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return -1;
}
@ -817,7 +817,7 @@ static inline int listensocket__poll_fill(listensocket_t *self, struct pollfd *p
p->events = POLLIN;
p->revents = 0;
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return 0;
}
@ -827,9 +827,9 @@ static inline int listensocket__select_set(listensocket_t *self, fd_set *set, in
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
if (self->sock == igloo_SOCK_ERROR) {
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return -1;
}
@ -837,7 +837,7 @@ static inline int listensocket__select_set(listensocket_t *self, fd_set *set, in
*max = self->sock;
FD_SET(self->sock, set);
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return 0;
}
@ -848,13 +848,13 @@ static inline int listensocket__select_isset(listensocket_t *self, fd_set *set)
if (!self)
return -1;
thread_mutex_lock(&self->lock);
igloo_thread_mutex_lock(&self->lock);
if (self->sock == igloo_SOCK_ERROR) {
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return -1;
}
ret = FD_ISSET(self->sock, set);
thread_mutex_unlock(&self->lock);
igloo_thread_mutex_unlock(&self->lock);
return ret;
}

View File

@ -54,7 +54,7 @@ int __module_container_new(refobject_t self, const refobject_type_t *type, va_li
{
module_container_t *ret = REFOBJECT_TO_TYPE(self, module_container_t*);
thread_mutex_create(&(ret->lock));
igloo_thread_mutex_create(&(ret->lock));
ret->module = igloo_avl_tree_new(compare_refobject_t_name, NULL);
@ -74,9 +74,9 @@ int module_container_add_module(module_container_t *self, mo
if (refobject_ref(module) != 0)
return -1;
thread_mutex_lock(&(self->lock));
igloo_thread_mutex_lock(&(self->lock));
igloo_avl_insert(self->module, module);
thread_mutex_unlock(&(self->lock));
igloo_thread_mutex_unlock(&(self->lock));
return 0;
}
@ -92,9 +92,9 @@ int module_container_delete_module(module_container_t *self,
if (!module)
return -1;
thread_mutex_lock(&(self->lock));
igloo_thread_mutex_lock(&(self->lock));
igloo_avl_delete(self->module, module, (igloo_avl_free_key_fun_type)refobject_unref);
thread_mutex_unlock(&(self->lock));
igloo_thread_mutex_unlock(&(self->lock));
refobject_unref(module);
@ -111,11 +111,11 @@ 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));
igloo_thread_mutex_lock(&(self->lock));
if (igloo_avl_get_by_key(self->module, REFOBJECT_TO_TYPE(search, void *), (void**)&ret) != 0) {
ret = NULL;
}
thread_mutex_unlock(&(self->lock));
igloo_thread_mutex_unlock(&(self->lock));
refobject_unref(search);
refobject_ref(ret);
@ -135,7 +135,7 @@ xmlNodePtr module_container_get_modulelist_as_xml(module_co
if (!root)
return NULL;
thread_mutex_lock(&(self->lock));
igloo_thread_mutex_lock(&(self->lock));
avlnode = igloo_avl_get_first(self->module);
while (avlnode) {
module_t *module = avlnode->key;
@ -149,7 +149,7 @@ xmlNodePtr module_container_get_modulelist_as_xml(module_co
avlnode = igloo_avl_get_next(avlnode);
}
thread_mutex_unlock(&(self->lock));
igloo_thread_mutex_unlock(&(self->lock));
return root;
}
@ -181,7 +181,7 @@ module_t * module_new(const char *name, module_setup_handler_t newc
if (!ret)
return NULL;
thread_mutex_create(&(ret->lock));
igloo_thread_mutex_create(&(ret->lock));
ret->userdata = userdata;
ret->freecb = freecb;
@ -221,13 +221,13 @@ int module_add_link(module_t *self, const char *type
}
}
thread_mutex_lock(&(self->lock));
igloo_thread_mutex_lock(&(self->lock));
free(self->management_link_url);
free(self->management_link_title);
self->management_link_url = n_url;
self->management_link_title = n_title;
thread_mutex_unlock(&(self->lock));
igloo_thread_mutex_unlock(&(self->lock));
return 0;
}
@ -239,14 +239,14 @@ const module_client_handler_t * module_get_client_handler(module_t *self, const
if (!self || !name)
return NULL;
thread_mutex_lock(&(self->lock));
igloo_thread_mutex_lock(&(self->lock));
for (i = 0; i < self->client_handlers_len; i++) {
if (self->client_handlers[i].name && strcmp(self->client_handlers[i].name, name) == 0) {
thread_mutex_unlock(&(self->lock));
igloo_thread_mutex_unlock(&(self->lock));
return &(self->client_handlers[i]);
}
}
thread_mutex_unlock(&(self->lock));
igloo_thread_mutex_unlock(&(self->lock));
return NULL;
}
@ -256,10 +256,10 @@ int module_add_client_handler(module_t *self, const
if (!self)
return -1;
thread_mutex_lock(&(self->lock));
igloo_thread_mutex_lock(&(self->lock));
self->client_handlers = handlers;
self->client_handlers_len = len;
thread_mutex_unlock(&(self->lock));
igloo_thread_mutex_unlock(&(self->lock));
return 0;
}

View File

@ -50,7 +50,7 @@ refobject_t refobject_new__real(const refobject_type_t *type, void *userdata
ret->refc = 1;
ret->userdata = userdata;
thread_mutex_create(&(ret->lock));
igloo_thread_mutex_create(&(ret->lock));
if (name) {
ret->name = strdup(name);
@ -105,9 +105,9 @@ int refobject_ref(refobject_t self)
if (REFOBJECT_IS_NULL(self))
return -1;
thread_mutex_lock(&(TO_BASE(self)->lock));
igloo_thread_mutex_lock(&(TO_BASE(self)->lock));
TO_BASE(self)->refc++;
thread_mutex_unlock(&(TO_BASE(self)->lock));
igloo_thread_mutex_unlock(&(TO_BASE(self)->lock));
return 0;
}
@ -119,10 +119,10 @@ int refobject_unref(refobject_t self)
if (REFOBJECT_IS_NULL(self))
return -1;
thread_mutex_lock(&(base->lock));
igloo_thread_mutex_lock(&(base->lock));
base->refc--;
if (base->refc) {
thread_mutex_unlock(&(base->lock));
igloo_thread_mutex_unlock(&(base->lock));
return 0;
}
@ -135,7 +135,7 @@ int refobject_unref(refobject_t self)
if (base->name)
free(base->name);
thread_mutex_unlock(&(base->lock));
igloo_thread_mutex_unlock(&(base->lock));
igloo_thread_mutex_destroy(&(base->lock));
free(base);
@ -150,9 +150,9 @@ void * refobject_get_userdata(refobject_t self)
if (REFOBJECT_IS_NULL(self))
return NULL;
thread_mutex_lock(&(TO_BASE(self)->lock));
igloo_thread_mutex_lock(&(TO_BASE(self)->lock));
ret = TO_BASE(self)->userdata;
thread_mutex_unlock(&(TO_BASE(self)->lock));
igloo_thread_mutex_unlock(&(TO_BASE(self)->lock));
return ret;
}
@ -162,9 +162,9 @@ int refobject_set_userdata(refobject_t self, void *userdata)
if (REFOBJECT_IS_NULL(self))
return -1;
thread_mutex_lock(&(TO_BASE(self)->lock));
igloo_thread_mutex_lock(&(TO_BASE(self)->lock));
TO_BASE(self)->userdata = userdata;
thread_mutex_unlock(&(TO_BASE(self)->lock));
igloo_thread_mutex_unlock(&(TO_BASE(self)->lock));
return 0;
}
@ -176,9 +176,9 @@ const char * refobject_get_name(refobject_t self)
if (REFOBJECT_IS_NULL(self))
return NULL;
thread_mutex_lock(&(TO_BASE(self)->lock));
igloo_thread_mutex_lock(&(TO_BASE(self)->lock));
ret = TO_BASE(self)->name;
thread_mutex_unlock(&(TO_BASE(self)->lock));
igloo_thread_mutex_unlock(&(TO_BASE(self)->lock));
return ret;
}
@ -190,9 +190,9 @@ refobject_t refobject_get_associated(refobject_t self)
if (REFOBJECT_IS_NULL(self))
return REFOBJECT_NULL;
thread_mutex_lock(&(TO_BASE(self)->lock));
igloo_thread_mutex_lock(&(TO_BASE(self)->lock));
ret = TO_BASE(self)->associated;
thread_mutex_unlock(&(TO_BASE(self)->lock));
igloo_thread_mutex_unlock(&(TO_BASE(self)->lock));
return ret;
}

View File

@ -988,7 +988,7 @@ static int __database_new(refobject_t self, const refobject_type_t *type, va_lis
{
reportxml_database_t *ret = REFOBJECT_TO_TYPE(self, reportxml_database_t*);
thread_mutex_create(&(ret->lock));
igloo_thread_mutex_create(&(ret->lock));
ret->definitions = igloo_avl_tree_new(__compare_definitions, NULL);
if (!ret->definitions)
@ -1024,7 +1024,7 @@ int reportxml_database_add_report(reportxml_database_t *db,
if (count < 0)
return -1;
thread_mutex_lock(&(db->lock));
igloo_thread_mutex_lock(&(db->lock));
for (i = 0; i < (size_t)count; i++) {
reportxml_node_t *node = reportxml_node_get_child(root, i);
@ -1044,7 +1044,7 @@ int reportxml_database_add_report(reportxml_database_t *db,
igloo_avl_insert(db->definitions, copy);
}
thread_mutex_unlock(&(db->lock));
igloo_thread_mutex_unlock(&(db->lock));
refobject_unref(root);
@ -1158,9 +1158,9 @@ static reportxml_node_t * __reportxml_database_build_node_ext(reportxml_dat
return NULL;
}
thread_mutex_lock(&(db->lock));
igloo_thread_mutex_lock(&(db->lock));
if (igloo_avl_get_by_key(db->definitions, REFOBJECT_TO_TYPE(search, void *), (void**)&found) != 0) {
thread_mutex_unlock(&(db->lock));
igloo_thread_mutex_unlock(&(db->lock));
refobject_unref(search);
return NULL;
}
@ -1168,10 +1168,10 @@ static reportxml_node_t * __reportxml_database_build_node_ext(reportxml_dat
refobject_unref(search);
if (refobject_ref(found) != 0) {
thread_mutex_unlock(&(db->lock));
igloo_thread_mutex_unlock(&(db->lock));
return NULL;
}
thread_mutex_unlock(&(db->lock));
igloo_thread_mutex_unlock(&(db->lock));
count = reportxml_node_count_child(found);
if (count < 0) {

View File

@ -191,11 +191,11 @@ static inline relay_t *relay_new(relay_config_t *config)
*/
void slave_update_all_mounts(void)
{
thread_mutex_lock(&_slave_mutex);
igloo_thread_mutex_lock(&_slave_mutex);
max_interval = 0;
update_all_mounts = 1;
update_settings = 1;
thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_unlock(&_slave_mutex);
}
@ -204,9 +204,9 @@ void slave_update_all_mounts(void)
*/
void slave_rebuild_mounts(void)
{
thread_mutex_lock(&_slave_mutex);
igloo_thread_mutex_lock(&_slave_mutex);
update_settings = 1;
thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_unlock(&_slave_mutex);
}
@ -217,20 +217,20 @@ 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, igloo_THREAD_ATTACHED);
igloo_thread_mutex_create (&_slave_mutex);
_slave_thread_id = igloo_thread_create("Slave Thread", _slave_thread, NULL, igloo_THREAD_ATTACHED);
}
void slave_shutdown(void)
{
thread_mutex_lock(&_slave_mutex);
igloo_thread_mutex_lock(&_slave_mutex);
if (!slave_running) {
thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_unlock(&_slave_mutex);
return;
}
slave_running = 0;
thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_unlock(&_slave_mutex);
ICECAST_LOG_DEBUG("waiting for slave thread");
igloo_thread_join (_slave_thread_id);
@ -476,13 +476,13 @@ static void *start_relay_stream (void *arg)
source_clear_source(relay->source);
/* cleanup relay, but prevent this relay from starting up again too soon */
thread_mutex_lock(&_slave_mutex);
thread_mutex_lock(&(config_locks()->relay_lock));
igloo_thread_mutex_lock(&_slave_mutex);
igloo_thread_mutex_lock(&(config_locks()->relay_lock));
relay->source->on_demand = 0;
relay->start = time(NULL) + max_interval;
relay->cleanup = 1;
thread_mutex_unlock(&(config_locks()->relay_lock));
thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_unlock(&(config_locks()->relay_lock));
igloo_thread_mutex_unlock(&_slave_mutex);
return NULL;
}
@ -555,7 +555,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 = igloo_thread_create ("Relay Thread", start_relay_stream,
relay, igloo_THREAD_ATTACHED);
return;
@ -846,7 +846,7 @@ static int update_from_master(ice_config_t *config)
}
igloo_sock_close (mastersock);
thread_mutex_lock (&(config_locks()->relay_lock));
igloo_thread_mutex_lock (&(config_locks()->relay_lock));
cleanup_relays = update_relays (&global.master_relays, new_relays, new_relays_length);
relay_check_streams (global.master_relays, cleanup_relays, 0);
@ -856,7 +856,7 @@ static int update_from_master(ice_config_t *config)
}
free(new_relays);
thread_mutex_unlock (&(config_locks()->relay_lock));
igloo_thread_mutex_unlock (&(config_locks()->relay_lock));
} while(0);
@ -878,10 +878,10 @@ static void *_slave_thread(void *arg)
(void)arg;
thread_mutex_lock(&_slave_mutex);
igloo_thread_mutex_lock(&_slave_mutex);
update_settings = 0;
update_all_mounts = 0;
thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_unlock(&_slave_mutex);
config = config_get_config();
stats_global(config);
@ -902,17 +902,17 @@ static void *_slave_thread(void *arg)
global_unlock();
igloo_thread_sleep(1000000);
thread_mutex_lock(&_slave_mutex);
igloo_thread_mutex_lock(&_slave_mutex);
if (slave_running == 0) {
thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_unlock(&_slave_mutex);
break;
}
thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_unlock(&_slave_mutex);
++interval;
/* only update relays lists when required */
thread_mutex_lock(&_slave_mutex);
igloo_thread_mutex_lock(&_slave_mutex);
if (max_interval <= interval)
{
ICECAST_LOG_DEBUG("checking master stream list");
@ -922,13 +922,13 @@ static void *_slave_thread(void *arg)
skip_timer = 1;
interval = 0;
max_interval = config->master_update_interval;
thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_unlock(&_slave_mutex);
/* the connection could take some time, so the lock can drop */
if (update_from_master (config))
config = config_get_config();
thread_mutex_lock (&(config_locks()->relay_lock));
igloo_thread_mutex_lock (&(config_locks()->relay_lock));
cleanup_relays = update_relays(&global.relays, config->relay, config->relay_length);
@ -936,22 +936,22 @@ static void *_slave_thread(void *arg)
}
else
{
thread_mutex_unlock(&_slave_mutex);
thread_mutex_lock (&(config_locks()->relay_lock));
igloo_thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_lock (&(config_locks()->relay_lock));
}
relay_check_streams (global.relays, cleanup_relays, skip_timer);
relay_check_streams (global.master_relays, NULL, skip_timer);
thread_mutex_unlock (&(config_locks()->relay_lock));
igloo_thread_mutex_unlock (&(config_locks()->relay_lock));
thread_mutex_lock(&_slave_mutex);
igloo_thread_mutex_lock(&_slave_mutex);
if (update_settings)
{
source_recheck_mounts (update_all_mounts);
update_settings = 0;
update_all_mounts = 0;
}
thread_mutex_unlock(&_slave_mutex);
igloo_thread_mutex_unlock(&_slave_mutex);
}
ICECAST_LOG_INFO("shutting down current relays");
relay_check_streams (NULL, global.relays, 0);

View File

@ -107,7 +107,7 @@ source_t *source_reserve (const char *mount)
/* make duplicates for strings or similar */
src->mount = strdup(mount);
src->max_listeners = -1;
thread_mutex_create(&src->lock);
igloo_thread_mutex_create(&src->lock);
igloo_avl_insert(global.source_tree, src);
@ -358,7 +358,7 @@ void source_move_clients(source_t *source, source_t *dest)
return;
}
/* we don't want the two write locks to deadlock in here */
thread_mutex_lock (&move_clients_mutex);
igloo_thread_mutex_lock (&move_clients_mutex);
/* if the destination is not running then we can't move clients */
@ -367,7 +367,7 @@ void source_move_clients(source_t *source, source_t *dest)
{
ICECAST_LOG_WARN("destination mount %s not running, unable to move clients ", dest->mount);
igloo_avl_tree_unlock (dest->pending_tree);
thread_mutex_unlock (&move_clients_mutex);
igloo_thread_mutex_unlock (&move_clients_mutex);
return;
}
@ -456,7 +456,7 @@ void source_move_clients(source_t *source, source_t *dest)
dest->on_demand_req = 1;
igloo_avl_tree_unlock (dest->pending_tree);
thread_mutex_unlock (&move_clients_mutex);
igloo_thread_mutex_unlock (&move_clients_mutex);
}
@ -503,7 +503,7 @@ static refbuf_t *get_next_buffer (source_t *source)
}
if (fds == 0)
{
thread_mutex_lock(&source->lock);
igloo_thread_mutex_lock(&source->lock);
if ((source->last_read + (time_t)source->timeout) < current)
{
ICECAST_LOG_DEBUG("last %ld, timeout %d, now %ld", (long)source->last_read,
@ -511,7 +511,7 @@ static refbuf_t *get_next_buffer (source_t *source)
ICECAST_LOG_WARN("Disconnecting source due to socket timeout");
source->running = 0;
}
thread_mutex_unlock(&source->lock);
igloo_thread_mutex_unlock(&source->lock);
break;
}
source->last_read = current;
@ -641,7 +641,7 @@ static void source_init (source_t *source)
}
/* grab a read lock, to make sure we get a chance to cleanup */
thread_rwlock_rlock (source->shutdown_rwlock);
igloo_thread_rwlock_rlock (source->shutdown_rwlock);
/* start off the statistics */
source->listeners = 0;
@ -733,10 +733,10 @@ void source_main (source_t *source)
source->format->write_buf_to_file(source, refbuf);
}
/* lets see if we have too much data in the queue, but don't remove it until later */
thread_mutex_lock(&source->lock);
igloo_thread_mutex_lock(&source->lock);
if (source->queue_size > source->queue_size_limit)
remove_from_q = 1;
thread_mutex_unlock(&source->lock);
igloo_thread_mutex_unlock(&source->lock);
/* acquire write lock on pending_tree */
igloo_avl_tree_wlock(source->pending_tree);
@ -916,7 +916,7 @@ static void source_shutdown (source_t *source)
global_unlock();
/* release our hold on the lock so the main thread can continue cleaning up */
thread_rwlock_unlock(source->shutdown_rwlock);
igloo_thread_rwlock_unlock(source->shutdown_rwlock);
}
@ -1227,12 +1227,12 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr
*/
void source_update_settings (ice_config_t *config, source_t *source, mount_proxy *mountinfo)
{
thread_mutex_lock(&source->lock);
igloo_thread_mutex_lock(&source->lock);
/* skip if source is a fallback to file */
if (source->running && source->client == NULL)
{
stats_event_hidden (source->mount, NULL, 1);
thread_mutex_unlock(&source->lock);
igloo_thread_mutex_unlock(&source->lock);
return;
}
/* set global settings first */
@ -1282,7 +1282,7 @@ void source_update_settings (ice_config_t *config, source_t *source, mount_proxy
ICECAST_LOG_DEBUG("burst size to %u", source->burst_size);
ICECAST_LOG_DEBUG("source timeout to %u", source->timeout);
ICECAST_LOG_DEBUG("fallback_when_full to %u", source->fallback_when_full);
thread_mutex_unlock(&source->lock);
igloo_thread_mutex_unlock(&source->lock);
}
@ -1324,7 +1324,7 @@ void source_client_callback (client_t *client, void *arg)
if (agent)
stats_event (source->mount, "user_agent", agent);
thread_create ("Source Thread", source_client_thread,
igloo_thread_create ("Source Thread", source_client_thread,
source, igloo_THREAD_DETACHED);
}
@ -1443,7 +1443,7 @@ void source_recheck_mounts (int update_all)
source_t *fallback = source_find_mount (mount->fallback_mount);
if (fallback == NULL)
{
thread_create ("Fallback file thread", source_fallback_file,
igloo_thread_create ("Fallback file thread", source_fallback_file,
strdup (mount->fallback_mount), igloo_THREAD_DETACHED);
}
}

View File

@ -121,9 +121,9 @@ static stats_event_t *build_event (const char *source, const char *name, const c
static void queue_global_event (stats_event_t *event)
{
thread_mutex_lock(&_global_event_mutex);
igloo_thread_mutex_lock(&_global_event_mutex);
_add_event_to_queue (event, &_global_event_queue);
thread_mutex_unlock(&_global_event_mutex);
igloo_thread_mutex_unlock(&_global_event_mutex);
}
void stats_initialize(void)
@ -135,15 +135,15 @@ void stats_initialize(void)
_stats.source_tree = igloo_avl_tree_new(_compare_source_stats, NULL);
/* set up global mutex */
thread_mutex_create(&_stats_mutex);
igloo_thread_mutex_create(&_stats_mutex);
/* set up stats queues */
event_queue_init(&_global_event_queue);
thread_mutex_create(&_global_event_mutex);
igloo_thread_mutex_create(&_global_event_mutex);
/* fire off the stats thread */
_stats_running = 1;
_stats_thread_id = thread_create("Stats Thread", _stats_thread, NULL, igloo_THREAD_ATTACHED);
_stats_thread_id = igloo_thread_create("Stats Thread", _stats_thread, NULL, igloo_THREAD_ATTACHED);
}
void stats_shutdown(void)
@ -154,17 +154,17 @@ void stats_shutdown(void)
return;
/* wait for thread to exit */
thread_mutex_lock(&_stats_mutex);
igloo_thread_mutex_lock(&_stats_mutex);
_stats_running = 0;
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
igloo_thread_join(_stats_thread_id);
/* wait for other threads to shut down */
do {
igloo_thread_sleep(300000);
thread_mutex_lock(&_stats_mutex);
igloo_thread_mutex_lock(&_stats_mutex);
n = _stats_threads;
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
} while (n > 0);
ICECAST_LOG_INFO("stats thread finished");
@ -292,7 +292,7 @@ static char *_get_stats(const char *source, const char *name)
stats_source_t *src = NULL;
char *value = NULL;
thread_mutex_lock(&_stats_mutex);
igloo_thread_mutex_lock(&_stats_mutex);
if (source == NULL) {
stats = _find_node(_stats.global_tree, name);
@ -305,7 +305,7 @@ static char *_get_stats(const char *source, const char *name)
if (stats) value = (char *)strdup(stats->value);
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
return value;
}
@ -694,24 +694,24 @@ static void *_stats_thread(void *arg)
ICECAST_LOG_INFO("stats thread started");
while (1) {
thread_mutex_lock(&_stats_mutex);
igloo_thread_mutex_lock(&_stats_mutex);
if (!_stats_running) {
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
break;
}
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
thread_mutex_lock(&_global_event_mutex);
igloo_thread_mutex_lock(&_global_event_mutex);
if (_global_event_queue.head != NULL) {
/* grab the next event from the queue */
event = _get_event_from_queue (&_global_event_queue);
thread_mutex_unlock(&_global_event_mutex);
igloo_thread_mutex_unlock(&_global_event_mutex);
if (event == NULL)
continue;
event->next = NULL;
thread_mutex_lock(&_stats_mutex);
igloo_thread_mutex_lock(&_stats_mutex);
/* check if we are dealing with a global or source event */
if (event->source == NULL)
@ -724,9 +724,9 @@ static void *_stats_thread(void *arg)
listener = (event_listener_t *)_event_listeners;
while (listener) {
copy = _copy_event(event);
thread_mutex_lock (&listener->mutex);
igloo_thread_mutex_lock (&listener->mutex);
_add_event_to_queue (copy, &listener->queue);
thread_mutex_unlock (&listener->mutex);
igloo_thread_mutex_unlock (&listener->mutex);
listener = listener->next;
}
@ -734,12 +734,12 @@ static void *_stats_thread(void *arg)
/* now we need to destroy the event */
_free_event(event);
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
continue;
}
else
{
thread_mutex_unlock(&_global_event_mutex);
igloo_thread_mutex_unlock(&_global_event_mutex);
}
igloo_thread_sleep(300000);
@ -847,7 +847,7 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i
__add_authstack(config->authstack, root);
config_release_config();
thread_mutex_lock(&_stats_mutex);
igloo_thread_mutex_lock(&_stats_mutex);
/* general stats first */
avlnode = igloo_avl_get_first(_stats.global_tree);
@ -913,7 +913,7 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i
}
avlnode = igloo_avl_get_next (avlnode);
}
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
return ret;
}
@ -930,7 +930,7 @@ static void _register_listener (event_listener_t *listener)
stats_event_t *event;
stats_source_t *source;
thread_mutex_lock(&_stats_mutex);
igloo_thread_mutex_lock(&_stats_mutex);
/* first we fill our queue with the current stats */
@ -962,7 +962,7 @@ static void _register_listener (event_listener_t *listener)
listener->next = (event_listener_t *)_event_listeners;
_event_listeners = listener;
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
}
void *stats_connection(void *arg)
@ -975,26 +975,26 @@ void *stats_connection(void *arg)
event_queue_init (&listener.queue);
/* increment the thread count */
thread_mutex_lock(&_stats_mutex);
igloo_thread_mutex_lock(&_stats_mutex);
_stats_threads++;
stats_event_args (NULL, "stats", "%d", _stats_threads);
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
thread_mutex_create (&(listener.mutex));
igloo_thread_mutex_create (&(listener.mutex));
_register_listener (&listener);
while (1) {
thread_mutex_lock(&_stats_mutex);
igloo_thread_mutex_lock(&_stats_mutex);
if (!_stats_running) {
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
break;
}
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
thread_mutex_lock (&listener.mutex);
igloo_thread_mutex_lock (&listener.mutex);
event = _get_event_from_queue (&listener.queue);
thread_mutex_unlock (&listener.mutex);
igloo_thread_mutex_unlock (&listener.mutex);
if (event != NULL) {
if (_send_event_to_client(event, client) < 0) {
_free_event(event);
@ -1006,11 +1006,11 @@ void *stats_connection(void *arg)
igloo_thread_sleep (500000);
}
thread_mutex_lock(&_stats_mutex);
igloo_thread_mutex_lock(&_stats_mutex);
_unregister_listener (&listener);
_stats_threads--;
stats_event_args (NULL, "stats", "%d", _stats_threads);
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_destroy (&listener.mutex);
client_destroy (client);
@ -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, igloo_THREAD_DETACHED);
igloo_thread_create("Stats Connection", stats_connection, (void *)client, igloo_THREAD_DETACHED);
}
@ -1164,7 +1164,7 @@ refbuf_t *stats_get_streams (void)
char *buffer = cur->data;
/* now the stats for each source */
thread_mutex_lock (&_stats_mutex);
igloo_thread_mutex_lock (&_stats_mutex);
node = igloo_avl_get_first(_stats.source_tree);
while (node)
{
@ -1190,7 +1190,7 @@ refbuf_t *stats_get_streams (void)
}
node = igloo_avl_get_next(node);
}
thread_mutex_unlock(&_stats_mutex);
igloo_thread_mutex_unlock(&_stats_mutex);
cur->len = STREAMLIST_BLKSIZE - remaining;
return start;
}
@ -1205,7 +1205,7 @@ void stats_clear_virtual_mounts (void)
{
igloo_avl_node *snode;
thread_mutex_lock (&_stats_mutex);
igloo_thread_mutex_lock (&_stats_mutex);
snode = igloo_avl_get_first(_stats.source_tree);
while (snode)
{
@ -1223,6 +1223,6 @@ void stats_clear_virtual_mounts (void)
snode = igloo_avl_get_next (snode);
}
thread_mutex_unlock (&_stats_mutex);
igloo_thread_mutex_unlock (&_stats_mutex);
}

View File

@ -1425,13 +1425,13 @@ struct tm *localtime_r (const time_t *timep, struct tm *result)
if (initialised == 0)
{
thread_mutex_create (&localtime_lock);
igloo_thread_mutex_create (&localtime_lock);
initialised = 1;
}
thread_mutex_lock (&localtime_lock);
igloo_thread_mutex_lock (&localtime_lock);
tm = localtime (timep);
memcpy (result, tm, sizeof (*result));
thread_mutex_unlock (&localtime_lock);
igloo_thread_mutex_unlock (&localtime_lock);
return result;
}
#endif

View File

@ -106,7 +106,7 @@ static xmlChar *admin_URI = NULL;
void xslt_initialize(void)
{
memset(cache, 0, sizeof(stylesheet_cache_t) * CACHESIZE);
thread_mutex_create(&xsltlock);
igloo_thread_mutex_create(&xsltlock);
xmlInitParser();
LIBXML_TEST_VERSION
xmlSubstituteEntitiesDefault(1);
@ -139,7 +139,7 @@ void xslt_clear_cache(void)
ICECAST_LOG_DEBUG("Clearing stylesheet cache.");
thread_mutex_lock(&xsltlock);
igloo_thread_mutex_lock(&xsltlock);
for (i = 0; i < CACHESIZE; i++)
clear_cache_entry(i);
@ -149,7 +149,7 @@ void xslt_clear_cache(void)
admin_URI = NULL;
}
thread_mutex_unlock(&xsltlock);
igloo_thread_mutex_unlock(&xsltlock);
}
static int evict_cache_entry(void) {
@ -333,12 +333,12 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client, in
xsltSetGenericErrorFunc("", log_parse_failure);
xsltSetLoaderFunc(custom_loader);
thread_mutex_lock(&xsltlock);
igloo_thread_mutex_lock(&xsltlock);
cur = xslt_get_stylesheet(xslfilename);
if (cur == NULL)
{
thread_mutex_unlock(&xsltlock);
igloo_thread_mutex_unlock(&xsltlock);
ICECAST_LOG_ERROR("problem reading stylesheet \"%s\"", xslfilename);
_send_error(client, ICECAST_ERROR_XSLT_PARSE, status);
return;
@ -436,7 +436,7 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client, in
ICECAST_LOG_WARN("problem applying stylesheet \"%s\"", xslfilename);
_send_error(client, ICECAST_ERROR_XSLT_problem, status);
}
thread_mutex_unlock (&xsltlock);
igloo_thread_mutex_unlock (&xsltlock);
xmlFreeDoc(res);
}

View File

@ -221,7 +221,7 @@ void yp_recheck_config (ice_config_t *config)
struct yp_server *server;
ICECAST_LOG_DEBUG("Updating YP configuration");
thread_rwlock_rlock (&yp_lock);
igloo_thread_rwlock_rlock (&yp_lock);
server = (struct yp_server *)active_yps;
while (server)
@ -271,21 +271,21 @@ void yp_recheck_config (ice_config_t *config)
server->remove = 0;
}
}
thread_rwlock_unlock (&yp_lock);
thread_rwlock_wlock(&yp_lock);
igloo_thread_rwlock_unlock (&yp_lock);
igloo_thread_rwlock_wlock(&yp_lock);
yp_update = 1;
thread_rwlock_unlock(&yp_lock);
igloo_thread_rwlock_unlock(&yp_lock);
}
void yp_initialize(void)
{
ice_config_t *config = config_get_config();
thread_rwlock_create (&yp_lock);
thread_mutex_create (&yp_pending_lock);
igloo_thread_rwlock_create (&yp_lock);
igloo_thread_mutex_create (&yp_pending_lock);
yp_recheck_config (config);
config_release_config ();
yp_thread = thread_create("YP Touch Thread", yp_update_thread,
yp_thread = igloo_thread_create("YP Touch Thread", yp_update_thread,
(void *)NULL, igloo_THREAD_ATTACHED);
}
@ -735,7 +735,7 @@ static void *yp_update_thread(void *arg)
igloo_thread_sleep (200000);
/* do the YP communication */
thread_rwlock_rlock (&yp_lock);
igloo_thread_rwlock_rlock (&yp_lock);
server = (struct yp_server *)active_yps;
while (server)
{
@ -746,8 +746,8 @@ static void *yp_update_thread(void *arg)
/* update the local YP structure */
if (yp_update)
{
thread_rwlock_unlock(&yp_lock);
thread_rwlock_wlock (&yp_lock);
igloo_thread_rwlock_unlock(&yp_lock);
igloo_thread_rwlock_wlock (&yp_lock);
check_servers ();
server = (struct yp_server *)active_yps;
while (server)
@ -760,7 +760,7 @@ static void *yp_update_thread(void *arg)
yp_update = 0;
}
running = yp_running;
thread_rwlock_unlock(&yp_lock);
igloo_thread_rwlock_unlock(&yp_lock);
}
igloo_thread_rwlock_destroy (&yp_lock);
igloo_thread_mutex_destroy (&yp_pending_lock);
@ -887,10 +887,10 @@ void yp_add (const char *mount)
struct yp_server *server;
/* make sure YP thread is not modifying the lists */
thread_rwlock_rlock (&yp_lock);
igloo_thread_rwlock_rlock (&yp_lock);
/* make sure we don't race against another yp_add */
thread_mutex_lock (&yp_pending_lock);
igloo_thread_mutex_lock (&yp_pending_lock);
server = (struct yp_server *)active_yps;
while (server)
{
@ -917,8 +917,8 @@ void yp_add (const char *mount)
ICECAST_LOG_DEBUG("YP entry %s already exists", mount);
server = server->next;
}
thread_mutex_unlock (&yp_pending_lock);
thread_rwlock_unlock (&yp_lock);
igloo_thread_mutex_unlock (&yp_pending_lock);
igloo_thread_rwlock_unlock (&yp_lock);
}
@ -928,7 +928,7 @@ void yp_remove (const char *mount)
{
struct yp_server *server = (struct yp_server *)active_yps;
thread_rwlock_rlock (&yp_lock);
igloo_thread_rwlock_rlock (&yp_lock);
while (server)
{
ypdata_t *list = server->mounts;
@ -949,7 +949,7 @@ void yp_remove (const char *mount)
}
server = server->next;
}
thread_rwlock_unlock (&yp_lock);
igloo_thread_rwlock_unlock (&yp_lock);
}
@ -960,7 +960,7 @@ void yp_touch (const char *mount)
struct yp_server *server = (struct yp_server *)active_yps;
ypdata_t *search_list = NULL;
thread_rwlock_rlock (&yp_lock);
igloo_thread_rwlock_rlock (&yp_lock);
if (server)
search_list = server->mounts;
@ -983,16 +983,16 @@ void yp_touch (const char *mount)
if (server)
search_list = server->mounts;
}
thread_rwlock_unlock (&yp_lock);
igloo_thread_rwlock_unlock (&yp_lock);
}
void yp_shutdown (void)
{
thread_rwlock_wlock(&yp_lock);
igloo_thread_rwlock_wlock(&yp_lock);
yp_running = 0;
yp_update = 1;
thread_rwlock_unlock(&yp_lock);
igloo_thread_rwlock_unlock(&yp_lock);
if (yp_thread)
igloo_thread_join (yp_thread);