diff options
author | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2009-06-16 20:40:33 -0400 |
---|---|---|
committer | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2009-06-16 20:40:33 -0400 |
commit | 2faa76a4840100bebd9532bd47a2755874c5b3a0 (patch) | |
tree | bc7f1814464826096b682d35e7df12a291f90ce9 /socket/tcp-bsd.c | |
parent | 7762ac1194eb0ebd6a8c9ab6a5a5143f225cc640 (diff) | |
download | libnice-2faa76a4840100bebd9532bd47a2755874c5b3a0.tar.gz |
Use a global mutex for all nice agents and use g_source_is_destroyed to avoid the race condition of a source being destroyed while we wait for the mutex
Diffstat (limited to 'socket/tcp-bsd.c')
-rw-r--r-- | socket/tcp-bsd.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/socket/tcp-bsd.c b/socket/tcp-bsd.c index 2b829ba..099718f 100644 --- a/socket/tcp-bsd.c +++ b/socket/tcp-bsd.c @@ -299,7 +299,14 @@ socket_send_more ( TcpPriv *priv = sock->priv; struct to_be_sent *tbs = NULL; - g_static_rec_mutex_lock (&priv->agent->mutex); + agent_lock (); + + if (g_source_is_destroyed (g_main_current_source ())) { + nice_debug ("Source was destroyed. " + "Avoided race condition in tcp-bsd.c:socket_send_more"); + agent_unlock (); + return FALSE; + } while ((tbs = g_queue_pop_head (&priv->send_queue)) != NULL) { int ret; @@ -335,11 +342,11 @@ socket_send_more ( g_source_unref (priv->io_source); priv->io_source = NULL; - g_static_rec_mutex_unlock (&priv->agent->mutex); + agent_unlock (); return FALSE; } - g_static_rec_mutex_unlock (&priv->agent->mutex); + agent_unlock (); return TRUE; } |