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:
parent
aade92a236
commit
6f40700abd
64
src/auth.c
64
src/auth.c
@ -56,9 +56,9 @@ static volatile unsigned long _current_id = 0;
|
|||||||
static unsigned long _next_auth_id(void) {
|
static unsigned long _next_auth_id(void) {
|
||||||
unsigned long id;
|
unsigned long id;
|
||||||
|
|
||||||
thread_mutex_lock(&_auth_lock);
|
igloo_thread_mutex_lock(&_auth_lock);
|
||||||
id = _current_id++;
|
id = _current_id++;
|
||||||
thread_mutex_unlock(&_auth_lock);
|
igloo_thread_mutex_unlock(&_auth_lock);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -169,12 +169,12 @@ static void queue_auth_client (auth_client *auth_user)
|
|||||||
if (auth->immediate) {
|
if (auth->immediate) {
|
||||||
__handle_auth_client(auth, auth_user);
|
__handle_auth_client(auth, auth_user);
|
||||||
} else {
|
} else {
|
||||||
thread_mutex_lock (&auth->lock);
|
igloo_thread_mutex_lock (&auth->lock);
|
||||||
*auth->tailp = auth_user;
|
*auth->tailp = auth_user;
|
||||||
auth->tailp = &auth_user->next;
|
auth->tailp = &auth_user->next;
|
||||||
auth->pending_count++;
|
auth->pending_count++;
|
||||||
ICECAST_LOG_INFO("auth on %s has %d pending", auth->mount, 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)
|
if (authenticator == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
thread_mutex_lock(&authenticator->lock);
|
igloo_thread_mutex_lock(&authenticator->lock);
|
||||||
authenticator->refcount--;
|
authenticator->refcount--;
|
||||||
ICECAST_LOG_DEBUG("...refcount on auth_t %s is now %d", authenticator->mount, (int)authenticator->refcount);
|
ICECAST_LOG_DEBUG("...refcount on auth_t %s is now %d", authenticator->mount, (int)authenticator->refcount);
|
||||||
if (authenticator->refcount)
|
if (authenticator->refcount)
|
||||||
{
|
{
|
||||||
thread_mutex_unlock(&authenticator->lock);
|
igloo_thread_mutex_unlock(&authenticator->lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup auth thread attached to this auth */
|
/* cleanup auth thread attached to this auth */
|
||||||
if (authenticator->running) {
|
if (authenticator->running) {
|
||||||
authenticator->running = 0;
|
authenticator->running = 0;
|
||||||
thread_mutex_unlock(&authenticator->lock);
|
igloo_thread_mutex_unlock(&authenticator->lock);
|
||||||
igloo_thread_join(authenticator->thread);
|
igloo_thread_join(authenticator->thread);
|
||||||
thread_mutex_lock(&authenticator->lock);
|
igloo_thread_mutex_lock(&authenticator->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authenticator->free)
|
if (authenticator->free)
|
||||||
@ -213,7 +213,7 @@ void auth_release (auth_t *authenticator) {
|
|||||||
xmlFree (authenticator->role);
|
xmlFree (authenticator->role);
|
||||||
if (authenticator->management_url)
|
if (authenticator->management_url)
|
||||||
xmlFree (authenticator->management_url);
|
xmlFree (authenticator->management_url);
|
||||||
thread_mutex_unlock(&authenticator->lock);
|
igloo_thread_mutex_unlock(&authenticator->lock);
|
||||||
igloo_thread_mutex_destroy(&authenticator->lock);
|
igloo_thread_mutex_destroy(&authenticator->lock);
|
||||||
if (authenticator->mount)
|
if (authenticator->mount)
|
||||||
free(authenticator->mount);
|
free(authenticator->mount);
|
||||||
@ -234,10 +234,10 @@ void auth_addref (auth_t *authenticator) {
|
|||||||
if (authenticator == NULL)
|
if (authenticator == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
thread_mutex_lock (&authenticator->lock);
|
igloo_thread_mutex_lock (&authenticator->lock);
|
||||||
authenticator->refcount++;
|
authenticator->refcount++;
|
||||||
ICECAST_LOG_DEBUG("...refcount on auth_t %s is now %d", authenticator->mount, (int)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)
|
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");
|
ICECAST_LOG_INFO("Authentication thread started");
|
||||||
while (1) {
|
while (1) {
|
||||||
thread_mutex_lock(&auth->lock);
|
igloo_thread_mutex_lock(&auth->lock);
|
||||||
|
|
||||||
if (!auth->running) {
|
if (!auth->running) {
|
||||||
thread_mutex_unlock(&auth->lock);
|
igloo_thread_mutex_unlock(&auth->lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ static void *auth_run_thread (void *arg)
|
|||||||
auth_user = (auth_client*)auth->head;
|
auth_user = (auth_client*)auth->head;
|
||||||
if (auth_user == NULL)
|
if (auth_user == NULL)
|
||||||
{
|
{
|
||||||
thread_mutex_unlock (&auth->lock);
|
igloo_thread_mutex_unlock (&auth->lock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ICECAST_LOG_DEBUG("%d client(s) pending on %s (role %s)", auth->pending_count, auth->mount, auth->role);
|
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)
|
if (auth->head == NULL)
|
||||||
auth->tailp = &auth->head;
|
auth->tailp = &auth->head;
|
||||||
auth->pending_count--;
|
auth->pending_count--;
|
||||||
thread_mutex_unlock(&auth->lock);
|
igloo_thread_mutex_unlock(&auth->lock);
|
||||||
auth_user->next = NULL;
|
auth_user->next = NULL;
|
||||||
|
|
||||||
__handle_auth_client(auth, auth_user);
|
__handle_auth_client(auth, auth_user);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
thread_mutex_unlock(&auth->lock);
|
igloo_thread_mutex_unlock(&auth->lock);
|
||||||
}
|
}
|
||||||
igloo_thread_sleep (150000);
|
igloo_thread_sleep (150000);
|
||||||
}
|
}
|
||||||
@ -806,7 +806,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
|
|||||||
if (auth == NULL)
|
if (auth == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_mutex_create(&auth->lock);
|
igloo_thread_mutex_create(&auth->lock);
|
||||||
auth->refcount = 1;
|
auth->refcount = 1;
|
||||||
auth->id = _next_auth_id();
|
auth->id = _next_auth_id();
|
||||||
auth->type = (char*)xmlGetProp(node, XMLSTR("type"));
|
auth->type = (char*)xmlGetProp(node, XMLSTR("type"));
|
||||||
@ -953,7 +953,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
|
|||||||
auth->tailp = &auth->head;
|
auth->tailp = &auth->head;
|
||||||
if (!auth->immediate) {
|
if (!auth->immediate) {
|
||||||
auth->running = 1;
|
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)
|
void auth_initialise (void)
|
||||||
{
|
{
|
||||||
thread_mutex_create(&_auth_lock);
|
igloo_thread_mutex_create(&_auth_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void auth_shutdown (void)
|
void auth_shutdown (void)
|
||||||
@ -1061,9 +1061,9 @@ void auth_stack_release(auth_stack_t *stack) {
|
|||||||
if (!stack)
|
if (!stack)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
thread_mutex_lock(&stack->lock);
|
igloo_thread_mutex_lock(&stack->lock);
|
||||||
stack->refcount--;
|
stack->refcount--;
|
||||||
thread_mutex_unlock(&stack->lock);
|
igloo_thread_mutex_unlock(&stack->lock);
|
||||||
|
|
||||||
if (stack->refcount)
|
if (stack->refcount)
|
||||||
return;
|
return;
|
||||||
@ -1077,19 +1077,19 @@ void auth_stack_release(auth_stack_t *stack) {
|
|||||||
void auth_stack_addref(auth_stack_t *stack) {
|
void auth_stack_addref(auth_stack_t *stack) {
|
||||||
if (!stack)
|
if (!stack)
|
||||||
return;
|
return;
|
||||||
thread_mutex_lock(&stack->lock);
|
igloo_thread_mutex_lock(&stack->lock);
|
||||||
stack->refcount++;
|
stack->refcount++;
|
||||||
thread_mutex_unlock(&stack->lock);
|
igloo_thread_mutex_unlock(&stack->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int auth_stack_next(auth_stack_t **stack) {
|
int auth_stack_next(auth_stack_t **stack) {
|
||||||
auth_stack_t *next;
|
auth_stack_t *next;
|
||||||
if (!stack || !*stack)
|
if (!stack || !*stack)
|
||||||
return -1;
|
return -1;
|
||||||
thread_mutex_lock(&(*stack)->lock);
|
igloo_thread_mutex_lock(&(*stack)->lock);
|
||||||
next = (*stack)->next;
|
next = (*stack)->next;
|
||||||
auth_stack_addref(next);
|
auth_stack_addref(next);
|
||||||
thread_mutex_unlock(&(*stack)->lock);
|
igloo_thread_mutex_unlock(&(*stack)->lock);
|
||||||
auth_stack_release(*stack);
|
auth_stack_release(*stack);
|
||||||
*stack = next;
|
*stack = next;
|
||||||
if (!next)
|
if (!next)
|
||||||
@ -1107,7 +1107,7 @@ int auth_stack_push(auth_stack_t **stack, auth_t *auth) {
|
|||||||
if (!next) {
|
if (!next) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
thread_mutex_create(&next->lock);
|
igloo_thread_mutex_create(&next->lock);
|
||||||
next->refcount = 1;
|
next->refcount = 1;
|
||||||
next->auth = auth;
|
next->auth = auth;
|
||||||
auth_addref(auth);
|
auth_addref(auth);
|
||||||
@ -1129,21 +1129,21 @@ int auth_stack_append(auth_stack_t *stack, auth_stack_t *tail) {
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
auth_stack_addref(cur = stack);
|
auth_stack_addref(cur = stack);
|
||||||
thread_mutex_lock(&cur->lock);
|
igloo_thread_mutex_lock(&cur->lock);
|
||||||
while (1) {
|
while (1) {
|
||||||
next = cur->next;
|
next = cur->next;
|
||||||
if (!cur->next)
|
if (!cur->next)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
auth_stack_addref(next);
|
auth_stack_addref(next);
|
||||||
thread_mutex_unlock(&cur->lock);
|
igloo_thread_mutex_unlock(&cur->lock);
|
||||||
auth_stack_release(cur);
|
auth_stack_release(cur);
|
||||||
cur = next;
|
cur = next;
|
||||||
thread_mutex_lock(&cur->lock);
|
igloo_thread_mutex_lock(&cur->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
auth_stack_addref(cur->next = tail);
|
auth_stack_addref(cur->next = tail);
|
||||||
thread_mutex_unlock(&cur->lock);
|
igloo_thread_mutex_unlock(&cur->lock);
|
||||||
auth_stack_release(cur);
|
auth_stack_release(cur);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1155,9 +1155,9 @@ auth_t *auth_stack_get(auth_stack_t *stack) {
|
|||||||
if (!stack)
|
if (!stack)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_mutex_lock(&stack->lock);
|
igloo_thread_mutex_lock(&stack->lock);
|
||||||
auth_addref(auth = stack->auth);
|
auth_addref(auth = stack->auth);
|
||||||
thread_mutex_unlock(&stack->lock);
|
igloo_thread_mutex_unlock(&stack->lock);
|
||||||
return auth;
|
return auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,10 +121,10 @@ static void htpasswd_recheckfile(htpasswd_auth_state *htpasswd)
|
|||||||
ICECAST_LOG_WARN("failed to check status of %s", htpasswd->filename);
|
ICECAST_LOG_WARN("failed to check status of %s", htpasswd->filename);
|
||||||
|
|
||||||
/* Create a dummy users tree for things to use later */
|
/* 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)
|
if(!htpasswd->users)
|
||||||
htpasswd->users = igloo_avl_tree_new(compare_users, NULL);
|
htpasswd->users = igloo_avl_tree_new(compare_users, NULL);
|
||||||
thread_rwlock_unlock (&htpasswd->file_rwlock);
|
igloo_thread_rwlock_unlock (&htpasswd->file_rwlock);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -167,11 +167,11 @@ static void htpasswd_recheckfile(htpasswd_auth_state *htpasswd)
|
|||||||
}
|
}
|
||||||
fclose (passwdfile);
|
fclose (passwdfile);
|
||||||
|
|
||||||
thread_rwlock_wlock (&htpasswd->file_rwlock);
|
igloo_thread_rwlock_wlock (&htpasswd->file_rwlock);
|
||||||
if (htpasswd->users)
|
if (htpasswd->users)
|
||||||
igloo_avl_tree_free (htpasswd->users, _free_user);
|
igloo_avl_tree_free (htpasswd->users, _free_user);
|
||||||
htpasswd->users = new_users;
|
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;
|
return AUTH_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_rwlock_rlock (&htpasswd->file_rwlock);
|
igloo_thread_rwlock_rlock (&htpasswd->file_rwlock);
|
||||||
entry.name = client->username;
|
entry.name = client->username;
|
||||||
if (igloo_avl_get_by_key (htpasswd->users, &entry, &result) == 0) {
|
if (igloo_avl_get_by_key (htpasswd->users, &entry, &result) == 0) {
|
||||||
htpasswd_user *found = result;
|
htpasswd_user *found = result;
|
||||||
char *hashed_pw;
|
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));
|
hashed_pw = get_hash (client->password, strlen (client->password));
|
||||||
if (strcmp (found->pass, hashed_pw) == 0) {
|
if (strcmp (found->pass, hashed_pw) == 0) {
|
||||||
free (hashed_pw);
|
free (hashed_pw);
|
||||||
@ -214,7 +214,7 @@ static auth_result htpasswd_auth (auth_client *auth_user)
|
|||||||
return AUTH_FAILED;
|
return AUTH_FAILED;
|
||||||
}
|
}
|
||||||
ICECAST_LOG_DEBUG("no such username: %s", client->username);
|
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;
|
return AUTH_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ int auth_get_htpasswd_auth (auth_t *authenticator, config_options_t *options)
|
|||||||
|
|
||||||
authenticator->state = state;
|
authenticator->state = state;
|
||||||
|
|
||||||
thread_rwlock_create(&state->file_rwlock);
|
igloo_thread_rwlock_create(&state->file_rwlock);
|
||||||
htpasswd_recheckfile(state);
|
htpasswd_recheckfile(state);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -275,18 +275,18 @@ static auth_result htpasswd_adduser (auth_t *auth, const char *username, const c
|
|||||||
return AUTH_FAILED;
|
return AUTH_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_rwlock_wlock (&state->file_rwlock);
|
igloo_thread_rwlock_wlock (&state->file_rwlock);
|
||||||
|
|
||||||
entry.name = (char*)username;
|
entry.name = (char*)username;
|
||||||
if (igloo_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);
|
igloo_thread_rwlock_unlock (&state->file_rwlock);
|
||||||
return AUTH_USEREXISTS;
|
return AUTH_USEREXISTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
passwdfile = fopen(state->filename, "ab");
|
passwdfile = fopen(state->filename, "ab");
|
||||||
|
|
||||||
if (passwdfile == NULL) {
|
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",
|
ICECAST_LOG_WARN("Failed to open authentication database \"%s\": %s",
|
||||||
state->filename, strerror(errno));
|
state->filename, strerror(errno));
|
||||||
return AUTH_FAILED;
|
return AUTH_FAILED;
|
||||||
@ -299,7 +299,7 @@ static auth_result htpasswd_adduser (auth_t *auth, const char *username, const c
|
|||||||
}
|
}
|
||||||
|
|
||||||
fclose(passwdfile);
|
fclose(passwdfile);
|
||||||
thread_rwlock_unlock (&state->file_rwlock);
|
igloo_thread_rwlock_unlock (&state->file_rwlock);
|
||||||
|
|
||||||
return AUTH_USERADDED;
|
return AUTH_USERADDED;
|
||||||
}
|
}
|
||||||
@ -328,13 +328,13 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
|
|||||||
return AUTH_FAILED;
|
return AUTH_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_rwlock_wlock (&state->file_rwlock);
|
igloo_thread_rwlock_wlock (&state->file_rwlock);
|
||||||
passwdfile = fopen(state->filename, "rb");
|
passwdfile = fopen(state->filename, "rb");
|
||||||
|
|
||||||
if(passwdfile == NULL) {
|
if(passwdfile == NULL) {
|
||||||
ICECAST_LOG_WARN("Failed to open authentication database \"%s\": %s",
|
ICECAST_LOG_WARN("Failed to open authentication database \"%s\": %s",
|
||||||
state->filename, strerror(errno));
|
state->filename, strerror(errno));
|
||||||
thread_rwlock_unlock (&state->file_rwlock);
|
igloo_thread_rwlock_unlock (&state->file_rwlock);
|
||||||
return AUTH_FAILED;
|
return AUTH_FAILED;
|
||||||
}
|
}
|
||||||
tmpfile_len = strlen(state->filename) + 6;
|
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);
|
ICECAST_LOG_WARN("temp file \"%s\" exists, rejecting operation", tmpfile);
|
||||||
free (tmpfile);
|
free (tmpfile);
|
||||||
fclose (passwdfile);
|
fclose (passwdfile);
|
||||||
thread_rwlock_unlock (&state->file_rwlock);
|
igloo_thread_rwlock_unlock (&state->file_rwlock);
|
||||||
return AUTH_FAILED;
|
return AUTH_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
|
|||||||
tmpfile, strerror(errno));
|
tmpfile, strerror(errno));
|
||||||
fclose(passwdfile);
|
fclose(passwdfile);
|
||||||
free(tmpfile);
|
free(tmpfile);
|
||||||
thread_rwlock_unlock (&state->file_rwlock);
|
igloo_thread_rwlock_unlock (&state->file_rwlock);
|
||||||
return AUTH_FAILED;
|
return AUTH_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(tmpfile);
|
free(tmpfile);
|
||||||
thread_rwlock_unlock(&state->file_rwlock);
|
igloo_thread_rwlock_unlock(&state->file_rwlock);
|
||||||
htpasswd_recheckfile(state);
|
htpasswd_recheckfile(state);
|
||||||
|
|
||||||
return AUTH_USERDELETED;
|
return AUTH_USERDELETED;
|
||||||
@ -422,7 +422,7 @@ static auth_result htpasswd_userlist(auth_t *auth, xmlNodePtr srcnode)
|
|||||||
return AUTH_FAILED;
|
return AUTH_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_rwlock_rlock(&state->file_rwlock);
|
igloo_thread_rwlock_rlock(&state->file_rwlock);
|
||||||
node = igloo_avl_get_first(state->users);
|
node = igloo_avl_get_first(state->users);
|
||||||
while (node) {
|
while (node) {
|
||||||
htpasswd_user *user = (htpasswd_user *)node->key;
|
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));
|
xmlNewTextChild(newnode, NULL, XMLSTR("username"), XMLSTR(user->name));
|
||||||
node = igloo_avl_get_next(node);
|
node = igloo_avl_get_next(node);
|
||||||
}
|
}
|
||||||
thread_rwlock_unlock(&state->file_rwlock);
|
igloo_thread_rwlock_unlock(&state->file_rwlock);
|
||||||
|
|
||||||
return AUTH_OK;
|
return AUTH_OK;
|
||||||
}
|
}
|
||||||
|
@ -231,8 +231,8 @@ char * config_href_to_id(const char *href)
|
|||||||
|
|
||||||
static void create_locks(void)
|
static void create_locks(void)
|
||||||
{
|
{
|
||||||
thread_mutex_create(&_locks.relay_lock);
|
igloo_thread_mutex_create(&_locks.relay_lock);
|
||||||
thread_rwlock_create(&_locks.config_lock);
|
igloo_thread_rwlock_create(&_locks.config_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void release_locks(void)
|
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)));
|
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++) {
|
for (i = 0; i < c->relay_length; i++) {
|
||||||
relay_config_free(c->relay[i]);
|
relay_config_free(c->relay[i]);
|
||||||
}
|
}
|
||||||
free(c->relay);
|
free(c->relay);
|
||||||
thread_mutex_unlock(&(_locks.relay_lock));
|
igloo_thread_mutex_unlock(&(_locks.relay_lock));
|
||||||
|
|
||||||
mount = c->mounts;
|
mount = c->mounts;
|
||||||
while (mount) {
|
while (mount) {
|
||||||
@ -821,18 +821,18 @@ ice_config_locks *config_locks(void)
|
|||||||
|
|
||||||
void config_release_config(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)
|
ice_config_t *config_get_config(void)
|
||||||
{
|
{
|
||||||
thread_rwlock_rlock(&(_locks.config_lock));
|
igloo_thread_rwlock_rlock(&(_locks.config_lock));
|
||||||
return &_current_configuration;
|
return &_current_configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
ice_config_t *config_grab_config(void)
|
ice_config_t *config_grab_config(void)
|
||||||
{
|
{
|
||||||
thread_rwlock_wlock(&(_locks.config_lock));
|
igloo_thread_rwlock_wlock(&(_locks.config_lock));
|
||||||
return &_current_configuration;
|
return &_current_configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
/* 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.
|
* 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);
|
source = source_find_mount_raw(client->uri);
|
||||||
ret = util_http_build_header(client->refbuf->data, PER_CLIENT_REFBUF_SIZE, 0,
|
ret = util_http_build_header(client->refbuf->data, PER_CLIENT_REFBUF_SIZE, 0,
|
||||||
0, 204, NULL,
|
0, 204, NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL, source, client);
|
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,
|
snprintf(client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
|
||||||
"Content-Length: 0\r\n\r\n");
|
"Content-Length: 0\r\n\r\n");
|
||||||
|
@ -115,9 +115,9 @@ void connection_initialize(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
igloo_thread_spin_create (&_connection_lock);
|
igloo_thread_spin_create (&_connection_lock);
|
||||||
thread_mutex_create(&move_clients_mutex);
|
igloo_thread_mutex_create(&move_clients_mutex);
|
||||||
thread_rwlock_create(&_source_shutdown_rwlock);
|
igloo_thread_rwlock_create(&_source_shutdown_rwlock);
|
||||||
thread_cond_create(&global.shutdown_cond);
|
igloo_thread_cond_create(&global.shutdown_cond);
|
||||||
_req_queue = NULL;
|
_req_queue = NULL;
|
||||||
_req_queue_tail = &_req_queue;
|
_req_queue_tail = &_req_queue;
|
||||||
_con_queue = NULL;
|
_con_queue = NULL;
|
||||||
@ -715,11 +715,11 @@ void connection_accept_loop(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Give all the other threads notification to shut down */
|
/* 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 */
|
/* wait for all the sources to shutdown */
|
||||||
thread_rwlock_wlock(&_source_shutdown_rwlock);
|
igloo_thread_rwlock_wlock(&_source_shutdown_rwlock);
|
||||||
thread_rwlock_unlock(&_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) {
|
static void _handle_delete_request(client_t *client) {
|
||||||
source_t *source;
|
source_t *source;
|
||||||
|
|
||||||
avl_tree_wlock(global.source_tree);
|
igloo_avl_tree_wlock(global.source_tree);
|
||||||
source = source_find_mount_raw(client->uri);
|
source = source_find_mount_raw(client->uri);
|
||||||
if (source) {
|
if (source) {
|
||||||
source->running = 0;
|
source->running = 0;
|
||||||
avl_tree_unlock(global.source_tree);
|
igloo_avl_tree_unlock(global.source_tree);
|
||||||
client_send_204(client);
|
client_send_204(client);
|
||||||
} else {
|
} 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);
|
client_send_error_by_id(client, ICECAST_ERROR_CON_UNKNOWN_REQUEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
60
src/event.c
60
src/event.c
@ -36,9 +36,9 @@ static igloo_thread_type *event_thread = NULL;
|
|||||||
static void event_addref(event_t *event) {
|
static void event_addref(event_t *event) {
|
||||||
if (!event)
|
if (!event)
|
||||||
return;
|
return;
|
||||||
thread_mutex_lock(&event_lock);
|
igloo_thread_mutex_lock(&event_lock);
|
||||||
event->refcount++;
|
event->refcount++;
|
||||||
thread_mutex_unlock(&event_lock);
|
igloo_thread_mutex_unlock(&event_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_release(event_t *event) {
|
static void event_release(event_t *event) {
|
||||||
@ -48,10 +48,10 @@ static void event_release(event_t *event) {
|
|||||||
if (!event)
|
if (!event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
thread_mutex_lock(&event_lock);
|
igloo_thread_mutex_lock(&event_lock);
|
||||||
event->refcount--;
|
event->refcount--;
|
||||||
if (event->refcount) {
|
if (event->refcount) {
|
||||||
thread_mutex_unlock(&event_lock);
|
igloo_thread_mutex_unlock(&event_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ static void event_release(event_t *event) {
|
|||||||
free(event->client_useragent);
|
free(event->client_useragent);
|
||||||
to_free = event->next;
|
to_free = event->next;
|
||||||
free(event);
|
free(event);
|
||||||
thread_mutex_unlock(&event_lock);
|
igloo_thread_mutex_unlock(&event_lock);
|
||||||
|
|
||||||
if (to_free)
|
if (to_free)
|
||||||
event_release(to_free);
|
event_release(to_free);
|
||||||
@ -144,7 +144,7 @@ static inline void _try_registrations(event_registration_t *er, event_t *event)
|
|||||||
if (!er)
|
if (!er)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
thread_mutex_lock(&er->lock);
|
igloo_thread_mutex_lock(&er->lock);
|
||||||
while (1) {
|
while (1) {
|
||||||
/* try registration */
|
/* try registration */
|
||||||
_try_event(er, event);
|
_try_event(er, event);
|
||||||
@ -153,14 +153,14 @@ static inline void _try_registrations(event_registration_t *er, event_t *event)
|
|||||||
if (er->next) {
|
if (er->next) {
|
||||||
event_registration_t *next = er->next;
|
event_registration_t *next = er->next;
|
||||||
|
|
||||||
thread_mutex_lock(&next->lock);
|
igloo_thread_mutex_lock(&next->lock);
|
||||||
thread_mutex_unlock(&er->lock);
|
igloo_thread_mutex_unlock(&er->lock);
|
||||||
er = next;
|
er = next;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&er->lock);
|
igloo_thread_mutex_unlock(&er->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *event_run_thread (void *arg) {
|
static void *event_run_thread (void *arg) {
|
||||||
@ -172,7 +172,7 @@ static void *event_run_thread (void *arg) {
|
|||||||
event_t *event;
|
event_t *event;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
thread_mutex_lock(&event_lock);
|
igloo_thread_mutex_lock(&event_lock);
|
||||||
running = event_running;
|
running = event_running;
|
||||||
if (event_queue) {
|
if (event_queue) {
|
||||||
event = event_queue;
|
event = event_queue;
|
||||||
@ -181,7 +181,7 @@ static void *event_run_thread (void *arg) {
|
|||||||
} else {
|
} else {
|
||||||
event = NULL;
|
event = NULL;
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&event_lock);
|
igloo_thread_mutex_unlock(&event_lock);
|
||||||
|
|
||||||
/* sleep if nothing todo and then try again */
|
/* sleep if nothing todo and then try again */
|
||||||
if (!event) {
|
if (!event) {
|
||||||
@ -200,15 +200,15 @@ static void *event_run_thread (void *arg) {
|
|||||||
|
|
||||||
void event_initialise(void) {
|
void event_initialise(void) {
|
||||||
/* create mutex */
|
/* create mutex */
|
||||||
thread_mutex_create(&event_lock);
|
igloo_thread_mutex_create(&event_lock);
|
||||||
|
|
||||||
/* initialise everything */
|
/* initialise everything */
|
||||||
thread_mutex_lock(&event_lock);
|
igloo_thread_mutex_lock(&event_lock);
|
||||||
event_running = 1;
|
event_running = 1;
|
||||||
thread_mutex_unlock(&event_lock);
|
igloo_thread_mutex_unlock(&event_lock);
|
||||||
|
|
||||||
/* start thread */
|
/* 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) {
|
void event_shutdown(void) {
|
||||||
@ -218,19 +218,19 @@ void event_shutdown(void) {
|
|||||||
if (!event_running)
|
if (!event_running)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
thread_mutex_lock(&event_lock);
|
igloo_thread_mutex_lock(&event_lock);
|
||||||
event_running = 0;
|
event_running = 0;
|
||||||
thread_mutex_unlock(&event_lock);
|
igloo_thread_mutex_unlock(&event_lock);
|
||||||
|
|
||||||
/* join thread as soon as it stopped */
|
/* join thread as soon as it stopped */
|
||||||
igloo_thread_join(event_thread);
|
igloo_thread_join(event_thread);
|
||||||
|
|
||||||
/* shutdown everything */
|
/* shutdown everything */
|
||||||
thread_mutex_lock(&event_lock);
|
igloo_thread_mutex_lock(&event_lock);
|
||||||
event_thread = NULL;
|
event_thread = NULL;
|
||||||
event_queue_to_free = event_queue;
|
event_queue_to_free = event_queue;
|
||||||
event_queue = NULL;
|
event_queue = NULL;
|
||||||
thread_mutex_unlock(&event_lock);
|
igloo_thread_mutex_unlock(&event_lock);
|
||||||
|
|
||||||
event_release(event_queue_to_free);
|
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) {
|
void event_registration_addref(event_registration_t * er) {
|
||||||
if(!er)
|
if(!er)
|
||||||
return;
|
return;
|
||||||
thread_mutex_lock(&er->lock);
|
igloo_thread_mutex_lock(&er->lock);
|
||||||
er->refcount++;
|
er->refcount++;
|
||||||
thread_mutex_unlock(&er->lock);
|
igloo_thread_mutex_unlock(&er->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_registration_release(event_registration_t *er) {
|
void event_registration_release(event_registration_t *er) {
|
||||||
if(!er)
|
if(!er)
|
||||||
return;
|
return;
|
||||||
thread_mutex_lock(&er->lock);
|
igloo_thread_mutex_lock(&er->lock);
|
||||||
er->refcount--;
|
er->refcount--;
|
||||||
|
|
||||||
if (er->refcount) {
|
if (er->refcount) {
|
||||||
thread_mutex_unlock(&er->lock);
|
igloo_thread_mutex_unlock(&er->lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ void event_registration_release(event_registration_t *er) {
|
|||||||
if (er->free)
|
if (er->free)
|
||||||
er->free(er->state);
|
er->free(er->state);
|
||||||
|
|
||||||
thread_mutex_unlock(&er->lock);
|
igloo_thread_mutex_unlock(&er->lock);
|
||||||
igloo_thread_mutex_destroy(&er->lock);
|
igloo_thread_mutex_destroy(&er->lock);
|
||||||
free(er);
|
free(er);
|
||||||
}
|
}
|
||||||
@ -329,21 +329,21 @@ void event_registration_push(event_registration_t **er, event_registration_t *ta
|
|||||||
}
|
}
|
||||||
|
|
||||||
event_registration_addref(cur = *er);
|
event_registration_addref(cur = *er);
|
||||||
thread_mutex_lock(&cur->lock);
|
igloo_thread_mutex_lock(&cur->lock);
|
||||||
while (1) {
|
while (1) {
|
||||||
next = cur->next;
|
next = cur->next;
|
||||||
if (!cur->next)
|
if (!cur->next)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
event_registration_addref(next);
|
event_registration_addref(next);
|
||||||
thread_mutex_unlock(&cur->lock);
|
igloo_thread_mutex_unlock(&cur->lock);
|
||||||
event_registration_release(cur);
|
event_registration_release(cur);
|
||||||
cur = next;
|
cur = next;
|
||||||
thread_mutex_lock(&cur->lock);
|
igloo_thread_mutex_lock(&cur->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_registration_addref(cur->next = tail);
|
event_registration_addref(cur->next = tail);
|
||||||
thread_mutex_unlock(&cur->lock);
|
igloo_thread_mutex_unlock(&cur->lock);
|
||||||
event_registration_release(cur);
|
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) {
|
void event_emit(event_t *event) {
|
||||||
fastevent_emit(FASTEVENT_TYPE_SLOWEVENT, FASTEVENT_FLAG_NONE, FASTEVENT_DATATYPE_EVENT, event);
|
fastevent_emit(FASTEVENT_TYPE_SLOWEVENT, FASTEVENT_FLAG_NONE, FASTEVENT_DATATYPE_EVENT, event);
|
||||||
event_addref(event);
|
event_addref(event);
|
||||||
thread_mutex_lock(&event_lock);
|
igloo_thread_mutex_lock(&event_lock);
|
||||||
event_push(&event_queue, event);
|
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
|
/* this function needs to extract all the info from the client, source and mount object
|
||||||
|
@ -103,12 +103,12 @@ static void __unregister(refobject_t self, void **userdata)
|
|||||||
|
|
||||||
(void)userdata;
|
(void)userdata;
|
||||||
|
|
||||||
thread_rwlock_wlock(&fastevent_lock);
|
igloo_thread_rwlock_wlock(&fastevent_lock);
|
||||||
row = __get_row(registration->type);
|
row = __get_row(registration->type);
|
||||||
if (__remove_from_row(row, registration) != 0) {
|
if (__remove_from_row(row, registration) != 0) {
|
||||||
ICECAST_LOG_ERROR("Can not remove fast event from row. BUG.");
|
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)
|
if (registration->freecb)
|
||||||
registration->freecb(&(registration->userdata));
|
registration->freecb(&(registration->userdata));
|
||||||
@ -119,7 +119,7 @@ static void __unregister(refobject_t self, void **userdata)
|
|||||||
|
|
||||||
int fastevent_initialize(void)
|
int fastevent_initialize(void)
|
||||||
{
|
{
|
||||||
thread_rwlock_create(&fastevent_lock);
|
igloo_thread_rwlock_create(&fastevent_lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ int fastevent_shutdown(void)
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
thread_rwlock_wlock(&fastevent_lock);
|
igloo_thread_rwlock_wlock(&fastevent_lock);
|
||||||
for (i = 0; i < FASTEVENT_TYPE__END; i++) {
|
for (i = 0; i < FASTEVENT_TYPE__END; i++) {
|
||||||
if (fastevent_registrations[i].used) {
|
if (fastevent_registrations[i].used) {
|
||||||
ICECAST_LOG_ERROR("Subsystem shutdown but elements still in use. BUG.");
|
ICECAST_LOG_ERROR("Subsystem shutdown but elements still in use. BUG.");
|
||||||
@ -137,7 +137,7 @@ int fastevent_shutdown(void)
|
|||||||
free(fastevent_registrations[i].registrations);
|
free(fastevent_registrations[i].registrations);
|
||||||
fastevent_registrations[i].registrations = NULL;
|
fastevent_registrations[i].registrations = NULL;
|
||||||
}
|
}
|
||||||
thread_rwlock_unlock(&fastevent_lock);
|
igloo_thread_rwlock_unlock(&fastevent_lock);
|
||||||
igloo_thread_rwlock_destroy(&fastevent_lock);
|
igloo_thread_rwlock_destroy(&fastevent_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -155,18 +155,18 @@ refobject_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fasteve
|
|||||||
if (cb == NULL)
|
if (cb == NULL)
|
||||||
return REFOBJECT_NULL;
|
return REFOBJECT_NULL;
|
||||||
|
|
||||||
thread_rwlock_wlock(&fastevent_lock);
|
igloo_thread_rwlock_wlock(&fastevent_lock);
|
||||||
row = __get_row(type);
|
row = __get_row(type);
|
||||||
|
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
thread_rwlock_unlock(&fastevent_lock);
|
igloo_thread_rwlock_unlock(&fastevent_lock);
|
||||||
return REFOBJECT_NULL;
|
return REFOBJECT_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
registration = refobject_new__new(fastevent_registration_t, NULL, NULL, NULL);
|
registration = refobject_new__new(fastevent_registration_t, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (!registration) {
|
if (!registration) {
|
||||||
thread_rwlock_unlock(&fastevent_lock);
|
igloo_thread_rwlock_unlock(&fastevent_lock);
|
||||||
return REFOBJECT_NULL;
|
return REFOBJECT_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,12 +176,12 @@ refobject_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fasteve
|
|||||||
registration->userdata = userdata;
|
registration->userdata = userdata;
|
||||||
|
|
||||||
if (__add_to_row(row, registration) != 0) {
|
if (__add_to_row(row, registration) != 0) {
|
||||||
thread_rwlock_unlock(&fastevent_lock);
|
igloo_thread_rwlock_unlock(&fastevent_lock);
|
||||||
refobject_unref(REFOBJECT_FROM_TYPE(registration));
|
refobject_unref(REFOBJECT_FROM_TYPE(registration));
|
||||||
return REFOBJECT_NULL;
|
return REFOBJECT_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_rwlock_unlock(&fastevent_lock);
|
igloo_thread_rwlock_unlock(&fastevent_lock);
|
||||||
return REFOBJECT_FROM_TYPE(registration);
|
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);
|
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);
|
row = __get_row(type);
|
||||||
if (row == NULL || row->used == 0) {
|
if (row == NULL || row->used == 0) {
|
||||||
thread_rwlock_unlock(&fastevent_lock);
|
igloo_thread_rwlock_unlock(&fastevent_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ void fastevent_emit(fastevent_type_t type, fastevent_flag_t flags, fastevent_dat
|
|||||||
va_end(apx);
|
va_end(apx);
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_rwlock_unlock(&fastevent_lock);
|
igloo_thread_rwlock_unlock(&fastevent_lock);
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ static int format_prepare_headers (source_t *source, client_t *client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bytes < 0 || (size_t)bytes >= remaining) {
|
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);
|
ICECAST_LOG_ERROR("Can not allocate headers for client %p", client);
|
||||||
client->respcode = 500;
|
client->respcode = 500;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -117,7 +117,7 @@ int format_mp3_get_plugin(source_t *source)
|
|||||||
|
|
||||||
vorbis_comment_init(&plugin->vc);
|
vorbis_comment_init(&plugin->vc);
|
||||||
source->format = plugin;
|
source->format = plugin;
|
||||||
thread_mutex_create(&state->url_lock);
|
igloo_thread_mutex_create(&state->url_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -129,12 +129,12 @@ static void mp3_set_tag (format_plugin_t *plugin, const char *tag, const char *i
|
|||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
/* protect against multiple updaters */
|
/* protect against multiple updaters */
|
||||||
thread_mutex_lock (&source_mp3->url_lock);
|
igloo_thread_mutex_lock (&source_mp3->url_lock);
|
||||||
|
|
||||||
if (tag==NULL)
|
if (tag==NULL)
|
||||||
{
|
{
|
||||||
source_mp3->update_metadata = 1;
|
source_mp3->update_metadata = 1;
|
||||||
thread_mutex_unlock (&source_mp3->url_lock);
|
igloo_thread_mutex_unlock (&source_mp3->url_lock);
|
||||||
return;
|
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);
|
format_set_vorbiscomment(plugin, tag, value);
|
||||||
free (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;
|
mp3_state *source_mp3 = source->format->_state;
|
||||||
|
|
||||||
/* make sure the url data does not disappear from under us */
|
/* 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 */
|
/* work out message length */
|
||||||
if (url_artist)
|
if (url_artist)
|
||||||
@ -262,7 +262,7 @@ static void mp3_set_title(source_t *source)
|
|||||||
#define MAX_META_LEN 255*16
|
#define MAX_META_LEN 255*16
|
||||||
if (len > MAX_META_LEN)
|
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);
|
ICECAST_LOG_WARN("Metadata too long at %d chars", len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -308,7 +308,7 @@ static void mp3_set_title(source_t *source)
|
|||||||
refbuf_release (source_mp3->metadata);
|
refbuf_release (source_mp3->metadata);
|
||||||
source_mp3->metadata = p;
|
source_mp3->metadata = p;
|
||||||
}
|
}
|
||||||
thread_mutex_unlock (&source_mp3->url_lock);
|
igloo_thread_mutex_unlock (&source_mp3->url_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -629,7 +629,7 @@ static void fserve_add_pending (fserve_t *fclient)
|
|||||||
{
|
{
|
||||||
run_fserv = 1;
|
run_fserv = 1;
|
||||||
ICECAST_LOG_DEBUG("fserve handler waking up");
|
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);
|
igloo_thread_spin_unlock (&pending_lock);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ void global_initialize(void)
|
|||||||
global.sources = 0;
|
global.sources = 0;
|
||||||
global.source_tree = igloo_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);
|
global.modulecontainer = refobject_new(module_container_t);
|
||||||
thread_mutex_create(&_global_mutex);
|
igloo_thread_mutex_create(&_global_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void global_shutdown(void)
|
void global_shutdown(void)
|
||||||
@ -52,10 +52,10 @@ void global_shutdown(void)
|
|||||||
|
|
||||||
void global_lock(void)
|
void global_lock(void)
|
||||||
{
|
{
|
||||||
thread_mutex_lock(&_global_mutex);
|
igloo_thread_mutex_lock(&_global_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void global_unlock(void)
|
void global_unlock(void)
|
||||||
{
|
{
|
||||||
thread_mutex_unlock(&_global_mutex);
|
igloo_thread_mutex_unlock(&_global_mutex);
|
||||||
}
|
}
|
||||||
|
@ -144,9 +144,9 @@ static void __listensocket_container_clear_sockets(listensocket_container_t *sel
|
|||||||
static void __listensocket_container_free(refobject_t self, void **userdata)
|
static void __listensocket_container_free(refobject_t self, void **userdata)
|
||||||
{
|
{
|
||||||
listensocket_container_t *container = REFOBJECT_TO_TYPE(self, listensocket_container_t *);
|
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);
|
__listensocket_container_clear_sockets(container);
|
||||||
thread_mutex_unlock(&container->lock);
|
igloo_thread_mutex_unlock(&container->lock);
|
||||||
igloo_thread_mutex_destroy(&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_cb = NULL;
|
||||||
ret->sockcount_userdata = NULL;
|
ret->sockcount_userdata = NULL;
|
||||||
|
|
||||||
thread_mutex_create(&ret->lock);
|
igloo_thread_mutex_create(&ret->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -201,9 +201,9 @@ int listensocket_container_configure(listensocket_contai
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
ret = listensocket_container_configure__unlocked(self, config);
|
ret = listensocket_container_configure__unlocked(self, config);
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -276,7 +276,7 @@ int listensocket_container_configure_and_setup(listensoc
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
cb = self->sockcount_cb;
|
cb = self->sockcount_cb;
|
||||||
self->sockcount_cb = NULL;
|
self->sockcount_cb = NULL;
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ int listensocket_container_configure_and_setup(listensoc
|
|||||||
|
|
||||||
self->sockcount_cb = cb;
|
self->sockcount_cb = cb;
|
||||||
__call_sockcount_cb(self);
|
__call_sockcount_cb(self);
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -300,9 +300,9 @@ int listensocket_container_setup(listensocket_container_
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
ret = listensocket_container_setup__unlocked(self);
|
ret = listensocket_container_setup__unlocked(self);
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -432,10 +432,10 @@ connection_t * listensocket_container_accept(listensocket_container
|
|||||||
if (!self)
|
if (!self)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
ls = listensocket_container_accept__inner(self, timeout);
|
ls = listensocket_container_accept__inner(self, timeout);
|
||||||
refobject_ref(ls);
|
refobject_ref(ls);
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
ret = listensocket_accept(ls, self);
|
ret = listensocket_accept(ls, self);
|
||||||
refobject_unref(ls);
|
refobject_unref(ls);
|
||||||
@ -448,10 +448,10 @@ int listensocket_container_set_sockcount_cb(listensocket
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
self->sockcount_cb = cb;
|
self->sockcount_cb = cb;
|
||||||
self->sockcount_userdata = userdata;
|
self->sockcount_userdata = userdata;
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -463,9 +463,9 @@ ssize_t listensocket_container_sockcount(listensocket_contai
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
ret = listensocket_container_sockcount__unlocked(self);
|
ret = listensocket_container_sockcount__unlocked(self);
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -513,7 +513,7 @@ static void __listensocket_free(refobject_t self, void **userdata)
|
|||||||
{
|
{
|
||||||
listensocket_t *listensocket = REFOBJECT_TO_TYPE(self, listensocket_t *);
|
listensocket_t *listensocket = REFOBJECT_TO_TYPE(self, listensocket_t *);
|
||||||
|
|
||||||
thread_mutex_lock(&listensocket->lock);
|
igloo_thread_mutex_lock(&listensocket->lock);
|
||||||
|
|
||||||
if (listensocket->sockrefc) {
|
if (listensocket->sockrefc) {
|
||||||
ICECAST_LOG_ERROR("BUG: listensocket->sockrefc == 0 && listensocket->sockrefc == %zu", 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)));
|
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)));
|
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);
|
igloo_thread_rwlock_destroy(&listensocket->listener_rwlock);
|
||||||
thread_mutex_unlock(&listensocket->lock);
|
igloo_thread_mutex_unlock(&listensocket->lock);
|
||||||
igloo_thread_mutex_destroy(&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;
|
self->sock = igloo_SOCK_ERROR;
|
||||||
|
|
||||||
thread_mutex_create(&self->lock);
|
igloo_thread_mutex_create(&self->lock);
|
||||||
thread_rwlock_create(&self->listener_rwlock);
|
igloo_thread_rwlock_create(&self->listener_rwlock);
|
||||||
|
|
||||||
self->listener = config_copy_listener_one(listener);
|
self->listener = config_copy_listener_one(listener);
|
||||||
if (self->listener == NULL) {
|
if (self->listener == NULL) {
|
||||||
@ -565,9 +565,9 @@ static int listensocket_apply_config(listensocket_t *self)
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
ret = listensocket_apply_config__unlocked(self);
|
ret = listensocket_apply_config__unlocked(self);
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -579,7 +579,7 @@ static int listensocket_apply_config__unlocked(listensocket_t *self
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_rwlock_wlock(&self->listener_rwlock);
|
igloo_thread_rwlock_wlock(&self->listener_rwlock);
|
||||||
if (self->listener_update) {
|
if (self->listener_update) {
|
||||||
if (__listener_cmp(self->listener, self->listener_update) != 1) {
|
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",
|
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>"),
|
__string_default(self->listener_update->bind_address, "<ANY>"),
|
||||||
self->listener_update->port
|
self->listener_update->port
|
||||||
);
|
);
|
||||||
thread_rwlock_unlock(&self->listener_rwlock);
|
igloo_thread_rwlock_unlock(&self->listener_rwlock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,7 +612,7 @@ static int listensocket_apply_config__unlocked(listensocket_t *self
|
|||||||
self->listener_update = NULL;
|
self->listener_update = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_rwlock_unlock(&self->listener_rwlock);
|
igloo_thread_rwlock_unlock(&self->listener_rwlock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -628,10 +628,10 @@ static int listensocket_set_update(listensocket_t *self, const list
|
|||||||
if (n == NULL)
|
if (n == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
while ((self->listener_update = config_clear_listener(self->listener_update)));
|
while ((self->listener_update = config_clear_listener(self->listener_update)));
|
||||||
self->listener_update = n;
|
self->listener_update = n;
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,38 +640,38 @@ int listensocket_refsock(listensocket_t *self)
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
if (self->sockrefc) {
|
if (self->sockrefc) {
|
||||||
self->sockrefc++;
|
self->sockrefc++;
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return 0;
|
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);
|
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) {
|
if (self->sock == igloo_SOCK_ERROR) {
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__socket_listen(self->sock, self->listener) == 0) {
|
if (__socket_listen(self->sock, self->listener) == 0) {
|
||||||
igloo_sock_close(self->sock);
|
igloo_sock_close(self->sock);
|
||||||
self->sock = igloo_SOCK_ERROR;
|
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);
|
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);
|
igloo_thread_rwlock_unlock(&self->listener_rwlock);
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listensocket_apply_config__unlocked(self) == -1) {
|
if (listensocket_apply_config__unlocked(self) == -1) {
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->sockrefc++;
|
self->sockrefc++;
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -681,21 +681,21 @@ int listensocket_unrefsock(listensocket_t *self)
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
self->sockrefc--;
|
self->sockrefc--;
|
||||||
if (self->sockrefc) {
|
if (self->sockrefc) {
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->sock == igloo_SOCK_ERROR) {
|
if (self->sock == igloo_SOCK_ERROR) {
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
igloo_sock_close(self->sock);
|
igloo_sock_close(self->sock);
|
||||||
self->sock = igloo_SOCK_ERROR;
|
self->sock = igloo_SOCK_ERROR;
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -714,9 +714,9 @@ connection_t * listensocket_accept(listensocket_t *self, listensock
|
|||||||
if (!ip)
|
if (!ip)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
sock = igloo_sock_accept(self->sock, ip, MAX_ADDR_LEN);
|
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) {
|
if (sock == igloo_SOCK_ERROR) {
|
||||||
free(ip);
|
free(ip);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -761,10 +761,10 @@ const listener_t * listensocket_get_listener(listensocket_t *self)
|
|||||||
if (!self)
|
if (!self)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
thread_rwlock_rlock(&self->listener_rwlock);
|
igloo_thread_rwlock_rlock(&self->listener_rwlock);
|
||||||
ret = self->listener;
|
ret = self->listener;
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -781,7 +781,7 @@ int listensocket_release_listener(listensocket_t *self)
|
|||||||
* waiting for a wlock to be come available.
|
* waiting for a wlock to be come available.
|
||||||
* -- ph3-der-loewe, 2018-05-11
|
* -- ph3-der-loewe, 2018-05-11
|
||||||
*/
|
*/
|
||||||
thread_rwlock_unlock(&self->listener_rwlock);
|
igloo_thread_rwlock_unlock(&self->listener_rwlock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -793,9 +793,9 @@ listener_type_t listensocket_get_type(listensocket_t *self)
|
|||||||
if (!self)
|
if (!self)
|
||||||
return LISTENER_TYPE_ERROR;
|
return LISTENER_TYPE_ERROR;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
ret = self->listener->type;
|
ret = self->listener->type;
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -806,9 +806,9 @@ static inline int listensocket__poll_fill(listensocket_t *self, struct pollfd *p
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
if (self->sock == igloo_SOCK_ERROR) {
|
if (self->sock == igloo_SOCK_ERROR) {
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -817,7 +817,7 @@ static inline int listensocket__poll_fill(listensocket_t *self, struct pollfd *p
|
|||||||
p->events = POLLIN;
|
p->events = POLLIN;
|
||||||
p->revents = 0;
|
p->revents = 0;
|
||||||
|
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -827,9 +827,9 @@ static inline int listensocket__select_set(listensocket_t *self, fd_set *set, in
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
if (self->sock == igloo_SOCK_ERROR) {
|
if (self->sock == igloo_SOCK_ERROR) {
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,7 +837,7 @@ static inline int listensocket__select_set(listensocket_t *self, fd_set *set, in
|
|||||||
*max = self->sock;
|
*max = self->sock;
|
||||||
|
|
||||||
FD_SET(self->sock, set);
|
FD_SET(self->sock, set);
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -848,13 +848,13 @@ static inline int listensocket__select_isset(listensocket_t *self, fd_set *set)
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&self->lock);
|
igloo_thread_mutex_lock(&self->lock);
|
||||||
if (self->sock == igloo_SOCK_ERROR) {
|
if (self->sock == igloo_SOCK_ERROR) {
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = FD_ISSET(self->sock, set);
|
ret = FD_ISSET(self->sock, set);
|
||||||
thread_mutex_unlock(&self->lock);
|
igloo_thread_mutex_unlock(&self->lock);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
34
src/module.c
34
src/module.c
@ -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*);
|
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);
|
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)
|
if (refobject_ref(module) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&(self->lock));
|
igloo_thread_mutex_lock(&(self->lock));
|
||||||
igloo_avl_insert(self->module, module);
|
igloo_avl_insert(self->module, module);
|
||||||
thread_mutex_unlock(&(self->lock));
|
igloo_thread_mutex_unlock(&(self->lock));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -92,9 +92,9 @@ int module_container_delete_module(module_container_t *self,
|
|||||||
if (!module)
|
if (!module)
|
||||||
return -1;
|
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);
|
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);
|
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);
|
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) {
|
if (igloo_avl_get_by_key(self->module, REFOBJECT_TO_TYPE(search, void *), (void**)&ret) != 0) {
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&(self->lock));
|
igloo_thread_mutex_unlock(&(self->lock));
|
||||||
|
|
||||||
refobject_unref(search);
|
refobject_unref(search);
|
||||||
refobject_ref(ret);
|
refobject_ref(ret);
|
||||||
@ -135,7 +135,7 @@ xmlNodePtr module_container_get_modulelist_as_xml(module_co
|
|||||||
if (!root)
|
if (!root)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_mutex_lock(&(self->lock));
|
igloo_thread_mutex_lock(&(self->lock));
|
||||||
avlnode = igloo_avl_get_first(self->module);
|
avlnode = igloo_avl_get_first(self->module);
|
||||||
while (avlnode) {
|
while (avlnode) {
|
||||||
module_t *module = avlnode->key;
|
module_t *module = avlnode->key;
|
||||||
@ -149,7 +149,7 @@ xmlNodePtr module_container_get_modulelist_as_xml(module_co
|
|||||||
|
|
||||||
avlnode = igloo_avl_get_next(avlnode);
|
avlnode = igloo_avl_get_next(avlnode);
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&(self->lock));
|
igloo_thread_mutex_unlock(&(self->lock));
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ module_t * module_new(const char *name, module_setup_handler_t newc
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_mutex_create(&(ret->lock));
|
igloo_thread_mutex_create(&(ret->lock));
|
||||||
|
|
||||||
ret->userdata = userdata;
|
ret->userdata = userdata;
|
||||||
ret->freecb = freecb;
|
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_url);
|
||||||
free(self->management_link_title);
|
free(self->management_link_title);
|
||||||
|
|
||||||
self->management_link_url = n_url;
|
self->management_link_url = n_url;
|
||||||
self->management_link_title = n_title;
|
self->management_link_title = n_title;
|
||||||
thread_mutex_unlock(&(self->lock));
|
igloo_thread_mutex_unlock(&(self->lock));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -239,14 +239,14 @@ const module_client_handler_t * module_get_client_handler(module_t *self, const
|
|||||||
if (!self || !name)
|
if (!self || !name)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_mutex_lock(&(self->lock));
|
igloo_thread_mutex_lock(&(self->lock));
|
||||||
for (i = 0; i < self->client_handlers_len; i++) {
|
for (i = 0; i < self->client_handlers_len; i++) {
|
||||||
if (self->client_handlers[i].name && strcmp(self->client_handlers[i].name, name) == 0) {
|
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]);
|
return &(self->client_handlers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&(self->lock));
|
igloo_thread_mutex_unlock(&(self->lock));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -256,10 +256,10 @@ int module_add_client_handler(module_t *self, const
|
|||||||
if (!self)
|
if (!self)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&(self->lock));
|
igloo_thread_mutex_lock(&(self->lock));
|
||||||
self->client_handlers = handlers;
|
self->client_handlers = handlers;
|
||||||
self->client_handlers_len = len;
|
self->client_handlers_len = len;
|
||||||
thread_mutex_unlock(&(self->lock));
|
igloo_thread_mutex_unlock(&(self->lock));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ refobject_t refobject_new__real(const refobject_type_t *type, void *userdata
|
|||||||
ret->refc = 1;
|
ret->refc = 1;
|
||||||
ret->userdata = userdata;
|
ret->userdata = userdata;
|
||||||
|
|
||||||
thread_mutex_create(&(ret->lock));
|
igloo_thread_mutex_create(&(ret->lock));
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
ret->name = strdup(name);
|
ret->name = strdup(name);
|
||||||
@ -105,9 +105,9 @@ int refobject_ref(refobject_t self)
|
|||||||
if (REFOBJECT_IS_NULL(self))
|
if (REFOBJECT_IS_NULL(self))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&(TO_BASE(self)->lock));
|
igloo_thread_mutex_lock(&(TO_BASE(self)->lock));
|
||||||
TO_BASE(self)->refc++;
|
TO_BASE(self)->refc++;
|
||||||
thread_mutex_unlock(&(TO_BASE(self)->lock));
|
igloo_thread_mutex_unlock(&(TO_BASE(self)->lock));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -119,10 +119,10 @@ int refobject_unref(refobject_t self)
|
|||||||
if (REFOBJECT_IS_NULL(self))
|
if (REFOBJECT_IS_NULL(self))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&(base->lock));
|
igloo_thread_mutex_lock(&(base->lock));
|
||||||
base->refc--;
|
base->refc--;
|
||||||
if (base->refc) {
|
if (base->refc) {
|
||||||
thread_mutex_unlock(&(base->lock));
|
igloo_thread_mutex_unlock(&(base->lock));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ int refobject_unref(refobject_t self)
|
|||||||
if (base->name)
|
if (base->name)
|
||||||
free(base->name);
|
free(base->name);
|
||||||
|
|
||||||
thread_mutex_unlock(&(base->lock));
|
igloo_thread_mutex_unlock(&(base->lock));
|
||||||
igloo_thread_mutex_destroy(&(base->lock));
|
igloo_thread_mutex_destroy(&(base->lock));
|
||||||
|
|
||||||
free(base);
|
free(base);
|
||||||
@ -150,9 +150,9 @@ void * refobject_get_userdata(refobject_t self)
|
|||||||
if (REFOBJECT_IS_NULL(self))
|
if (REFOBJECT_IS_NULL(self))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_mutex_lock(&(TO_BASE(self)->lock));
|
igloo_thread_mutex_lock(&(TO_BASE(self)->lock));
|
||||||
ret = TO_BASE(self)->userdata;
|
ret = TO_BASE(self)->userdata;
|
||||||
thread_mutex_unlock(&(TO_BASE(self)->lock));
|
igloo_thread_mutex_unlock(&(TO_BASE(self)->lock));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -162,9 +162,9 @@ int refobject_set_userdata(refobject_t self, void *userdata)
|
|||||||
if (REFOBJECT_IS_NULL(self))
|
if (REFOBJECT_IS_NULL(self))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&(TO_BASE(self)->lock));
|
igloo_thread_mutex_lock(&(TO_BASE(self)->lock));
|
||||||
TO_BASE(self)->userdata = userdata;
|
TO_BASE(self)->userdata = userdata;
|
||||||
thread_mutex_unlock(&(TO_BASE(self)->lock));
|
igloo_thread_mutex_unlock(&(TO_BASE(self)->lock));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -176,9 +176,9 @@ const char * refobject_get_name(refobject_t self)
|
|||||||
if (REFOBJECT_IS_NULL(self))
|
if (REFOBJECT_IS_NULL(self))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_mutex_lock(&(TO_BASE(self)->lock));
|
igloo_thread_mutex_lock(&(TO_BASE(self)->lock));
|
||||||
ret = TO_BASE(self)->name;
|
ret = TO_BASE(self)->name;
|
||||||
thread_mutex_unlock(&(TO_BASE(self)->lock));
|
igloo_thread_mutex_unlock(&(TO_BASE(self)->lock));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -190,9 +190,9 @@ refobject_t refobject_get_associated(refobject_t self)
|
|||||||
if (REFOBJECT_IS_NULL(self))
|
if (REFOBJECT_IS_NULL(self))
|
||||||
return REFOBJECT_NULL;
|
return REFOBJECT_NULL;
|
||||||
|
|
||||||
thread_mutex_lock(&(TO_BASE(self)->lock));
|
igloo_thread_mutex_lock(&(TO_BASE(self)->lock));
|
||||||
ret = TO_BASE(self)->associated;
|
ret = TO_BASE(self)->associated;
|
||||||
thread_mutex_unlock(&(TO_BASE(self)->lock));
|
igloo_thread_mutex_unlock(&(TO_BASE(self)->lock));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -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*);
|
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);
|
ret->definitions = igloo_avl_tree_new(__compare_definitions, NULL);
|
||||||
if (!ret->definitions)
|
if (!ret->definitions)
|
||||||
@ -1024,7 +1024,7 @@ int reportxml_database_add_report(reportxml_database_t *db,
|
|||||||
if (count < 0)
|
if (count < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
thread_mutex_lock(&(db->lock));
|
igloo_thread_mutex_lock(&(db->lock));
|
||||||
|
|
||||||
for (i = 0; i < (size_t)count; i++) {
|
for (i = 0; i < (size_t)count; i++) {
|
||||||
reportxml_node_t *node = reportxml_node_get_child(root, 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);
|
igloo_avl_insert(db->definitions, copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_mutex_unlock(&(db->lock));
|
igloo_thread_mutex_unlock(&(db->lock));
|
||||||
|
|
||||||
refobject_unref(root);
|
refobject_unref(root);
|
||||||
|
|
||||||
@ -1158,9 +1158,9 @@ static reportxml_node_t * __reportxml_database_build_node_ext(reportxml_dat
|
|||||||
return NULL;
|
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) {
|
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);
|
refobject_unref(search);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1168,10 +1168,10 @@ static reportxml_node_t * __reportxml_database_build_node_ext(reportxml_dat
|
|||||||
refobject_unref(search);
|
refobject_unref(search);
|
||||||
|
|
||||||
if (refobject_ref(found) != 0) {
|
if (refobject_ref(found) != 0) {
|
||||||
thread_mutex_unlock(&(db->lock));
|
igloo_thread_mutex_unlock(&(db->lock));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&(db->lock));
|
igloo_thread_mutex_unlock(&(db->lock));
|
||||||
|
|
||||||
count = reportxml_node_count_child(found);
|
count = reportxml_node_count_child(found);
|
||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
|
58
src/slave.c
58
src/slave.c
@ -191,11 +191,11 @@ static inline relay_t *relay_new(relay_config_t *config)
|
|||||||
*/
|
*/
|
||||||
void slave_update_all_mounts(void)
|
void slave_update_all_mounts(void)
|
||||||
{
|
{
|
||||||
thread_mutex_lock(&_slave_mutex);
|
igloo_thread_mutex_lock(&_slave_mutex);
|
||||||
max_interval = 0;
|
max_interval = 0;
|
||||||
update_all_mounts = 1;
|
update_all_mounts = 1;
|
||||||
update_settings = 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)
|
void slave_rebuild_mounts(void)
|
||||||
{
|
{
|
||||||
thread_mutex_lock(&_slave_mutex);
|
igloo_thread_mutex_lock(&_slave_mutex);
|
||||||
update_settings = 1;
|
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;
|
slave_running = 1;
|
||||||
max_interval = 0;
|
max_interval = 0;
|
||||||
thread_mutex_create (&_slave_mutex);
|
igloo_thread_mutex_create (&_slave_mutex);
|
||||||
_slave_thread_id = thread_create("Slave Thread", _slave_thread, NULL, igloo_THREAD_ATTACHED);
|
_slave_thread_id = igloo_thread_create("Slave Thread", _slave_thread, NULL, igloo_THREAD_ATTACHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slave_shutdown(void)
|
void slave_shutdown(void)
|
||||||
{
|
{
|
||||||
thread_mutex_lock(&_slave_mutex);
|
igloo_thread_mutex_lock(&_slave_mutex);
|
||||||
if (!slave_running) {
|
if (!slave_running) {
|
||||||
thread_mutex_unlock(&_slave_mutex);
|
igloo_thread_mutex_unlock(&_slave_mutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
slave_running = 0;
|
slave_running = 0;
|
||||||
thread_mutex_unlock(&_slave_mutex);
|
igloo_thread_mutex_unlock(&_slave_mutex);
|
||||||
|
|
||||||
ICECAST_LOG_DEBUG("waiting for slave thread");
|
ICECAST_LOG_DEBUG("waiting for slave thread");
|
||||||
igloo_thread_join (_slave_thread_id);
|
igloo_thread_join (_slave_thread_id);
|
||||||
@ -476,13 +476,13 @@ static void *start_relay_stream (void *arg)
|
|||||||
source_clear_source(relay->source);
|
source_clear_source(relay->source);
|
||||||
|
|
||||||
/* cleanup relay, but prevent this relay from starting up again too soon */
|
/* cleanup relay, but prevent this relay from starting up again too soon */
|
||||||
thread_mutex_lock(&_slave_mutex);
|
igloo_thread_mutex_lock(&_slave_mutex);
|
||||||
thread_mutex_lock(&(config_locks()->relay_lock));
|
igloo_thread_mutex_lock(&(config_locks()->relay_lock));
|
||||||
relay->source->on_demand = 0;
|
relay->source->on_demand = 0;
|
||||||
relay->start = time(NULL) + max_interval;
|
relay->start = time(NULL) + max_interval;
|
||||||
relay->cleanup = 1;
|
relay->cleanup = 1;
|
||||||
thread_mutex_unlock(&(config_locks()->relay_lock));
|
igloo_thread_mutex_unlock(&(config_locks()->relay_lock));
|
||||||
thread_mutex_unlock(&_slave_mutex);
|
igloo_thread_mutex_unlock(&_slave_mutex);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -555,7 +555,7 @@ static void check_relay_stream (relay_t *relay)
|
|||||||
|
|
||||||
relay->start = time(NULL) + 5;
|
relay->start = time(NULL) + 5;
|
||||||
relay->running = 1;
|
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);
|
relay, igloo_THREAD_ATTACHED);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -846,7 +846,7 @@ static int update_from_master(ice_config_t *config)
|
|||||||
}
|
}
|
||||||
igloo_sock_close (mastersock);
|
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);
|
cleanup_relays = update_relays (&global.master_relays, new_relays, new_relays_length);
|
||||||
|
|
||||||
relay_check_streams (global.master_relays, cleanup_relays, 0);
|
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);
|
free(new_relays);
|
||||||
|
|
||||||
thread_mutex_unlock (&(config_locks()->relay_lock));
|
igloo_thread_mutex_unlock (&(config_locks()->relay_lock));
|
||||||
|
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
@ -878,10 +878,10 @@ static void *_slave_thread(void *arg)
|
|||||||
|
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
thread_mutex_lock(&_slave_mutex);
|
igloo_thread_mutex_lock(&_slave_mutex);
|
||||||
update_settings = 0;
|
update_settings = 0;
|
||||||
update_all_mounts = 0;
|
update_all_mounts = 0;
|
||||||
thread_mutex_unlock(&_slave_mutex);
|
igloo_thread_mutex_unlock(&_slave_mutex);
|
||||||
|
|
||||||
config = config_get_config();
|
config = config_get_config();
|
||||||
stats_global(config);
|
stats_global(config);
|
||||||
@ -902,17 +902,17 @@ static void *_slave_thread(void *arg)
|
|||||||
global_unlock();
|
global_unlock();
|
||||||
|
|
||||||
igloo_thread_sleep(1000000);
|
igloo_thread_sleep(1000000);
|
||||||
thread_mutex_lock(&_slave_mutex);
|
igloo_thread_mutex_lock(&_slave_mutex);
|
||||||
if (slave_running == 0) {
|
if (slave_running == 0) {
|
||||||
thread_mutex_unlock(&_slave_mutex);
|
igloo_thread_mutex_unlock(&_slave_mutex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&_slave_mutex);
|
igloo_thread_mutex_unlock(&_slave_mutex);
|
||||||
|
|
||||||
++interval;
|
++interval;
|
||||||
|
|
||||||
/* only update relays lists when required */
|
/* only update relays lists when required */
|
||||||
thread_mutex_lock(&_slave_mutex);
|
igloo_thread_mutex_lock(&_slave_mutex);
|
||||||
if (max_interval <= interval)
|
if (max_interval <= interval)
|
||||||
{
|
{
|
||||||
ICECAST_LOG_DEBUG("checking master stream list");
|
ICECAST_LOG_DEBUG("checking master stream list");
|
||||||
@ -922,13 +922,13 @@ static void *_slave_thread(void *arg)
|
|||||||
skip_timer = 1;
|
skip_timer = 1;
|
||||||
interval = 0;
|
interval = 0;
|
||||||
max_interval = config->master_update_interval;
|
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 */
|
/* the connection could take some time, so the lock can drop */
|
||||||
if (update_from_master (config))
|
if (update_from_master (config))
|
||||||
config = config_get_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);
|
cleanup_relays = update_relays(&global.relays, config->relay, config->relay_length);
|
||||||
|
|
||||||
@ -936,22 +936,22 @@ static void *_slave_thread(void *arg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
thread_mutex_unlock(&_slave_mutex);
|
igloo_thread_mutex_unlock(&_slave_mutex);
|
||||||
thread_mutex_lock (&(config_locks()->relay_lock));
|
igloo_thread_mutex_lock (&(config_locks()->relay_lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
relay_check_streams (global.relays, cleanup_relays, skip_timer);
|
relay_check_streams (global.relays, cleanup_relays, skip_timer);
|
||||||
relay_check_streams (global.master_relays, NULL, 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)
|
if (update_settings)
|
||||||
{
|
{
|
||||||
source_recheck_mounts (update_all_mounts);
|
source_recheck_mounts (update_all_mounts);
|
||||||
update_settings = 0;
|
update_settings = 0;
|
||||||
update_all_mounts = 0;
|
update_all_mounts = 0;
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&_slave_mutex);
|
igloo_thread_mutex_unlock(&_slave_mutex);
|
||||||
}
|
}
|
||||||
ICECAST_LOG_INFO("shutting down current relays");
|
ICECAST_LOG_INFO("shutting down current relays");
|
||||||
relay_check_streams (NULL, global.relays, 0);
|
relay_check_streams (NULL, global.relays, 0);
|
||||||
|
30
src/source.c
30
src/source.c
@ -107,7 +107,7 @@ source_t *source_reserve (const char *mount)
|
|||||||
/* make duplicates for strings or similar */
|
/* make duplicates for strings or similar */
|
||||||
src->mount = strdup(mount);
|
src->mount = strdup(mount);
|
||||||
src->max_listeners = -1;
|
src->max_listeners = -1;
|
||||||
thread_mutex_create(&src->lock);
|
igloo_thread_mutex_create(&src->lock);
|
||||||
|
|
||||||
igloo_avl_insert(global.source_tree, src);
|
igloo_avl_insert(global.source_tree, src);
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ void source_move_clients(source_t *source, source_t *dest)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* we don't want the two write locks to deadlock in here */
|
/* 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 */
|
/* 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);
|
ICECAST_LOG_WARN("destination mount %s not running, unable to move clients ", dest->mount);
|
||||||
igloo_avl_tree_unlock (dest->pending_tree);
|
igloo_avl_tree_unlock (dest->pending_tree);
|
||||||
thread_mutex_unlock (&move_clients_mutex);
|
igloo_thread_mutex_unlock (&move_clients_mutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,7 +456,7 @@ void source_move_clients(source_t *source, source_t *dest)
|
|||||||
dest->on_demand_req = 1;
|
dest->on_demand_req = 1;
|
||||||
|
|
||||||
igloo_avl_tree_unlock (dest->pending_tree);
|
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)
|
if (fds == 0)
|
||||||
{
|
{
|
||||||
thread_mutex_lock(&source->lock);
|
igloo_thread_mutex_lock(&source->lock);
|
||||||
if ((source->last_read + (time_t)source->timeout) < current)
|
if ((source->last_read + (time_t)source->timeout) < current)
|
||||||
{
|
{
|
||||||
ICECAST_LOG_DEBUG("last %ld, timeout %d, now %ld", (long)source->last_read,
|
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");
|
ICECAST_LOG_WARN("Disconnecting source due to socket timeout");
|
||||||
source->running = 0;
|
source->running = 0;
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&source->lock);
|
igloo_thread_mutex_unlock(&source->lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
source->last_read = current;
|
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 */
|
/* 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 */
|
/* start off the statistics */
|
||||||
source->listeners = 0;
|
source->listeners = 0;
|
||||||
@ -733,10 +733,10 @@ void source_main (source_t *source)
|
|||||||
source->format->write_buf_to_file(source, refbuf);
|
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 */
|
/* 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)
|
if (source->queue_size > source->queue_size_limit)
|
||||||
remove_from_q = 1;
|
remove_from_q = 1;
|
||||||
thread_mutex_unlock(&source->lock);
|
igloo_thread_mutex_unlock(&source->lock);
|
||||||
|
|
||||||
/* acquire write lock on pending_tree */
|
/* acquire write lock on pending_tree */
|
||||||
igloo_avl_tree_wlock(source->pending_tree);
|
igloo_avl_tree_wlock(source->pending_tree);
|
||||||
@ -916,7 +916,7 @@ static void source_shutdown (source_t *source)
|
|||||||
global_unlock();
|
global_unlock();
|
||||||
|
|
||||||
/* release our hold on the lock so the main thread can continue cleaning up */
|
/* 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)
|
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 */
|
/* skip if source is a fallback to file */
|
||||||
if (source->running && source->client == NULL)
|
if (source->running && source->client == NULL)
|
||||||
{
|
{
|
||||||
stats_event_hidden (source->mount, NULL, 1);
|
stats_event_hidden (source->mount, NULL, 1);
|
||||||
thread_mutex_unlock(&source->lock);
|
igloo_thread_mutex_unlock(&source->lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* set global settings first */
|
/* 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("burst size to %u", source->burst_size);
|
||||||
ICECAST_LOG_DEBUG("source timeout to %u", source->timeout);
|
ICECAST_LOG_DEBUG("source timeout to %u", source->timeout);
|
||||||
ICECAST_LOG_DEBUG("fallback_when_full to %u", source->fallback_when_full);
|
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)
|
if (agent)
|
||||||
stats_event (source->mount, "user_agent", 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);
|
source, igloo_THREAD_DETACHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1443,7 +1443,7 @@ void source_recheck_mounts (int update_all)
|
|||||||
source_t *fallback = source_find_mount (mount->fallback_mount);
|
source_t *fallback = source_find_mount (mount->fallback_mount);
|
||||||
if (fallback == NULL)
|
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);
|
strdup (mount->fallback_mount), igloo_THREAD_DETACHED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
80
src/stats.c
80
src/stats.c
@ -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)
|
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);
|
_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)
|
void stats_initialize(void)
|
||||||
@ -135,15 +135,15 @@ void stats_initialize(void)
|
|||||||
_stats.source_tree = igloo_avl_tree_new(_compare_source_stats, NULL);
|
_stats.source_tree = igloo_avl_tree_new(_compare_source_stats, NULL);
|
||||||
|
|
||||||
/* set up global mutex */
|
/* set up global mutex */
|
||||||
thread_mutex_create(&_stats_mutex);
|
igloo_thread_mutex_create(&_stats_mutex);
|
||||||
|
|
||||||
/* set up stats queues */
|
/* set up stats queues */
|
||||||
event_queue_init(&_global_event_queue);
|
event_queue_init(&_global_event_queue);
|
||||||
thread_mutex_create(&_global_event_mutex);
|
igloo_thread_mutex_create(&_global_event_mutex);
|
||||||
|
|
||||||
/* fire off the stats thread */
|
/* fire off the stats thread */
|
||||||
_stats_running = 1;
|
_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)
|
void stats_shutdown(void)
|
||||||
@ -154,17 +154,17 @@ void stats_shutdown(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* wait for thread to exit */
|
/* wait for thread to exit */
|
||||||
thread_mutex_lock(&_stats_mutex);
|
igloo_thread_mutex_lock(&_stats_mutex);
|
||||||
_stats_running = 0;
|
_stats_running = 0;
|
||||||
thread_mutex_unlock(&_stats_mutex);
|
igloo_thread_mutex_unlock(&_stats_mutex);
|
||||||
igloo_thread_join(_stats_thread_id);
|
igloo_thread_join(_stats_thread_id);
|
||||||
|
|
||||||
/* wait for other threads to shut down */
|
/* wait for other threads to shut down */
|
||||||
do {
|
do {
|
||||||
igloo_thread_sleep(300000);
|
igloo_thread_sleep(300000);
|
||||||
thread_mutex_lock(&_stats_mutex);
|
igloo_thread_mutex_lock(&_stats_mutex);
|
||||||
n = _stats_threads;
|
n = _stats_threads;
|
||||||
thread_mutex_unlock(&_stats_mutex);
|
igloo_thread_mutex_unlock(&_stats_mutex);
|
||||||
} while (n > 0);
|
} while (n > 0);
|
||||||
ICECAST_LOG_INFO("stats thread finished");
|
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;
|
stats_source_t *src = NULL;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
|
||||||
thread_mutex_lock(&_stats_mutex);
|
igloo_thread_mutex_lock(&_stats_mutex);
|
||||||
|
|
||||||
if (source == NULL) {
|
if (source == NULL) {
|
||||||
stats = _find_node(_stats.global_tree, name);
|
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);
|
if (stats) value = (char *)strdup(stats->value);
|
||||||
|
|
||||||
thread_mutex_unlock(&_stats_mutex);
|
igloo_thread_mutex_unlock(&_stats_mutex);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -694,24 +694,24 @@ static void *_stats_thread(void *arg)
|
|||||||
|
|
||||||
ICECAST_LOG_INFO("stats thread started");
|
ICECAST_LOG_INFO("stats thread started");
|
||||||
while (1) {
|
while (1) {
|
||||||
thread_mutex_lock(&_stats_mutex);
|
igloo_thread_mutex_lock(&_stats_mutex);
|
||||||
if (!_stats_running) {
|
if (!_stats_running) {
|
||||||
thread_mutex_unlock(&_stats_mutex);
|
igloo_thread_mutex_unlock(&_stats_mutex);
|
||||||
break;
|
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) {
|
if (_global_event_queue.head != NULL) {
|
||||||
/* grab the next event from the queue */
|
/* grab the next event from the queue */
|
||||||
event = _get_event_from_queue (&_global_event_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)
|
if (event == NULL)
|
||||||
continue;
|
continue;
|
||||||
event->next = NULL;
|
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 */
|
/* check if we are dealing with a global or source event */
|
||||||
if (event->source == NULL)
|
if (event->source == NULL)
|
||||||
@ -724,9 +724,9 @@ static void *_stats_thread(void *arg)
|
|||||||
listener = (event_listener_t *)_event_listeners;
|
listener = (event_listener_t *)_event_listeners;
|
||||||
while (listener) {
|
while (listener) {
|
||||||
copy = _copy_event(event);
|
copy = _copy_event(event);
|
||||||
thread_mutex_lock (&listener->mutex);
|
igloo_thread_mutex_lock (&listener->mutex);
|
||||||
_add_event_to_queue (copy, &listener->queue);
|
_add_event_to_queue (copy, &listener->queue);
|
||||||
thread_mutex_unlock (&listener->mutex);
|
igloo_thread_mutex_unlock (&listener->mutex);
|
||||||
|
|
||||||
listener = listener->next;
|
listener = listener->next;
|
||||||
}
|
}
|
||||||
@ -734,12 +734,12 @@ static void *_stats_thread(void *arg)
|
|||||||
/* now we need to destroy the event */
|
/* now we need to destroy the event */
|
||||||
_free_event(event);
|
_free_event(event);
|
||||||
|
|
||||||
thread_mutex_unlock(&_stats_mutex);
|
igloo_thread_mutex_unlock(&_stats_mutex);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
thread_mutex_unlock(&_global_event_mutex);
|
igloo_thread_mutex_unlock(&_global_event_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
igloo_thread_sleep(300000);
|
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);
|
__add_authstack(config->authstack, root);
|
||||||
config_release_config();
|
config_release_config();
|
||||||
|
|
||||||
thread_mutex_lock(&_stats_mutex);
|
igloo_thread_mutex_lock(&_stats_mutex);
|
||||||
/* general stats first */
|
/* general stats first */
|
||||||
avlnode = igloo_avl_get_first(_stats.global_tree);
|
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);
|
avlnode = igloo_avl_get_next (avlnode);
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&_stats_mutex);
|
igloo_thread_mutex_unlock(&_stats_mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -930,7 +930,7 @@ static void _register_listener (event_listener_t *listener)
|
|||||||
stats_event_t *event;
|
stats_event_t *event;
|
||||||
stats_source_t *source;
|
stats_source_t *source;
|
||||||
|
|
||||||
thread_mutex_lock(&_stats_mutex);
|
igloo_thread_mutex_lock(&_stats_mutex);
|
||||||
|
|
||||||
/* first we fill our queue with the current stats */
|
/* 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;
|
listener->next = (event_listener_t *)_event_listeners;
|
||||||
_event_listeners = listener;
|
_event_listeners = listener;
|
||||||
|
|
||||||
thread_mutex_unlock(&_stats_mutex);
|
igloo_thread_mutex_unlock(&_stats_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *stats_connection(void *arg)
|
void *stats_connection(void *arg)
|
||||||
@ -975,26 +975,26 @@ void *stats_connection(void *arg)
|
|||||||
|
|
||||||
event_queue_init (&listener.queue);
|
event_queue_init (&listener.queue);
|
||||||
/* increment the thread count */
|
/* increment the thread count */
|
||||||
thread_mutex_lock(&_stats_mutex);
|
igloo_thread_mutex_lock(&_stats_mutex);
|
||||||
_stats_threads++;
|
_stats_threads++;
|
||||||
stats_event_args (NULL, "stats", "%d", _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);
|
_register_listener (&listener);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
thread_mutex_lock(&_stats_mutex);
|
igloo_thread_mutex_lock(&_stats_mutex);
|
||||||
if (!_stats_running) {
|
if (!_stats_running) {
|
||||||
thread_mutex_unlock(&_stats_mutex);
|
igloo_thread_mutex_unlock(&_stats_mutex);
|
||||||
break;
|
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);
|
event = _get_event_from_queue (&listener.queue);
|
||||||
thread_mutex_unlock (&listener.mutex);
|
igloo_thread_mutex_unlock (&listener.mutex);
|
||||||
if (event != NULL) {
|
if (event != NULL) {
|
||||||
if (_send_event_to_client(event, client) < 0) {
|
if (_send_event_to_client(event, client) < 0) {
|
||||||
_free_event(event);
|
_free_event(event);
|
||||||
@ -1006,11 +1006,11 @@ void *stats_connection(void *arg)
|
|||||||
igloo_thread_sleep (500000);
|
igloo_thread_sleep (500000);
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_mutex_lock(&_stats_mutex);
|
igloo_thread_mutex_lock(&_stats_mutex);
|
||||||
_unregister_listener (&listener);
|
_unregister_listener (&listener);
|
||||||
_stats_threads--;
|
_stats_threads--;
|
||||||
stats_event_args (NULL, "stats", "%d", _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);
|
igloo_thread_mutex_destroy (&listener.mutex);
|
||||||
client_destroy (client);
|
client_destroy (client);
|
||||||
@ -1030,7 +1030,7 @@ void stats_callback (client_t *client, void *notused)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client_set_queue (client, NULL);
|
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;
|
char *buffer = cur->data;
|
||||||
|
|
||||||
/* now the stats for each source */
|
/* 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);
|
node = igloo_avl_get_first(_stats.source_tree);
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
@ -1190,7 +1190,7 @@ refbuf_t *stats_get_streams (void)
|
|||||||
}
|
}
|
||||||
node = igloo_avl_get_next(node);
|
node = igloo_avl_get_next(node);
|
||||||
}
|
}
|
||||||
thread_mutex_unlock(&_stats_mutex);
|
igloo_thread_mutex_unlock(&_stats_mutex);
|
||||||
cur->len = STREAMLIST_BLKSIZE - remaining;
|
cur->len = STREAMLIST_BLKSIZE - remaining;
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
@ -1205,7 +1205,7 @@ void stats_clear_virtual_mounts (void)
|
|||||||
{
|
{
|
||||||
igloo_avl_node *snode;
|
igloo_avl_node *snode;
|
||||||
|
|
||||||
thread_mutex_lock (&_stats_mutex);
|
igloo_thread_mutex_lock (&_stats_mutex);
|
||||||
snode = igloo_avl_get_first(_stats.source_tree);
|
snode = igloo_avl_get_first(_stats.source_tree);
|
||||||
while (snode)
|
while (snode)
|
||||||
{
|
{
|
||||||
@ -1223,6 +1223,6 @@ void stats_clear_virtual_mounts (void)
|
|||||||
|
|
||||||
snode = igloo_avl_get_next (snode);
|
snode = igloo_avl_get_next (snode);
|
||||||
}
|
}
|
||||||
thread_mutex_unlock (&_stats_mutex);
|
igloo_thread_mutex_unlock (&_stats_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1425,13 +1425,13 @@ struct tm *localtime_r (const time_t *timep, struct tm *result)
|
|||||||
|
|
||||||
if (initialised == 0)
|
if (initialised == 0)
|
||||||
{
|
{
|
||||||
thread_mutex_create (&localtime_lock);
|
igloo_thread_mutex_create (&localtime_lock);
|
||||||
initialised = 1;
|
initialised = 1;
|
||||||
}
|
}
|
||||||
thread_mutex_lock (&localtime_lock);
|
igloo_thread_mutex_lock (&localtime_lock);
|
||||||
tm = localtime (timep);
|
tm = localtime (timep);
|
||||||
memcpy (result, tm, sizeof (*result));
|
memcpy (result, tm, sizeof (*result));
|
||||||
thread_mutex_unlock (&localtime_lock);
|
igloo_thread_mutex_unlock (&localtime_lock);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
12
src/xslt.c
12
src/xslt.c
@ -106,7 +106,7 @@ static xmlChar *admin_URI = NULL;
|
|||||||
void xslt_initialize(void)
|
void xslt_initialize(void)
|
||||||
{
|
{
|
||||||
memset(cache, 0, sizeof(stylesheet_cache_t) * CACHESIZE);
|
memset(cache, 0, sizeof(stylesheet_cache_t) * CACHESIZE);
|
||||||
thread_mutex_create(&xsltlock);
|
igloo_thread_mutex_create(&xsltlock);
|
||||||
xmlInitParser();
|
xmlInitParser();
|
||||||
LIBXML_TEST_VERSION
|
LIBXML_TEST_VERSION
|
||||||
xmlSubstituteEntitiesDefault(1);
|
xmlSubstituteEntitiesDefault(1);
|
||||||
@ -139,7 +139,7 @@ void xslt_clear_cache(void)
|
|||||||
|
|
||||||
ICECAST_LOG_DEBUG("Clearing stylesheet cache.");
|
ICECAST_LOG_DEBUG("Clearing stylesheet cache.");
|
||||||
|
|
||||||
thread_mutex_lock(&xsltlock);
|
igloo_thread_mutex_lock(&xsltlock);
|
||||||
|
|
||||||
for (i = 0; i < CACHESIZE; i++)
|
for (i = 0; i < CACHESIZE; i++)
|
||||||
clear_cache_entry(i);
|
clear_cache_entry(i);
|
||||||
@ -149,7 +149,7 @@ void xslt_clear_cache(void)
|
|||||||
admin_URI = NULL;
|
admin_URI = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_mutex_unlock(&xsltlock);
|
igloo_thread_mutex_unlock(&xsltlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int evict_cache_entry(void) {
|
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);
|
xsltSetGenericErrorFunc("", log_parse_failure);
|
||||||
xsltSetLoaderFunc(custom_loader);
|
xsltSetLoaderFunc(custom_loader);
|
||||||
|
|
||||||
thread_mutex_lock(&xsltlock);
|
igloo_thread_mutex_lock(&xsltlock);
|
||||||
cur = xslt_get_stylesheet(xslfilename);
|
cur = xslt_get_stylesheet(xslfilename);
|
||||||
|
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
{
|
{
|
||||||
thread_mutex_unlock(&xsltlock);
|
igloo_thread_mutex_unlock(&xsltlock);
|
||||||
ICECAST_LOG_ERROR("problem reading stylesheet \"%s\"", xslfilename);
|
ICECAST_LOG_ERROR("problem reading stylesheet \"%s\"", xslfilename);
|
||||||
_send_error(client, ICECAST_ERROR_XSLT_PARSE, status);
|
_send_error(client, ICECAST_ERROR_XSLT_PARSE, status);
|
||||||
return;
|
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);
|
ICECAST_LOG_WARN("problem applying stylesheet \"%s\"", xslfilename);
|
||||||
_send_error(client, ICECAST_ERROR_XSLT_problem, status);
|
_send_error(client, ICECAST_ERROR_XSLT_problem, status);
|
||||||
}
|
}
|
||||||
thread_mutex_unlock (&xsltlock);
|
igloo_thread_mutex_unlock (&xsltlock);
|
||||||
xmlFreeDoc(res);
|
xmlFreeDoc(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
42
src/yp.c
42
src/yp.c
@ -221,7 +221,7 @@ void yp_recheck_config (ice_config_t *config)
|
|||||||
struct yp_server *server;
|
struct yp_server *server;
|
||||||
|
|
||||||
ICECAST_LOG_DEBUG("Updating YP configuration");
|
ICECAST_LOG_DEBUG("Updating YP configuration");
|
||||||
thread_rwlock_rlock (&yp_lock);
|
igloo_thread_rwlock_rlock (&yp_lock);
|
||||||
|
|
||||||
server = (struct yp_server *)active_yps;
|
server = (struct yp_server *)active_yps;
|
||||||
while (server)
|
while (server)
|
||||||
@ -271,21 +271,21 @@ void yp_recheck_config (ice_config_t *config)
|
|||||||
server->remove = 0;
|
server->remove = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thread_rwlock_unlock (&yp_lock);
|
igloo_thread_rwlock_unlock (&yp_lock);
|
||||||
thread_rwlock_wlock(&yp_lock);
|
igloo_thread_rwlock_wlock(&yp_lock);
|
||||||
yp_update = 1;
|
yp_update = 1;
|
||||||
thread_rwlock_unlock(&yp_lock);
|
igloo_thread_rwlock_unlock(&yp_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void yp_initialize(void)
|
void yp_initialize(void)
|
||||||
{
|
{
|
||||||
ice_config_t *config = config_get_config();
|
ice_config_t *config = config_get_config();
|
||||||
thread_rwlock_create (&yp_lock);
|
igloo_thread_rwlock_create (&yp_lock);
|
||||||
thread_mutex_create (&yp_pending_lock);
|
igloo_thread_mutex_create (&yp_pending_lock);
|
||||||
yp_recheck_config (config);
|
yp_recheck_config (config);
|
||||||
config_release_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);
|
(void *)NULL, igloo_THREAD_ATTACHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,7 +735,7 @@ static void *yp_update_thread(void *arg)
|
|||||||
igloo_thread_sleep (200000);
|
igloo_thread_sleep (200000);
|
||||||
|
|
||||||
/* do the YP communication */
|
/* do the YP communication */
|
||||||
thread_rwlock_rlock (&yp_lock);
|
igloo_thread_rwlock_rlock (&yp_lock);
|
||||||
server = (struct yp_server *)active_yps;
|
server = (struct yp_server *)active_yps;
|
||||||
while (server)
|
while (server)
|
||||||
{
|
{
|
||||||
@ -746,8 +746,8 @@ static void *yp_update_thread(void *arg)
|
|||||||
/* update the local YP structure */
|
/* update the local YP structure */
|
||||||
if (yp_update)
|
if (yp_update)
|
||||||
{
|
{
|
||||||
thread_rwlock_unlock(&yp_lock);
|
igloo_thread_rwlock_unlock(&yp_lock);
|
||||||
thread_rwlock_wlock (&yp_lock);
|
igloo_thread_rwlock_wlock (&yp_lock);
|
||||||
check_servers ();
|
check_servers ();
|
||||||
server = (struct yp_server *)active_yps;
|
server = (struct yp_server *)active_yps;
|
||||||
while (server)
|
while (server)
|
||||||
@ -760,7 +760,7 @@ static void *yp_update_thread(void *arg)
|
|||||||
yp_update = 0;
|
yp_update = 0;
|
||||||
}
|
}
|
||||||
running = yp_running;
|
running = yp_running;
|
||||||
thread_rwlock_unlock(&yp_lock);
|
igloo_thread_rwlock_unlock(&yp_lock);
|
||||||
}
|
}
|
||||||
igloo_thread_rwlock_destroy (&yp_lock);
|
igloo_thread_rwlock_destroy (&yp_lock);
|
||||||
igloo_thread_mutex_destroy (&yp_pending_lock);
|
igloo_thread_mutex_destroy (&yp_pending_lock);
|
||||||
@ -887,10 +887,10 @@ void yp_add (const char *mount)
|
|||||||
struct yp_server *server;
|
struct yp_server *server;
|
||||||
|
|
||||||
/* make sure YP thread is not modifying the lists */
|
/* 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 */
|
/* 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;
|
server = (struct yp_server *)active_yps;
|
||||||
while (server)
|
while (server)
|
||||||
{
|
{
|
||||||
@ -917,8 +917,8 @@ void yp_add (const char *mount)
|
|||||||
ICECAST_LOG_DEBUG("YP entry %s already exists", mount);
|
ICECAST_LOG_DEBUG("YP entry %s already exists", mount);
|
||||||
server = server->next;
|
server = server->next;
|
||||||
}
|
}
|
||||||
thread_mutex_unlock (&yp_pending_lock);
|
igloo_thread_mutex_unlock (&yp_pending_lock);
|
||||||
thread_rwlock_unlock (&yp_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;
|
struct yp_server *server = (struct yp_server *)active_yps;
|
||||||
|
|
||||||
thread_rwlock_rlock (&yp_lock);
|
igloo_thread_rwlock_rlock (&yp_lock);
|
||||||
while (server)
|
while (server)
|
||||||
{
|
{
|
||||||
ypdata_t *list = server->mounts;
|
ypdata_t *list = server->mounts;
|
||||||
@ -949,7 +949,7 @@ void yp_remove (const char *mount)
|
|||||||
}
|
}
|
||||||
server = server->next;
|
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;
|
struct yp_server *server = (struct yp_server *)active_yps;
|
||||||
ypdata_t *search_list = NULL;
|
ypdata_t *search_list = NULL;
|
||||||
|
|
||||||
thread_rwlock_rlock (&yp_lock);
|
igloo_thread_rwlock_rlock (&yp_lock);
|
||||||
if (server)
|
if (server)
|
||||||
search_list = server->mounts;
|
search_list = server->mounts;
|
||||||
|
|
||||||
@ -983,16 +983,16 @@ void yp_touch (const char *mount)
|
|||||||
if (server)
|
if (server)
|
||||||
search_list = server->mounts;
|
search_list = server->mounts;
|
||||||
}
|
}
|
||||||
thread_rwlock_unlock (&yp_lock);
|
igloo_thread_rwlock_unlock (&yp_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void yp_shutdown (void)
|
void yp_shutdown (void)
|
||||||
{
|
{
|
||||||
thread_rwlock_wlock(&yp_lock);
|
igloo_thread_rwlock_wlock(&yp_lock);
|
||||||
yp_running = 0;
|
yp_running = 0;
|
||||||
yp_update = 1;
|
yp_update = 1;
|
||||||
thread_rwlock_unlock(&yp_lock);
|
igloo_thread_rwlock_unlock(&yp_lock);
|
||||||
|
|
||||||
if (yp_thread)
|
if (yp_thread)
|
||||||
igloo_thread_join (yp_thread);
|
igloo_thread_join (yp_thread);
|
||||||
|
Loading…
Reference in New Issue
Block a user