From 7542c4898053f6c15ac58f146f2852e59e592503 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 19 Sep 2008 22:18:50 +0000 Subject: 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 --- pjlib/src/pj/ioqueue_epoll.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pjlib') 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); -- cgit v1.2.3