Properly fix double locking issue, fix wav49 issue
authorMark Spencer <markster@digium.com>
Thu, 11 Dec 2003 20:55:26 +0000 (20:55 +0000)
committerMark Spencer <markster@digium.com>
Thu, 11 Dec 2003 20:55:26 +0000 (20:55 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1855 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c
channels/chan_zap.c

index a0bea84..a7b43a8 100755 (executable)
@@ -1928,6 +1928,9 @@ forward_message(struct ast_channel *chan, char *context, char *dir, int curmsg,
                        strncpy(tmp, fmt, sizeof(tmp));
                        stringp = tmp;
                        while((s = strsep(&stringp, "|"))) {
+                               /* XXX This is a hack -- we should use build_filename or similar XXX */
+                               if (!strcasecmp(s, "wav49"))
+                                       s = "WAV";
                                snprintf(sys, sizeof(sys), "cp %s/msg%04d.%s %s/msg%04d.%s\n", dir, curmsg, s, todir, todircount, s);
                                ast_log(LOG_DEBUG, sys);
                                system(sys);
index 5f70250..ff9a48e 100755 (executable)
@@ -3182,7 +3182,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
 
 
 
-static struct ast_frame *zt_exception(struct ast_channel *ast)
+static struct ast_frame *__zt_exception(struct ast_channel *ast)
 {
        struct zt_pvt *p = ast->pvt->pvt;
        int res;
@@ -3190,7 +3190,6 @@ static struct ast_frame *zt_exception(struct ast_channel *ast)
        int index;
        struct ast_frame *f;
 
-       ast_mutex_lock(&p->lock);
 
        index = zt_get_index(ast, p, 1);
        
@@ -3272,7 +3271,6 @@ static struct ast_frame *zt_exception(struct ast_channel *ast)
                        ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", event2str(res));
                }
                f = &p->subs[index].f;
-               ast_mutex_unlock(&p->lock);
                return f;
        }
        if (!p->radio) ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
@@ -3280,10 +3278,18 @@ static struct ast_frame *zt_exception(struct ast_channel *ast)
        if (ast != p->owner) {
                ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
                f = &p->subs[index].f;
-               ast_mutex_unlock(&p->lock);
                return f;
        }
        f = zt_handle_event(ast);
+       return f;
+}
+
+struct ast_frame *zt_exception(struct ast_channel *ast)
+{
+       struct zt_pvt *p = ast->pvt->pvt;
+       struct ast_frame *f;
+       ast_mutex_lock(&p->lock);
+       f = __zt_exception(ast);
        ast_mutex_unlock(&p->lock);
        return f;
 }
@@ -3403,7 +3409,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
                                ast_mutex_unlock(&p->lock);
                                return &p->subs[index].f;
                        } else if (errno == ELAST) {
-                               f = zt_exception(ast);
+                               f = __zt_exception(ast);
                        } else
                                ast_log(LOG_WARNING, "zt_rec: %s\n", strerror(errno));
                }
@@ -3412,7 +3418,7 @@ struct ast_frame  *zt_read(struct ast_channel *ast)
        }
        if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
                ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
-               f = zt_exception(ast);
+               f = __zt_exception(ast);
                ast_mutex_unlock(&p->lock);
                return f;
        }