summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-09-19 22:18:50 +0000
committerBenny Prijono <bennylp@teluu.com>2008-09-19 22:18:50 +0000
commit7542c4898053f6c15ac58f146f2852e59e592503 (patch)
treeebb916534c4ad84c5a199da4e67d0715b3e66271 /pjlib
parentbfbf08032fe10128674555e7b0b7f142607203ea (diff)
Couple of fixes in ioqueue_epoll for ticket #622 (still not working)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2300 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/src/pj/ioqueue_epoll.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/pjlib/src/pj/ioqueue_epoll.c b/pjlib/src/pj/ioqueue_epoll.c
index 90dc3b53..58e3cbe7 100644
--- a/pjlib/src/pj/ioqueue_epoll.c
+++ b/pjlib/src/pj/ioqueue_epoll.c
@@ -253,6 +253,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_create( pj_pool_t *pool,
/* Init key list */
pj_list_init(&ioqueue->free_list);
pj_list_init(&ioqueue->closing_list);
+ pj_list_init(&ioqueue->active_list);
/* Pre-create all keys according to max_fd */
@@ -491,6 +492,14 @@ PJ_DEF(pj_status_t) pj_ioqueue_unregister( pj_ioqueue_key_t *key)
PJ_ASSERT_RETURN(key != NULL, PJ_EINVAL);
ioqueue = key->ioqueue;
+
+ /* Lock the key to make sure no callback is simultaneously modifying
+ * the key. We need to lock the key before ioqueue here to prevent
+ * deadlock.
+ */
+ pj_mutex_lock(key->mutex);
+
+ /* Also lock ioqueue */
pj_lock_acquire(ioqueue->lock);
pj_assert(ioqueue->count > 0);