From 0062fe9588f94dbd6b5e11e84f4bb2f171738829 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Fri, 4 Jun 2004 18:30:35 +0000 Subject: IAX2 fixup, fix res_monitor sillyseg git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3144 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_iax2.c | 11 ++++++----- res/res_monitor.c | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index fa8e3df4c..a2257fe38 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -6421,7 +6421,7 @@ int reload(void) return reload_config(); } -static int cache_get_callno(char *data) +static int cache_get_callno_locked(char *data) { struct sockaddr_in sin; int x; @@ -6437,7 +6437,6 @@ static int cache_get_callno(char *data) look up entries for a single context */ if (!ast_mutex_trylock(&iaxsl[x])) { if (iaxs[x] && !strcasecmp(data, iaxs[x]->dproot)) { - ast_mutex_unlock(&iaxsl[x]); return x; } ast_mutex_unlock(&iaxsl[x]); @@ -6501,7 +6500,6 @@ static int cache_get_callno(char *data) #endif /* Start the call going */ send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_NEW, 0, ied.buf, ied.pos, -1); - ast_mutex_unlock(&iaxsl[callno]); return callno; } @@ -6548,14 +6546,16 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, char *data, cha if (!dp) { /* No matching entry. Create a new one. */ /* First, can we make a callno? */ - callno = cache_get_callno(data); + callno = cache_get_callno_locked(data); if (callno < 0) { ast_log(LOG_WARNING, "Unable to generate call for '%s'\n", data); return NULL; } dp = malloc(sizeof(struct iax2_dpcache)); - if (!dp) + if (!dp) { + ast_mutex_unlock(&iaxsl[callno]); return NULL; + } memset(dp, 0, sizeof(struct iax2_dpcache)); strncpy(dp->peercontext, data, sizeof(dp->peercontext)-1); strncpy(dp->exten, exten, sizeof(dp->exten)-1); @@ -6573,6 +6573,7 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, char *data, cha /* Send the request if we're already up */ if (iaxs[callno]->state & IAX_STATE_STARTED) iax2_dprequest(dp, callno); + ast_mutex_unlock(&iaxsl[callno]); } /* By here we must have a dp */ if (dp->flags & CACHE_FLAG_PENDING) { diff --git a/res/res_monitor.c b/res/res_monitor.c index 56eaaf956..3f85b1f1e 100755 --- a/res/res_monitor.c +++ b/res/res_monitor.c @@ -172,7 +172,7 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec, /* Stop monitoring a channel */ int ast_monitor_stop( struct ast_channel *chan, int need_lock ) { - char *execute=NULL; + char *execute; int soxmix =0; if(need_lock) { if(ast_mutex_lock(&chan->lock)) { @@ -219,7 +219,7 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock ) } } - if (chan->monitor->joinfiles && !ast_strlen_zero(execute) && strlen(chan->monitor->filename_base)) { + if (chan->monitor->joinfiles && strlen(chan->monitor->filename_base)) { char tmp[1024]; char tmp2[1024]; char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : chan->monitor->format; -- cgit v1.2.3