refactor to avoid some potential issues with channels that are hungup instantly after being answered

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4926 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2007-04-13 22:15:58 +00:00
1 parent ff44ce11cc
commit eb2124ae32
16 files changed
+1524 -1606

No files matched your search

@@ -39,7 +39,7 @@ static const char modname[] = "mod_bridgecall";
static void audio_bridge_function(switch_core_session_t *session, char *data)
{
switch_channel_t *caller_channel;
switch_core_session_t *peer_session;
switch_core_session_t *peer_session = NULL;
unsigned int timelimit = 60;
char *var;
uint8_t no_media_bridge = 0;
@@ -98,7 +98,7 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
if (bad) {
switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return;
goto end;
}
}
@@ -113,6 +113,10 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
}
}
end:
if (peer_session) {
switch_core_session_rwunlock(peer_session);
}
}
}
@@ -590,7 +590,7 @@ static switch_status_t pause_function(char *cmd, switch_core_session_t *isession
static switch_status_t originate_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{
switch_channel_t *caller_channel;
switch_core_session_t *caller_session;
switch_core_session_t *caller_session = NULL;
char *argv[7] = { 0 };
int i = 0, x, argc = 0;
char *aleg, *exten, *dp, *context, *cid_name, *cid_num;
@@ -684,6 +684,10 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
stream->write_function(stream, "Created Session: %s\n", switch_core_session_get_uuid(caller_session));
}
if (caller_session) {
switch_core_session_rwunlock(caller_session);
}
return SWITCH_STATUS_SUCCESS;;
}
@@ -3476,12 +3476,12 @@ static switch_status_t conference_outcall(conference_obj_t * conference,
switch_core_session_t *session,
char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause)
{
switch_core_session_t *peer_session;
switch_core_session_t *peer_session = NULL;
switch_channel_t *peer_channel;
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_channel_t *caller_channel = NULL;
char appdata[512];
int rdlock = 0;
*cause = SWITCH_CAUSE_NORMAL_CLEARING;
@@ -3498,7 +3498,7 @@ static switch_status_t conference_outcall(conference_obj_t * conference,
peer_channel = switch_core_session_get_channel(peer_session);
assert(peer_channel != NULL);
rdlock = 1;
goto callup;
}
@@ -3534,7 +3534,7 @@ static switch_status_t conference_outcall(conference_obj_t * conference,
goto done;
}
rdlock = 1;
peer_channel = switch_core_session_get_channel(peer_session);
assert(peer_channel != NULL);
@@ -3585,6 +3585,10 @@ static switch_status_t conference_outcall(conference_obj_t * conference,
if (conference) {
switch_thread_rwlock_unlock(conference->rwlock);
}
if (rdlock && peer_session) {
switch_core_session_rwunlock(peer_session);
}
return status;
}