Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
spr0cketeer
Icecast-Server
Commits
42889cda
Commit
42889cda
authored
Nov 01, 2018
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Corrected namespace for threading part
parent
b047537e
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
335 additions
and
335 deletions
+335
-335
src/auth.c
src/auth.c
+32
-32
src/auth_htpasswd.c
src/auth_htpasswd.c
+19
-19
src/cfgfile.c
src/cfgfile.c
+7
-7
src/client.c
src/client.c
+2
-2
src/connection.c
src/connection.c
+9
-9
src/event.c
src/event.c
+30
-30
src/fastevent.c
src/fastevent.c
+13
-13
src/format.c
src/format.c
+1
-1
src/format_mp3.c
src/format_mp3.c
+7
-7
src/fserve.c
src/fserve.c
+1
-1
src/global.c
src/global.c
+3
-3
src/listensocket.c
src/listensocket.c
+59
-59
src/module.c
src/module.c
+17
-17
src/refobject.c
src/refobject.c
+14
-14
src/reportxml.c
src/reportxml.c
+7
-7
src/slave.c
src/slave.c
+29
-29
src/source.c
src/source.c
+15
-15
src/stats.c
src/stats.c
+40
-40
src/util.c
src/util.c
+3
-3
src/xslt.c
src/xslt.c
+6
-6
src/yp.c
src/yp.c
+21
-21
No files found.
src/auth.c
View file @
42889cda
...
...
@@ -56,9 +56,9 @@ static volatile unsigned long _current_id = 0;
static
unsigned
long
_next_auth_id
(
void
)
{
unsigned
long
id
;
thread_mutex_lock
(
&
_auth_lock
);
igloo_
thread_mutex_lock
(
&
_auth_lock
);
id
=
_current_id
++
;
thread_mutex_unlock
(
&
_auth_lock
);
igloo_
thread_mutex_unlock
(
&
_auth_lock
);
return
id
;
}
...
...
@@ -169,12 +169,12 @@ static void queue_auth_client (auth_client *auth_user)
if
(
auth
->
immediate
)
{
__handle_auth_client
(
auth
,
auth_user
);
}
else
{
thread_mutex_lock
(
&
auth
->
lock
);
igloo_
thread_mutex_lock
(
&
auth
->
lock
);
*
auth
->
tailp
=
auth_user
;
auth
->
tailp
=
&
auth_user
->
next
;
auth
->
pending_count
++
;
ICECAST_LOG_INFO
(
"auth on %s has %d pending"
,
auth
->
mount
,
auth
->
pending_count
);
thread_mutex_unlock
(
&
auth
->
lock
);
igloo_
thread_mutex_unlock
(
&
auth
->
lock
);
}
}
...
...
@@ -188,21 +188,21 @@ void auth_release (auth_t *authenticator) {
if
(
authenticator
==
NULL
)
return
;
thread_mutex_lock
(
&
authenticator
->
lock
);
igloo_
thread_mutex_lock
(
&
authenticator
->
lock
);
authenticator
->
refcount
--
;
ICECAST_LOG_DEBUG
(
"...refcount on auth_t %s is now %d"
,
authenticator
->
mount
,
(
int
)
authenticator
->
refcount
);
if
(
authenticator
->
refcount
)
{
thread_mutex_unlock
(
&
authenticator
->
lock
);
igloo_
thread_mutex_unlock
(
&
authenticator
->
lock
);
return
;
}
/* cleanup auth thread attached to this auth */
if
(
authenticator
->
running
)
{
authenticator
->
running
=
0
;
thread_mutex_unlock
(
&
authenticator
->
lock
);
igloo_
thread_mutex_unlock
(
&
authenticator
->
lock
);
igloo_thread_join
(
authenticator
->
thread
);
thread_mutex_lock
(
&
authenticator
->
lock
);
igloo_
thread_mutex_lock
(
&
authenticator
->
lock
);
}
if
(
authenticator
->
free
)
...
...
@@ -213,7 +213,7 @@ void auth_release (auth_t *authenticator) {
xmlFree
(
authenticator
->
role
);
if
(
authenticator
->
management_url
)
xmlFree
(
authenticator
->
management_url
);
thread_mutex_unlock
(
&
authenticator
->
lock
);
igloo_
thread_mutex_unlock
(
&
authenticator
->
lock
);
igloo_thread_mutex_destroy
(
&
authenticator
->
lock
);
if
(
authenticator
->
mount
)
free
(
authenticator
->
mount
);
...
...
@@ -234,10 +234,10 @@ void auth_addref (auth_t *authenticator) {
if
(
authenticator
==
NULL
)
return
;
thread_mutex_lock
(
&
authenticator
->
lock
);
igloo_
thread_mutex_lock
(
&
authenticator
->
lock
);
authenticator
->
refcount
++
;
ICECAST_LOG_DEBUG
(
"...refcount on auth_t %s is now %d"
,
authenticator
->
mount
,
(
int
)
authenticator
->
refcount
);
thread_mutex_unlock
(
&
authenticator
->
lock
);
igloo_
thread_mutex_unlock
(
&
authenticator
->
lock
);
}
static
void
auth_client_free
(
auth_client
*
auth_user
)
...
...
@@ -402,10 +402,10 @@ static void *auth_run_thread (void *arg)
ICECAST_LOG_INFO
(
"Authentication thread started"
);
while
(
1
)
{
thread_mutex_lock
(
&
auth
->
lock
);
igloo_
thread_mutex_lock
(
&
auth
->
lock
);
if
(
!
auth
->
running
)
{
thread_mutex_unlock
(
&
auth
->
lock
);
igloo_
thread_mutex_unlock
(
&
auth
->
lock
);
break
;
}
...
...
@@ -416,7 +416,7 @@ static void *auth_run_thread (void *arg)
auth_user
=
(
auth_client
*
)
auth
->
head
;
if
(
auth_user
==
NULL
)
{
thread_mutex_unlock
(
&
auth
->
lock
);
igloo_
thread_mutex_unlock
(
&
auth
->
lock
);
continue
;
}
ICECAST_LOG_DEBUG
(
"%d client(s) pending on %s (role %s)"
,
auth
->
pending_count
,
auth
->
mount
,
auth
->
role
);
...
...
@@ -424,14 +424,14 @@ static void *auth_run_thread (void *arg)
if
(
auth
->
head
==
NULL
)
auth
->
tailp
=
&
auth
->
head
;
auth
->
pending_count
--
;
thread_mutex_unlock
(
&
auth
->
lock
);
igloo_
thread_mutex_unlock
(
&
auth
->
lock
);
auth_user
->
next
=
NULL
;
__handle_auth_client
(
auth
,
auth_user
);
continue
;
}
else
{
thread_mutex_unlock
(
&
auth
->
lock
);
igloo_
thread_mutex_unlock
(
&
auth
->
lock
);
}
igloo_thread_sleep
(
150000
);
}
...
...
@@ -806,7 +806,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
if
(
auth
==
NULL
)
return
NULL
;
thread_mutex_create
(
&
auth
->
lock
);
igloo_
thread_mutex_create
(
&
auth
->
lock
);
auth
->
refcount
=
1
;
auth
->
id
=
_next_auth_id
();
auth
->
type
=
(
char
*
)
xmlGetProp
(
node
,
XMLSTR
(
"type"
));
...
...
@@ -953,7 +953,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
auth
->
tailp
=
&
auth
->
head
;
if
(
!
auth
->
immediate
)
{
auth
->
running
=
1
;
auth
->
thread
=
thread_create
(
"auth thread"
,
auth_run_thread
,
auth
,
igloo_THREAD_ATTACHED
);
auth
->
thread
=
igloo_
thread_create
(
"auth thread"
,
auth_run_thread
,
auth
,
igloo_THREAD_ATTACHED
);
}
}
}
...
...
@@ -1022,7 +1022,7 @@ auth_alter_t auth_str2alter(const char *str)
void
auth_initialise
(
void
)
{
thread_mutex_create
(
&
_auth_lock
);
igloo_
thread_mutex_create
(
&
_auth_lock
);
}
void
auth_shutdown
(
void
)
...
...
@@ -1061,9 +1061,9 @@ void auth_stack_release(auth_stack_t *stack) {
if
(
!
stack
)
return
;
thread_mutex_lock
(
&
stack
->
lock
);
igloo_
thread_mutex_lock
(
&
stack
->
lock
);
stack
->
refcount
--
;
thread_mutex_unlock
(
&
stack
->
lock
);
igloo_
thread_mutex_unlock
(
&
stack
->
lock
);
if
(
stack
->
refcount
)
return
;
...
...
@@ -1077,19 +1077,19 @@ void auth_stack_release(auth_stack_t *stack) {
void
auth_stack_addref
(
auth_stack_t
*
stack
)
{
if
(
!
stack
)
return
;
thread_mutex_lock
(
&
stack
->
lock
);
igloo_
thread_mutex_lock
(
&
stack
->
lock
);
stack
->
refcount
++
;
thread_mutex_unlock
(
&
stack
->
lock
);
igloo_
thread_mutex_unlock
(
&
stack
->
lock
);
}
int
auth_stack_next
(
auth_stack_t
**
stack
)
{
auth_stack_t
*
next
;
if
(
!
stack
||
!*
stack
)
return
-
1
;
thread_mutex_lock
(
&
(
*
stack
)
->
lock
);
igloo_
thread_mutex_lock
(
&
(
*
stack
)
->
lock
);
next
=
(
*
stack
)
->
next
;
auth_stack_addref
(
next
);
thread_mutex_unlock
(
&
(
*
stack
)
->
lock
);
igloo_
thread_mutex_unlock
(
&
(
*
stack
)
->
lock
);
auth_stack_release
(
*
stack
);
*
stack
=
next
;
if
(
!
next
)
...
...
@@ -1107,7 +1107,7 @@ int auth_stack_push(auth_stack_t **stack, auth_t *auth) {
if
(
!
next
)
{
return
-
1
;
}
thread_mutex_create
(
&
next
->
lock
);
igloo_
thread_mutex_create
(
&
next
->
lock
);
next
->
refcount
=
1
;
next
->
auth
=
auth
;
auth_addref
(
auth
);
...
...
@@ -1129,21 +1129,21 @@ int auth_stack_append(auth_stack_t *stack, auth_stack_t *tail) {
return
-
1
;
auth_stack_addref
(
cur
=
stack
);
thread_mutex_lock
(
&
cur
->
lock
);
igloo_
thread_mutex_lock
(
&
cur
->
lock
);
while
(
1
)
{
next
=
cur
->
next
;
if
(
!
cur
->
next
)
break
;
auth_stack_addref
(
next
);
thread_mutex_unlock
(
&
cur
->
lock
);
igloo_
thread_mutex_unlock
(
&
cur
->
lock
);
auth_stack_release
(
cur
);
cur
=
next
;
thread_mutex_lock
(
&
cur
->
lock
);
igloo_
thread_mutex_lock
(
&
cur
->
lock
);
}
auth_stack_addref
(
cur
->
next
=
tail
);
thread_mutex_unlock
(
&
cur
->
lock
);
igloo_
thread_mutex_unlock
(
&
cur
->
lock
);
auth_stack_release
(
cur
);
return
0
;
...
...
@@ -1155,9 +1155,9 @@ auth_t *auth_stack_get(auth_stack_t *stack) {
if
(
!
stack
)
return
NULL
;
thread_mutex_lock
(
&
stack
->
lock
);
igloo_
thread_mutex_lock
(
&
stack
->
lock
);
auth_addref
(
auth
=
stack
->
auth
);
thread_mutex_unlock
(
&
stack
->
lock
);
igloo_
thread_mutex_unlock
(
&
stack
->
lock
);
return
auth
;
}
...
...
src/auth_htpasswd.c
View file @
42889cda
...
...
@@ -121,10 +121,10 @@ static void htpasswd_recheckfile(htpasswd_auth_state *htpasswd)
ICECAST_LOG_WARN
(
"failed to check status of %s"
,
htpasswd
->
filename
);
/* Create a dummy users tree for things to use later */
thread_rwlock_wlock
(
&
htpasswd
->
file_rwlock
);
igloo_
thread_rwlock_wlock
(
&
htpasswd
->
file_rwlock
);
if
(
!
htpasswd
->
users
)
htpasswd
->
users
=
igloo_avl_tree_new
(
compare_users
,
NULL
);
thread_rwlock_unlock
(
&
htpasswd
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
htpasswd
->
file_rwlock
);
return
;
}
...
...
@@ -167,11 +167,11 @@ static void htpasswd_recheckfile(htpasswd_auth_state *htpasswd)
}
fclose
(
passwdfile
);
thread_rwlock_wlock
(
&
htpasswd
->
file_rwlock
);
igloo_
thread_rwlock_wlock
(
&
htpasswd
->
file_rwlock
);
if
(
htpasswd
->
users
)
igloo_avl_tree_free
(
htpasswd
->
users
,
_free_user
);
htpasswd
->
users
=
new_users
;
thread_rwlock_unlock
(
&
htpasswd
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
htpasswd
->
file_rwlock
);
}
...
...
@@ -197,13 +197,13 @@ static auth_result htpasswd_auth (auth_client *auth_user)
return
AUTH_NOMATCH
;
}
thread_rwlock_rlock
(
&
htpasswd
->
file_rwlock
);
igloo_
thread_rwlock_rlock
(
&
htpasswd
->
file_rwlock
);
entry
.
name
=
client
->
username
;
if
(
igloo_avl_get_by_key
(
htpasswd
->
users
,
&
entry
,
&
result
)
==
0
)
{
htpasswd_user
*
found
=
result
;
char
*
hashed_pw
;
thread_rwlock_unlock
(
&
htpasswd
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
htpasswd
->
file_rwlock
);
hashed_pw
=
get_hash
(
client
->
password
,
strlen
(
client
->
password
));
if
(
strcmp
(
found
->
pass
,
hashed_pw
)
==
0
)
{
free
(
hashed_pw
);
...
...
@@ -214,7 +214,7 @@ static auth_result htpasswd_auth (auth_client *auth_user)
return
AUTH_FAILED
;
}
ICECAST_LOG_DEBUG
(
"no such username: %s"
,
client
->
username
);
thread_rwlock_unlock
(
&
htpasswd
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
htpasswd
->
file_rwlock
);
return
AUTH_NOMATCH
;
}
...
...
@@ -248,7 +248,7 @@ int auth_get_htpasswd_auth (auth_t *authenticator, config_options_t *options)
authenticator
->
state
=
state
;
thread_rwlock_create
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_create
(
&
state
->
file_rwlock
);
htpasswd_recheckfile
(
state
);
return
0
;
...
...
@@ -275,18 +275,18 @@ static auth_result htpasswd_adduser (auth_t *auth, const char *username, const c
return
AUTH_FAILED
;
}
thread_rwlock_wlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_wlock
(
&
state
->
file_rwlock
);
entry
.
name
=
(
char
*
)
username
;
if
(
igloo_avl_get_by_key
(
state
->
users
,
&
entry
,
&
result
)
==
0
)
{
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
return
AUTH_USEREXISTS
;
}
passwdfile
=
fopen
(
state
->
filename
,
"ab"
);
if
(
passwdfile
==
NULL
)
{
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
ICECAST_LOG_WARN
(
"Failed to open authentication database
\"
%s
\"
: %s"
,
state
->
filename
,
strerror
(
errno
));
return
AUTH_FAILED
;
...
...
@@ -299,7 +299,7 @@ static auth_result htpasswd_adduser (auth_t *auth, const char *username, const c
}
fclose
(
passwdfile
);
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
return
AUTH_USERADDED
;
}
...
...
@@ -328,13 +328,13 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
return
AUTH_FAILED
;
}
thread_rwlock_wlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_wlock
(
&
state
->
file_rwlock
);
passwdfile
=
fopen
(
state
->
filename
,
"rb"
);
if
(
passwdfile
==
NULL
)
{
ICECAST_LOG_WARN
(
"Failed to open authentication database
\"
%s
\"
: %s"
,
state
->
filename
,
strerror
(
errno
));
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
return
AUTH_FAILED
;
}
tmpfile_len
=
strlen
(
state
->
filename
)
+
6
;
...
...
@@ -344,7 +344,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
ICECAST_LOG_WARN
(
"temp file
\"
%s
\"
exists, rejecting operation"
,
tmpfile
);
free
(
tmpfile
);
fclose
(
passwdfile
);
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
return
AUTH_FAILED
;
}
...
...
@@ -355,7 +355,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
tmpfile
,
strerror
(
errno
));
fclose
(
passwdfile
);
free
(
tmpfile
);
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
return
AUTH_FAILED
;
}
...
...
@@ -395,7 +395,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
}
}
free
(
tmpfile
);
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
htpasswd_recheckfile
(
state
);
return
AUTH_USERDELETED
;
...
...
@@ -422,7 +422,7 @@ static auth_result htpasswd_userlist(auth_t *auth, xmlNodePtr srcnode)
return
AUTH_FAILED
;
}
thread_rwlock_rlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_rlock
(
&
state
->
file_rwlock
);
node
=
igloo_avl_get_first
(
state
->
users
);
while
(
node
)
{
htpasswd_user
*
user
=
(
htpasswd_user
*
)
node
->
key
;
...
...
@@ -430,7 +430,7 @@ static auth_result htpasswd_userlist(auth_t *auth, xmlNodePtr srcnode)
xmlNewTextChild
(
newnode
,
NULL
,
XMLSTR
(
"username"
),
XMLSTR
(
user
->
name
));
node
=
igloo_avl_get_next
(
node
);
}
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
igloo_
thread_rwlock_unlock
(
&
state
->
file_rwlock
);
return
AUTH_OK
;
}
src/cfgfile.c
View file @
42889cda
...
...
@@ -207,8 +207,8 @@ char * config_href_to_id(const char *href)
static
void
create_locks
(
void
)
{
thread_mutex_create
(
&
_locks
.
relay_lock
);
thread_rwlock_create
(
&
_locks
.
config_lock
);
igloo_
thread_mutex_create
(
&
_locks
.
relay_lock
);
igloo_
thread_rwlock_create
(
&
_locks
.
config_lock
);
}
static
void
release_locks
(
void
)
...
...
@@ -668,12 +668,12 @@ void config_clear(ice_config_t *c)
while
((
c
->
listen_sock
=
config_clear_listener
(
c
->
listen_sock
)));
thread_mutex_lock
(
&
(
_locks
.
relay_lock
));
igloo_
thread_mutex_lock
(
&
(
_locks
.
relay_lock
));
for
(
i
=
0
;
i
<
c
->
relay_length
;
i
++
)
{
relay_config_free
(
c
->
relay
[
i
]);
}
free
(
c
->
relay
);
thread_mutex_unlock
(
&
(
_locks
.
relay_lock
));
igloo_
thread_mutex_unlock
(
&
(
_locks
.
relay_lock
));
mount
=
c
->
mounts
;
while
(
mount
)
{
...
...
@@ -797,18 +797,18 @@ ice_config_locks *config_locks(void)
void
config_release_config
(
void
)
{
thread_rwlock_unlock
(
&
(
_locks
.
config_lock
));
igloo_
thread_rwlock_unlock
(
&
(
_locks
.
config_lock
));
}
ice_config_t
*
config_get_config
(
void
)
{
thread_rwlock_rlock
(
&
(
_locks
.
config_lock
));
igloo_
thread_rwlock_rlock
(
&
(
_locks
.
config_lock
));
return
&
_current_configuration
;
}
ice_config_t
*
config_grab_config
(
void
)
{
thread_rwlock_wlock
(
&
(
_locks
.
config_lock
));
igloo_
thread_rwlock_wlock
(
&
(
_locks
.
config_lock
));
return
&
_current_configuration
;
}
...
...
src/client.c
View file @
42889cda
...
...
@@ -414,13 +414,13 @@ void client_send_204(client_t *client)
/* We get a source_t* here as this is likely a reply to OPTIONS and we want
* to have as much infos as possible in that case.
*/
avl_tree_rlock
(
global
.
source_tree
);
igloo_
avl_tree_rlock
(
global
.
source_tree
);
source
=
source_find_mount_raw
(
client
->
uri
);
ret
=
util_http_build_header
(
client
->
refbuf
->
data
,
PER_CLIENT_REFBUF_SIZE
,
0
,
0
,
204
,
NULL
,
NULL
,
NULL
,
NULL
,
source
,
client
);
avl_tree_unlock
(
global
.
source_tree
);
igloo_
avl_tree_unlock
(
global
.
source_tree
);
snprintf
(
client
->
refbuf
->
data
+
ret
,
PER_CLIENT_REFBUF_SIZE
-
ret
,
"Content-Length: 0
\r\n\r\n
"
);
...
...
src/connection.c
View file @
42889cda
...
...
@@ -115,9 +115,9 @@ void connection_initialize(void)
return
;
igloo_thread_spin_create
(
&
_connection_lock
);
thread_mutex_create
(
&
move_clients_mutex
);
thread_rwlock_create
(
&
_source_shutdown_rwlock
);
thread_cond_create
(
&
global
.
shutdown_cond
);
igloo_
thread_mutex_create
(
&
move_clients_mutex
);
igloo_
thread_rwlock_create
(
&
_source_shutdown_rwlock
);
igloo_
thread_cond_create
(
&
global
.
shutdown_cond
);
_req_queue
=
NULL
;
_req_queue_tail
=
&
_req_queue
;
_con_queue
=
NULL
;
...
...
@@ -715,11 +715,11 @@ void connection_accept_loop(void)
}
/* Give all the other threads notification to shut down */
thread_cond_broadcast
(
&
global
.
shutdown_cond
);
igloo_
thread_cond_broadcast
(
&
global
.
shutdown_cond
);
/* wait for all the sources to shutdown */
thread_rwlock_wlock
(
&
_source_shutdown_rwlock
);
thread_rwlock_unlock
(
&
_source_shutdown_rwlock
);
igloo_
thread_rwlock_wlock
(
&
_source_shutdown_rwlock
);
igloo_
thread_rwlock_unlock
(
&
_source_shutdown_rwlock
);
}
...
...
@@ -1069,14 +1069,14 @@ static void _handle_get_request(client_t *client) {
static
void
_handle_delete_request
(
client_t
*
client
)
{
source_t
*
source
;
avl_tree_wlock
(
global
.
source_tree
);
igloo_
avl_tree_wlock
(
global
.
source_tree
);
source
=
source_find_mount_raw
(
client
->
uri
);
if
(
source
)
{
source
->
running
=
0
;
avl_tree_unlock
(
global
.
source_tree
);
igloo_
avl_tree_unlock
(
global
.
source_tree
);
client_send_204
(
client
);
}
else
{
avl_tree_unlock
(
global
.
source_tree
);
igloo_
avl_tree_unlock
(
global
.
source_tree
);
client_send_error_by_id
(
client
,
ICECAST_ERROR_CON_UNKNOWN_REQUEST
);
}
}
...
...
src/event.c
View file @
42889cda
...
...
@@ -36,9 +36,9 @@ static igloo_thread_type *event_thread = NULL;
static
void
event_addref
(
event_t
*
event
)
{
if
(
!
event
)
return
;
thread_mutex_lock
(
&
event_lock
);
igloo_
thread_mutex_lock
(
&
event_lock
);
event
->
refcount
++
;
thread_mutex_unlock
(
&
event_lock
);
igloo_
thread_mutex_unlock
(
&
event_lock
);
}
static
void
event_release
(
event_t
*
event
)
{
...
...
@@ -48,10 +48,10 @@ static void event_release(event_t *event) {
if
(
!
event
)
return
;
thread_mutex_lock
(
&
event_lock
);
igloo_
thread_mutex_lock
(
&
event_lock
);
event
->
refcount
--
;
if
(
event
->
refcount
)
{
thread_mutex_unlock
(
&
event_lock
);
igloo_
thread_mutex_unlock
(
&
event_lock
);
return
;
}
...
...
@@ -66,7 +66,7 @@ static void event_release(event_t *event) {
free
(
event
->
client_useragent
);
to_free
=
event
->
next
;
free
(
event
);
thread_mutex_unlock
(
&
event_lock
);
igloo_
thread_mutex_unlock
(
&
event_lock
);
if
(
to_free
)
event_release
(
to_free
);
...
...
@@ -144,7 +144,7 @@ static inline void _try_registrations(event_registration_t *er, event_t *event)
if
(
!
er
)
return
;
thread_mutex_lock
(
&
er
->
lock
);
igloo_
thread_mutex_lock
(
&
er
->
lock
);
while
(
1
)
{
/* try registration */
_try_event
(
er
,
event
);
...
...
@@ -153,14 +153,14 @@ static inline void _try_registrations(event_registration_t *er, event_t *event)
if
(
er
->
next
)
{
event_registration_t
*
next
=
er
->
next
;
thread_mutex_lock
(
&
next
->
lock
);
thread_mutex_unlock
(
&
er
->
lock
);
igloo_
thread_mutex_lock
(
&
next
->
lock
);
igloo_
thread_mutex_unlock
(
&
er
->
lock
);
er
=
next
;
}
else
{
break
;
}
}
thread_mutex_unlock
(
&
er
->
lock
);
igloo_
thread_mutex_unlock
(
&
er
->
lock
);
}
static
void
*
event_run_thread
(
void
*
arg
)
{
...
...
@@ -172,7 +172,7 @@ static void *event_run_thread (void *arg) {
event_t
*
event
;
size_t
i
;
thread_mutex_lock
(
&
event_lock
);
igloo_
thread_mutex_lock
(
&
event_lock
);
running
=
event_running
;
if
(
event_queue
)
{
event
=
event_queue
;
...
...
@@ -181,7 +181,7 @@ static void *event_run_thread (void *arg) {
}
else
{
event
=
NULL
;
}
thread_mutex_unlock
(
&
event_lock
);
igloo_
thread_mutex_unlock
(
&
event_lock
);
/* sleep if nothing todo and then try again */
if
(
!
event
)
{
...
...
@@ -200,15 +200,15 @@ static void *event_run_thread (void *arg) {
void
event_initialise
(
void
)
{
/* create mutex */
thread_mutex_create
(
&
event_lock
);
igloo_
thread_mutex_create
(
&
event_lock
);
/* initialise everything */
thread_mutex_lock
(
&
event_lock
);
igloo_
thread_mutex_lock
(
&
event_lock
);
event_running
=
1
;
thread_mutex_unlock
(
&
event_lock
);
igloo_
thread_mutex_unlock
(
&
event_lock
);
/* start thread */
event_thread
=
thread_create
(
"events thread"
,
event_run_thread
,
NULL
,
igloo_THREAD_ATTACHED
);
event_thread
=
igloo_
thread_create
(
"events thread"
,
event_run_thread
,
NULL
,
igloo_THREAD_ATTACHED
);
}
void
event_shutdown
(
void
)
{
...
...
@@ -218,19 +218,19 @@ void event_shutdown(void) {
if
(
!
event_running
)
return
;
thread_mutex_lock
(
&
event_lock
);
igloo_
thread_mutex_lock
(
&
event_lock
);
event_running
=
0
;
thread_mutex_unlock
(
&
event_lock
);
igloo_
thread_mutex_unlock
(
&
event_lock
);
/* join thread as soon as it stopped */
igloo_thread_join
(
event_thread
);
/* shutdown everything */
thread_mutex_lock
(
&
event_lock
);
igloo_
thread_mutex_lock
(
&
event_lock
);
event_thread
=
NULL
;
event_queue_to_free
=
event_queue
;
event_queue
=
NULL
;
thread_mutex_unlock
(
&
event_lock
);
igloo_
thread_mutex_unlock
(
&
event_lock
);
event_release
(
event_queue_to_free
);
...
...
@@ -287,19 +287,19 @@ event_registration_t * event_new_from_xml_node(xmlNodePtr node) {
void
event_registration_addref
(
event_registration_t
*
er
)
{
if
(
!
er
)
return
;
thread_mutex_lock
(
&
er
->
lock
);
igloo_
thread_mutex_lock
(
&
er
->
lock
);
er
->
refcount
++
;
thread_mutex_unlock
(
&
er
->
lock
);
igloo_
thread_mutex_unlock
(
&
er
->
lock
);
}
void
event_registration_release
(
event_registration_t
*
er
)
{
if
(
!
er
)
return
;
thread_mutex_lock
(
&
er
->
lock
);
igloo_
thread_mutex_lock
(
&
er
->
lock
);
er
->
refcount
--
;
if
(
er
->
refcount
)
{
thread_mutex_unlock
(
&
er
->
lock
);
igloo_
thread_mutex_unlock
(
&
er
->
lock
);
return
;
}
...
...
@@ -312,7 +312,7 @@ void event_registration_release(event_registration_t *er) {
if
(
er
->
free
)
er
->
free
(
er
->
state
);
thread_mutex_unlock
(
&
er
->
lock
);
igloo_
thread_mutex_unlock
(
&
er
->
lock
);
igloo_thread_mutex_destroy
(
&
er
->
lock
);
free
(
er
);
}
...
...
@@ -329,21 +329,21 @@ void event_registration_push(event_registration_t **er, event_registration_t *ta
}
event_registration_addref
(
cur
=
*
er
);
thread_mutex_lock
(
&
cur
->
lock
);
igloo_