]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a crash that could occur when handing device state changes.
authorRussell Bryant <russell@russellbryant.com>
Tue, 19 Jun 2007 15:22:36 +0000 (15:22 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 19 Jun 2007 15:22:36 +0000 (15:22 +0000)
When the state of a device changes, the device state thread tells the extension
state handling code that it changed.  Then, the extension state code calls the
callback in chan_sip so that it can update subscriptions to that extension.
A pointer to a sip_pvt structure is passed to this function as the call which
needs a NOTIFY sent.  However, there was no locking done to ensure that the pvt
struct didn't disappear during this process.
(issue #9946, reported by tdonahue, patch by me, patch updated to trunk to use
 the sip_pvt lock wrappers by eliel)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@69944 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 2da9dd7c1c8d0650f8770de35a01e61207c4ed8d..d6f513a642ad2202ed43dc96b9fb97da8b3ec0fe 100644 (file)
@@ -8281,6 +8281,8 @@ static int cb_extensionstate(char *context, char* exten, int state, void *data)
 {
        struct sip_pvt *p = data;
 
+       ast_mutex_lock(&p->lock);
+
        switch(state) {
        case AST_EXTENSION_DEACTIVATED: /* Retry after a while */
        case AST_EXTENSION_REMOVED:     /* Extension is gone */
@@ -8301,6 +8303,9 @@ static int cb_extensionstate(char *context, char* exten, int state, void *data)
 
        if (option_verbose > 1)
                ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s\n", exten, ast_extension_state2str(state), p->username);
+       
+       ast_mutex_unlock(&p->lock);
+
        return 0;
 }