keep new conference locked the whole time during transfer

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12988 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-04-10 21:29:09 +00:00
parent 73fe7bfdcc
commit e4a513f073

View File

@ -3635,6 +3635,8 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
char *conf_name = NULL, *profile_name;
switch_event_t *params = NULL;
conference_obj_t *new_conference = NULL;
switch_assert(conference != NULL);
switch_assert(stream != NULL);
@ -3652,7 +3654,6 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc
for (x = 3; x < argc; x++) {
conference_member_t *member = NULL;
uint32_t id = atoi(argv[x]);
conference_obj_t *new_conference = NULL;
switch_channel_t *channel;
switch_event_t *event;
switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
@ -3664,8 +3665,9 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc
channel = switch_core_session_get_channel(member->session);
/* build a new conference if it doesn't exist */
if (!new_conference) {
if (!(new_conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
/* build a new conference if it doesn't exist */
switch_memory_pool_t *pool = NULL;
conf_xml_cfg_t xml_cfg = { 0 };
@ -3730,6 +3732,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc
} else {
switch_mutex_lock(new_conference->mutex);
}
}
/* move the member from the old conference to the new one */
switch_mutex_lock(member->control_mutex);
@ -3745,10 +3748,8 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc
}
}
switch_mutex_unlock(new_conference->mutex);
switch_mutex_unlock(member->control_mutex);
stream->write_function(stream, "OK Member '%d' sent to conference %s.\n", member->id, argv[2]);
/* tell them what happened */
@ -3761,6 +3762,11 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc
switch_event_fire(&event);
}
}
if (new_conference) {
switch_mutex_unlock(new_conference->mutex);
}
} else {
ret_status = SWITCH_STATUS_GENERR;
}