From: Terry Wilson Date: Fri, 15 Oct 2010 16:39:58 +0000 (+0000) Subject: Merged revisions 291904 via svnmerge from X-Git-Tag: 1.8.0-rc4~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=36a672b7e88336ec89e954a1ff77d02a88a4976e;p=thirdparty%2Fasterisk.git Merged revisions 291904 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ........ r291904 | twilson | 2010-10-15 09:16:57 -0700 (Fri, 15 Oct 2010) | 7 lines Don't crash or deadlock on module unload We can't hold the lock while pthread_join is called since aji_log_hook will attempt to lock from the other therad. We reorder the pthread_join and ast_aji_disconnect so that we don't do an SSL_read() while SSL_shutdown is running, causing a crash. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@291905 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/res/res_jabber.c b/res/res_jabber.c index 6b737e70b8..0c463f0c64 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -4695,12 +4695,12 @@ static int unload_module(void) ast_custom_function_unregister(&jabberreceive_function); ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { - ASTOBJ_RDLOCK(iterator); + ASTOBJ_WRLOCK(iterator); ast_debug(3, "JABBER: Releasing and disconnecting client: %s\n", iterator->name); iterator->state = AJI_DISCONNECTING; - ast_aji_disconnect(iterator); - pthread_join(iterator->thread, NULL); ASTOBJ_UNLOCK(iterator); + pthread_join(iterator->thread, NULL); + ast_aji_disconnect(iterator); }); ASTOBJ_CONTAINER_DESTROYALL(&clients, aji_client_destroy);