FS-4453 --resolve this will now cause up to a 20 second timeout waiting for the response and the call will be blocking

This commit is contained in:
Anthony Minessale
2012-07-24 13:45:05 -05:00
parent 7f525d5ca9
commit d832b5dfef
6 changed files with 60 additions and 12 deletions
@@ -7764,7 +7764,7 @@ static switch_status_t chat_send(switch_event_t *message_event)
}
if (!(conference = conference_find(name, NULL))) {
switch_core_chat_send_args(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL, NULL);
switch_core_chat_send_args(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL, NULL, SWITCH_FALSE);
return SWITCH_STATUS_FALSE;
}
@@ -7782,7 +7782,7 @@ static switch_status_t chat_send(switch_event_t *message_event)
switch_safe_free(lbuf);
switch_core_chat_send_args(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", stream.data, NULL, NULL);
switch_core_chat_send_args(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", stream.data, NULL, NULL, SWITCH_FALSE);
switch_safe_free(stream.data);
switch_thread_rwlock_unlock(conference->rwlock);
@@ -1720,7 +1720,7 @@ SWITCH_STANDARD_API(chat_api_function)
if (!zstr(cmd) && (lbuf = strdup(cmd))
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) >= 4) {
if (switch_core_chat_send_args(argv[0], "global", argv[1], argv[2], "", argv[3], !zstr(argv[4]) ? argv[4] : NULL, "") == SWITCH_STATUS_SUCCESS) {
if (switch_core_chat_send_args(argv[0], "global", argv[1], argv[2], "", argv[3], !zstr(argv[4]) ? argv[4] : NULL, "", SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "Sent");
} else {
stream->write_function(stream, "Error! Message Not Sent");
@@ -4105,7 +4105,7 @@ static switch_status_t api_chat_send(switch_event_t *message_event)
switch_api_execute(cmd, arg, NULL, &stream);
if (proto) {
switch_core_chat_send_args(proto, "api", to, hint && strchr(hint, '/') ? hint : from, !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL);
switch_core_chat_send_args(proto, "api", to, hint && strchr(hint, '/') ? hint : from, !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL, SWITCH_TRUE);
}
switch_safe_free(stream.data);
+18
View File
@@ -745,6 +745,24 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
void sofia_handle_sip_r_message(int status, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip)
{
const char *call_id;
int *mstatus;
if (!sip && sip->sip_call_id) {
return;
}
call_id = sip->sip_call_id->i_id;
switch_mutex_lock(profile->flag_mutex);
mstatus = switch_core_hash_find(profile->chat_hash, call_id);
switch_mutex_unlock(profile->flag_mutex);
if (mstatus) {
*mstatus = status;
}
}
void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout)
+24 -1
View File
@@ -128,6 +128,9 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
char *route_uri = NULL;
const char *network_ip = NULL, *network_port = NULL, *from_proto;
char *extra_headers = NULL;
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
int mstatus = 0, sanity = 0;
proto = switch_event_get_header(message_event, "proto");
from_proto = switch_event_get_header(message_event, "from_proto");
@@ -324,6 +327,12 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
switch_snprintf(header, sizeof(header), "X-FS-Sending-Message: %s", switch_core_get_uuid());
switch_uuid_str(uuid_str, sizeof(uuid_str));
switch_mutex_lock(profile->flag_mutex);
switch_core_hash_insert(profile->chat_hash, uuid_str, &mstatus);
switch_mutex_unlock(profile->flag_mutex);
nua_message(msg_nh,
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)),
TAG_IF(route_uri, NUTAG_PROXY(route_uri)),
@@ -331,7 +340,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
SIPTAG_FROM_STR(from),
TAG_IF(contact, NUTAG_URL(contact)),
SIPTAG_TO_STR(dup_dest),
SIPTAG_CALL_ID_STR(uuid_str),
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
SIPTAG_CONTENT_TYPE_STR(ct),
SIPTAG_PAYLOAD_STR(body),
@@ -339,6 +348,20 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
TAG_END());
sanity = 200;
while(!mstatus && --sanity) {
switch_yield(100000);
}
if (!(mstatus > 199 && mstatus < 300)) {
status = SWITCH_STATUS_FALSE;
}
switch_mutex_lock(profile->flag_mutex);
switch_core_hash_delete(profile->chat_hash, uuid_str);
switch_mutex_unlock(profile->flag_mutex);
sofia_glue_free_destination(dst);
switch_safe_free(dup_dest);
switch_safe_free(remote_host);