Merged revisions 51788 via svnmerge from
authorJoshua Colp <jcolp@digium.com>
Tue, 23 Jan 2007 22:59:55 +0000 (22:59 +0000)
committerJoshua Colp <jcolp@digium.com>
Tue, 23 Jan 2007 22:59:55 +0000 (22:59 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r51788 | file | 2007-01-23 17:46:31 -0500 (Tue, 23 Jan 2007) | 2 lines

Update channel drivers to use module referencing so that unloading them while in use will not result in crashes. (issue #8897 reported by junky)

........

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

channels/chan_alsa.c
channels/chan_features.c
channels/chan_gtalk.c
channels/chan_iax2.c
channels/chan_oss.c
channels/chan_phone.c
channels/chan_sip.c
channels/chan_skinny.c
channels/chan_zap.c

index 67c0b66..1651b7d 100644 (file)
@@ -580,6 +580,7 @@ static int alsa_hangup(struct ast_channel *c)
        c->tech_pvt = NULL;
        alsa.owner = NULL;
        ast_verbose(" << Hangup on console >> \n");
+       ast_module_unref(ast_module_info->self);
        if (hookstate) {
                hookstate = 0;
                if (!autoanswer) {
@@ -805,6 +806,7 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state)
        if (!ast_strlen_zero(language))
                ast_string_field_set(tmp, language, language);
        p->owner = tmp;
+       ast_module_ref(ast_module_info->self);
        ast_jb_configure(tmp, &global_jbconf);
        if (state != AST_STATE_DOWN) {
                if (ast_pbx_start(tmp)) {
index c4d82d7..2fb7207 100644 (file)
@@ -490,6 +490,7 @@ static struct ast_channel *features_new(struct feature_pvt *p, int state, int in
        p->subs[index].owner = tmp;
        if (!p->owner)
                p->owner = tmp;
+       ast_module_ref(ast_module_info->self);
        return tmp;
 }
 
index 430601a..fa1d216 100644 (file)
@@ -952,6 +952,7 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
        if (!ast_strlen_zero(client->musicclass))
                ast_string_field_set(tmp, musicclass, client->musicclass);
        i->owner = tmp;
+       ast_module_ref(ast_module_info->self);
        ast_copy_string(tmp->context, client->context, sizeof(tmp->context));
        ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
        /* Don't use ast_set_callerid() here because it will
@@ -1464,6 +1465,7 @@ static int gtalk_hangup(struct ast_channel *ast)
        ast_mutex_unlock(&p->lock);
 
        gtalk_free_pvt(client, p);
+       ast_module_unref(ast_module_info->self);
 
        return 0;
 }
index 5ca3842..c63b155 100644 (file)
@@ -1772,6 +1772,7 @@ static int iax2_predestroy(int callno)
                c->tech_pvt = NULL;
                ast_queue_hangup(c);
                pvt->owner = NULL;
+               ast_module_unref(ast_module_info->self);
        }
 
        return 0;
@@ -3402,6 +3403,7 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
        for (v = i->vars ; v ; v = v->next)
                pbx_builtin_setvar_helper(tmp, v->name, v->value);
 
+       ast_module_ref(ast_module_info->self);
        return tmp;
 }
 
index fb869cb..470c4ae 100644 (file)
@@ -865,6 +865,7 @@ static int oss_hangup(struct ast_channel *c)
        c->tech_pvt = NULL;
        o->owner = NULL;
        ast_verbose(" << Hangup on console >> \n");
+       ast_module_unref(ast_module_info->self);
        if (o->hookstate) {
                if (o->autoanswer || o->autohangup) {
                        /* Assume auto-hangup too */
@@ -1047,6 +1048,7 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o, char *ext, char *ctx,
                c->cid.cid_dnid = ast_strdup(ext);
 
        o->owner = c;
+       ast_module_ref(ast_module_info->self);
        ast_jb_configure(c, &global_jbconf);
        if (state != AST_STATE_DOWN) {
                if (ast_pbx_start(c)) {
index 26e6921..8312fab 100644 (file)
@@ -385,6 +385,7 @@ static int phone_hangup(struct ast_channel *ast)
        p->dialtone = 0;
        memset(p->ext, 0, sizeof(p->ext));
        ((struct phone_pvt *)(ast->tech_pvt))->owner = NULL;
+       ast_module_unref(ast_module_info->self);
        if (option_verbose > 2) 
                ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
        ast->tech_pvt = NULL;
@@ -907,6 +908,7 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
                tmp->cid.cid_name = ast_strdup(i->cid_name);
 
                i->owner = tmp;
+               ast_module_ref(ast_module_info->self);
                if (state != AST_STATE_DOWN) {
                        if (state == AST_STATE_RING) {
                                ioctl(tmp->fds[0], PHONE_RINGBACK);
@@ -987,6 +989,7 @@ static void phone_check_exception(struct phone_pvt *i)
                        if (i->mode == MODE_IMMEDIATE) {
                                phone_new(i, AST_STATE_RING, i->context);
                        } else if (i->mode == MODE_DIALTONE) {
+                               ast_module_ref(ast_module_info->self);
                                /* Reset the extension */
                                i->ext[0] = '\0';
                                /* Play the dialtone */
@@ -996,6 +999,7 @@ static void phone_check_exception(struct phone_pvt *i)
                                ioctl(i->fd, PHONE_PLAY_START);
                                i->lastformat = -1;
                        } else if (i->mode == MODE_SIGMA) {
+                               ast_module_ref(ast_module_info->self);
                                /* Reset the extension */
                                i->ext[0] = '\0';
                                /* Play the dialtone */
@@ -1003,6 +1007,8 @@ static void phone_check_exception(struct phone_pvt *i)
                                ioctl(i->fd, PHONE_DIALTONE);
                        }
                } else {
+                       if (i->dialtone)
+                               ast_module_unref(ast_module_info->self);
                        memset(i->ext, 0, sizeof(i->ext));
                        if (i->cpt)
                        {
index 6d43d36..abd473b 100644 (file)
@@ -3455,6 +3455,7 @@ static int sip_hangup(struct ast_channel *ast)
        p->owner = NULL;
        ast->tech_pvt = NULL;
 
+       ast_module_unref(ast_module_info->self);
        /* Do not destroy this pvt until we have timeout or
           get an answer to the BYE or INVITE/CANCEL 
           If we get no answer during retransmit period, drop the call anyway.
@@ -3976,6 +3977,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
        if (!ast_strlen_zero(i->language))
                ast_string_field_set(tmp, language, i->language);
        i->owner = tmp;
+       ast_module_ref(ast_module_info->self);
        ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
        ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
 
index 350db45..c07d361 100644 (file)
@@ -2753,6 +2753,7 @@ static struct ast_channel *skinny_new(struct skinny_line *l, int state)
                if (l->amaflags)
                        tmp->amaflags = l->amaflags;
 
+               ast_module_ref(ast_module_info->self);
                tmp->callgroup = l->callgroup;
                tmp->pickupgroup = l->pickupgroup;
                ast_string_field_set(tmp, call_forward, l->call_forward);
index 57d5d2c..8c56208 100644 (file)
@@ -2906,6 +2906,7 @@ static int zt_hangup(struct ast_channel *ast)
        p->oprmode = 0;
        ast->tech_pvt = NULL;
        ast_mutex_unlock(&p->lock);
+       ast_module_unref(ast_module_info->self);
        if (option_verbose > 2) 
                ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
 
@@ -5652,6 +5653,7 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
                }
        }
 
+       ast_module_ref(ast_module_info->self);
        return tmp;
 }