Merge branch 'master' of ssh://git.freeswitch.org:222/freeswitch

This commit is contained in:
David Yat Sin 2011-07-14 18:30:16 -04:00
commit 3d028378c5
19 changed files with 251 additions and 182 deletions

View File

@ -584,10 +584,12 @@ uint32_t sngisdn_decode_ie(char *str, uint32_t *str_len, uint8_t current_codeset
break;
case PROT_Q931_IE_DISPLAY:
{
uint8_t j, displayType, assocInfo;
uint8_t j;
char displayStr[82];
uint8_t displayNtEnabled = 0;
uint8_t displayStrOct = 2;
uint8_t displayType = 0;
uint8_t assocInfo = 0;
memset(displayStr, 0, sizeof(displayStr));

View File

@ -1 +1 @@
Mon Jul 11 17:37:21 CDT 2011
Wed Jul 6 15:11:41 CDT 2011

View File

@ -109,8 +109,8 @@ nua_handle_t *nh_create_handle(nua_t *nua,
assert(nua->nua_home);
//if ((nh = su_home_clone(nua->nua_home, sizeof(*nh)))) {
if ((nh = su_home_clone(NULL, sizeof(*nh)))) {
if ((nh = su_home_clone(nua->nua_home, sizeof(*nh)))) {
//if ((nh = su_home_new(sizeof(*nh)))) {
nh->nh_valid = nua_valid_handle_cookie;
nh->nh_nua = nua;
nh->nh_magic = hmagic;
@ -174,7 +174,7 @@ _nua_handle_ref_by(nua_handle_t *nh,
{
if (nh)
SU_DEBUG_0(("%p - nua_handle_ref() => "MOD_ZU" by %s:%u: %s()\n",
nh, su_home_refcount((su_home_t *)nh) + 1, file, line, by));
nh, su_home_refcount((su_home_t *)nh) + 1, file, line, function));
return (nua_handle_t *)su_home_ref((su_home_t *)nh);
}
@ -186,15 +186,17 @@ _nua_handle_unref_by(nua_handle_t *nh,
if (nh) {
size_t refcount = su_home_refcount((su_home_t *)nh) - 1;
int freed = su_home_unref((su_home_t *)nh);
if (freed) refcount = 0;
SU_DEBUG_0(("%p - nua_handle_unref() => "MOD_ZU" by %s:%u: %s()\n",
nh, refcount, file, line, by));
nh, refcount, file, line, function));
return freed;
}
return 0;
}
#if 0
nua_handle_t *nua_handle_ref(nua_handle_t *nh)
{
return _nua_handle_ref_by(nh, "<app>", 0, "<app>")
@ -204,6 +206,7 @@ int nua_handle_unref(nua_handle_t *nh)
{
return _nua_handle_unref_by(nh, "<app>", 0, "<app>")
}
#endif
#else

View File

@ -84,7 +84,6 @@
#define SWITCH_EVENT_QUEUE_LEN 256
#define SWITCH_MESSAGE_QUEUE_LEN 256
#define SWITCH_SQL_QUEUE_LEN 100000
#define SWITCH_BUFFER_BLOCK_FRAMES 25
#define SWITCH_BUFFER_START_FRAMES 50
@ -221,7 +220,7 @@ struct switch_runtime {
switch_mutex_t *throttle_mutex;
switch_mutex_t *session_hash_mutex;
switch_mutex_t *global_mutex;
switch_mutex_t *global_var_mutex;
switch_thread_rwlock_t *global_var_rwlock;
uint32_t sps_total;
int32_t sps;
int32_t sps_last;

View File

@ -438,7 +438,11 @@ static inline void switch_core_codec_add_implementation(switch_memory_pool_t *po
/*! deinitalize a codec handle using this implementation */
switch_core_codec_destroy_func_t destroy)
{
if (codec_type == SWITCH_CODEC_TYPE_VIDEO || switch_check_interval(actual_samples_per_second, microseconds_per_packet / 1000)) {
if (decoded_bytes_per_packet > SWITCH_RECOMMENDED_BUFFER_SIZE) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Rejected codec name: %s rate: %u ptime: %u not enough buffer space %d > %d\n",
iananame, actual_samples_per_second, microseconds_per_packet / 1000, decoded_bytes_per_packet, SWITCH_RECOMMENDED_BUFFER_SIZE);
} else if (codec_type == SWITCH_CODEC_TYPE_VIDEO || switch_check_interval(actual_samples_per_second, microseconds_per_packet / 1000)) {
switch_codec_implementation_t *impl = (switch_codec_implementation_t *) switch_core_alloc(pool, sizeof(*impl));
impl->codec_type = codec_type;
impl->ianacode = ianacode;

View File

@ -1352,27 +1352,28 @@ SWITCH_STANDARD_API(strftime_api_function)
switch_time_exp_t tm;
char date[80] = "";
switch_time_t thetime;
char *p;
char *p, *q = NULL;
char *mycmd = NULL;
if (!zstr(cmd)) {
mycmd = strdup(cmd);
q = mycmd;
}
if (!zstr(mycmd) && (p = strchr(mycmd, '|'))) {
if (!zstr(q) && (p = strchr(q, '|'))) {
*p++ = '\0';
thetime = switch_time_make(atol(mycmd), 0);
mycmd = p + 1;
thetime = switch_time_make(atol(q), 0);
q = p + 1;
} else {
thetime = switch_micro_time_now();
}
switch_time_exp_lt(&tm, thetime);
if (zstr(mycmd)) {
if (zstr(q)) {
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
} else {
switch_strftime(date, &retsize, sizeof(date), mycmd, &tm);
switch_strftime(date, &retsize, sizeof(date), q, &tm);
}
stream->write_function(stream, "%s", date);
switch_safe_free(mycmd);

View File

@ -34,6 +34,7 @@
#include "mod_spandsp.h"
#if SWITCH_MAX_INTERVAL >= 90
/* LPC10 - START */
struct lpc10_context {
@ -123,7 +124,7 @@ static switch_status_t switch_lpc10_decode(switch_codec_t *codec,
}
/* LPC10 - END */
#endif
/* GSM - START */
struct gsm_context {

View File

@ -364,7 +364,7 @@ static switch_status_t interface_exists(char *the_interface)
if (globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread) {
#ifdef WIN32
skypopen_signaling_write(tech_pvt, "DIE");
switch_sleep(10000);
switch_sleep(20000);
switch_file_write(tech_pvt->SkypopenHandles.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die
#else /* WIN32 */
howmany = write(tech_pvt->SkypopenHandles.fdesc[1], "sciutati", howmany);
@ -381,7 +381,7 @@ static switch_status_t interface_exists(char *the_interface)
if (tech_pvt->running && tech_pvt->SkypopenHandles.disp) {
XEvent e;
Atom atom1 = XInternAtom(tech_pvt->SkypopenHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
switch_sleep(1000);
switch_sleep(20000);
XFlush(tech_pvt->SkypopenHandles.disp);
memset(&e, 0, sizeof(e));
e.xclient.type = ClientMessage;
@ -494,9 +494,9 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
DEBUGA_SKYPE("audio tcp threads to DIE\n", SKYPOPEN_P_LOG);
conta = 0;
while (tech_pvt->tcp_srv_thread) {
switch_sleep(5000);
switch_sleep(50000);
conta++;
if (conta == 200) {
if (conta == 20) {
ERRORA("tcp_srv_thread is NOT dead, this can LEAK MEMORY\n", SKYPOPEN_P_LOG);
break;
}
@ -504,9 +504,9 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
DEBUGA_SKYPE("audio tcp srv thread DEAD %d\n", SKYPOPEN_P_LOG, conta);
conta = 0;
while (tech_pvt->tcp_cli_thread) {
switch_sleep(5000);
switch_sleep(50000);
conta++;
if (conta == 200) {
if (conta == 20) {
ERRORA("tcp_cli_thread is NOT dead, this can LEAK MEMORY\n", SKYPOPEN_P_LOG);
break;
}
@ -857,6 +857,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
switch_core_timer_next(&tech_pvt->timer_read);
}
try = 0;
read:
@ -871,12 +872,13 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
try = 0;
if (!bytes_read) {
switch_sleep(1000);
switch_sleep(1000); //XXX don't like this
try++;
if (try < 5)
if (try < 5){
DEBUGA_SKYPE("skypopen_audio_read going back to read\n", SKYPOPEN_P_LOG);
goto read;
}
DEBUGA_SKYPE("skypopen_audio_read Silence\n", SKYPOPEN_P_LOG);
memset(tech_pvt->read_frame.data, 255, BYTES_PER_FRAME);
tech_pvt->read_frame.datalen = BYTES_PER_FRAME;
@ -1056,9 +1058,9 @@ static switch_status_t channel_answer_channel(switch_core_session_t *session)
if (switch_channel_get_state(channel) == CS_RESET) {
return SWITCH_STATUS_FALSE;
}
switch_sleep(5000);
switch_sleep(50000);
conta++;
if (conta == 100) { //0.5 seconds
if (conta == 10) { //0.5 seconds
return SWITCH_STATUS_FALSE;
}
}
@ -1361,7 +1363,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
tech_pvt->ob_calls++;
rdest = strchr(caller_profile->destination_number, '/');
*rdest++ = '\0';
@ -1371,6 +1372,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
caller_profile->destination_number = rdest;
switch_mutex_lock(tech_pvt->flag_mutex);
tech_pvt->ob_calls++;
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
switch_mutex_unlock(tech_pvt->flag_mutex);
switch_channel_set_state(channel, CS_INIT);
@ -1428,7 +1430,7 @@ static void *SWITCH_THREAD_FUNC skypopen_signaling_thread_func(switch_thread_t *
if (channel) {
switch_channel_state_t state = switch_channel_get_state(channel);
if (state < CS_EXECUTE) {
switch_sleep(10000); //10 msec, let the state evolve from CS_NEW
switch_sleep(20000); //20 msec, let the state evolve from CS_NEW
}
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
} else {
@ -1442,9 +1444,9 @@ static void *SWITCH_THREAD_FUNC skypopen_signaling_thread_func(switch_thread_t *
DEBUGA_SKYPE("audio tcp threads to DIE\n", SKYPOPEN_P_LOG);
conta = 0;
while (tech_pvt->tcp_srv_thread) {
switch_sleep(5000);
switch_sleep(50000);
conta++;
if (conta == 200) {
if (conta == 20) {
ERRORA("tcp_srv_thread is NOT dead, this can LEAK MEMORY\n", SKYPOPEN_P_LOG);
break;
}
@ -1452,9 +1454,9 @@ static void *SWITCH_THREAD_FUNC skypopen_signaling_thread_func(switch_thread_t *
DEBUGA_SKYPE("audio tcp srv thread DEAD %d\n", SKYPOPEN_P_LOG, conta);
conta = 0;
while (tech_pvt->tcp_cli_thread) {
switch_sleep(5000);
switch_sleep(50000);
conta++;
if (conta == 200) {
if (conta == 20) {
ERRORA("tcp_cli_thread is NOT dead, this can LEAK MEMORY\n", SKYPOPEN_P_LOG);
break;
}
@ -1647,7 +1649,7 @@ static switch_status_t load_config(int reload_type)
} else {
DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPOPEN_P_LOG);
}
switch_sleep(1000);
switch_sleep(20000);
#endif /* WIN32 */
if (interface_id && interface_id < SKYPOPEN_MAX_INTERFACES) {
@ -1795,20 +1797,20 @@ static switch_status_t load_config(int reload_type)
SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].skype_user);
skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "PROTOCOL 7");
switch_sleep(10000);
switch_sleep(20000);
skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET AUTOAWAY OFF");
switch_sleep(10000);
switch_sleep(20000);
skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET WINDOWSTATE HIDDEN");
switch_sleep(10000);
switch_sleep(20000);
skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET USERSTATUS ONLINE");
switch_sleep(10000);
switch_sleep(20000);
if (globals.SKYPOPEN_INTERFACES[interface_id].silent_mode) {
skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET SILENT_MODE ON");
switch_sleep(10000);
switch_sleep(20000);
skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET SILENT_MODE OFF");
switch_sleep(10000);
switch_sleep(20000);
skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET SILENT_MODE ON");
switch_sleep(10000);
switch_sleep(20000);
}
} else {
ERRORA
@ -1929,7 +1931,7 @@ static switch_status_t chat_send(const char *proto, const char *from, const char
snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", to);
skypopen_signaling_write(tech_pvt, skype_msg);
switch_sleep(1000);
switch_sleep(20000);
}
found = 0;
@ -1946,11 +1948,12 @@ static switch_status_t chat_send(const char *proto, const char *from, const char
if (found) {
break;
}
if (tried > 1000) {
tried++;
if (tried > 20) {
ERRORA("No chat with dialog_partner='%s' was found\n", SKYPOPEN_P_LOG, to);
break;
}
switch_sleep(1000);
switch_sleep(50000);
}
}
@ -2032,12 +2035,12 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypopen_shutdown)
if (globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread) {
#ifdef WIN32
skypopen_signaling_write(tech_pvt, "DIE");
switch_sleep(10000);
switch_sleep(20000);
switch_file_write(tech_pvt->SkypopenHandles.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die
#else /* WIN32 */
skypopen_signaling_write(tech_pvt, "DIE");
switch_sleep(10000);
switch_sleep(20000);
howmany = write(tech_pvt->SkypopenHandles.fdesc[1], "sciutati", howmany);
#endif /* WIN32 */
}
@ -2053,7 +2056,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypopen_shutdown)
XEvent e;
Atom atom1 = XInternAtom(tech_pvt->SkypopenHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN",
False);
switch_sleep(1000);
switch_sleep(20000);
XFlush(tech_pvt->SkypopenHandles.disp);
memset(&e, 0, sizeof(e));
e.xclient.type = ClientMessage;
@ -2456,12 +2459,12 @@ SWITCH_STANDARD_API(sk_function)
for (tmp_i = 0; tmp_i < SKYPOPEN_MAX_INTERFACES; tmp_i++) {
if (strlen(globals.SKYPOPEN_INTERFACES[tmp_i].name)) {
skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE");
switch_sleep(10000);
switch_sleep(20000);
strncpy(tmp_message, globals.SKYPOPEN_INTERFACES[tmp_i].message, sizeof(globals.SKYPOPEN_INTERFACES[tmp_i].message));
skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE_CURRENCY");
switch_sleep(10000);
switch_sleep(20000);
if(strlen(tmp_message)>21 && strlen(globals.SKYPOPEN_INTERFACES[tmp_i].message) > 30)
stream->write_function(stream, " %s \t%s\t%s\n", globals.SKYPOPEN_INTERFACES[tmp_i].name, tmp_message+21, globals.SKYPOPEN_INTERFACES[tmp_i].message+30);
}
@ -2470,23 +2473,23 @@ SWITCH_STANDARD_API(sk_function)
if (!strcasecmp(argv[0], "list")) {
int i;
int ib = 0;
int ib_failed = 0;
int ob = 0;
int ob_failed = 0;
unsigned int ib = 0;
unsigned int ib_failed = 0;
unsigned int ob = 0;
unsigned int ob_failed = 0;
char next_flag_char = ' ';
stream->write_function(stream, "F ID\t Name \tIB (F/T) OB (F/T)\tState\tCallFlw\t\tUUID\n");
stream->write_function(stream, "= ====\t ======== \t======= =======\t======\t============\t======\n");
for (i = 0; i < SKYPOPEN_MAX_INTERFACES; i++) {
if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) {
next_flag_char = i == globals.next_interface ? '*' : ' ';
ib += globals.SKYPOPEN_INTERFACES[i].ib_calls;
ib_failed += globals.SKYPOPEN_INTERFACES[i].ib_failed_calls;
ob += globals.SKYPOPEN_INTERFACES[i].ob_calls;
ob_failed += globals.SKYPOPEN_INTERFACES[i].ob_failed_calls;
if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) {
stream->write_function(stream,
"%c %d\t[%s]\t%3u/%u\t%6u/%u\t%s\t%s\t%s\n",
next_flag_char,
@ -2498,11 +2501,11 @@ SWITCH_STANDARD_API(sk_function)
interface_status[globals.SKYPOPEN_INTERFACES[i].interface_state],
skype_callflow[globals.SKYPOPEN_INTERFACES[i].skype_callflow], globals.SKYPOPEN_INTERFACES[i].session_uuid_str);
} else if (argc > 1 && !strcasecmp(argv[1], "full")) {
stream->write_function(stream, "%c\t%d\n", next_flag_char, i);
stream->write_function(stream, "%c %d\n", next_flag_char, i);
}
}
stream->write_function(stream, "\nTotal Interfaces: %d IB Calls(Failed/Total): %ld/%ld OB Calls(Failed/Total): %ld/%ld\n",
stream->write_function(stream, "\nTotal Interfaces: %d IB Calls(Failed/Total): %u/%u OB Calls(Failed/Total): %u/%u\n",
globals.real_interfaces > 0 ? globals.real_interfaces - 1 : 0, ib_failed, ib, ob_failed, ob);
} else if (!strcasecmp(argv[0], "console")) {
@ -2915,7 +2918,7 @@ int skypopen_transfer(private_t *tech_pvt)
sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id);
skypopen_signaling_write(tech_pvt, msg_to_skype);
}
switch_sleep(10000);
switch_sleep(20000);
DEBUGA_SKYPE
("We have NOT answered a Skype RING from skype_call %s, because we are already in a skypopen call (%s)\n",
SKYPOPEN_P_LOG, id, tech_pvt->skype_call_id);

View File

@ -186,7 +186,7 @@ int skypopen_signaling_read(private_t *tech_pvt)
SKYPOPEN_P_LOG);
skypopen_sleep(1000000);
skypopen_signaling_write(tech_pvt, "PROTOCOL 7");
skypopen_sleep(10000);
skypopen_sleep(20000);
return 0;
}
if (!strncasecmp(message, "ERROR 92 CALL", 12)) {
@ -898,6 +898,9 @@ void *skypopen_do_tcp_srv_thread_func(void *obj)
if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) {
switch_core_timer_next(&tech_pvt->timer_read_srv);
} else {
skypopen_sleep(20000);
}
//rt = select(fdselect + 1, &fs, NULL, NULL, &to);
if (rt > 0) {
@ -905,12 +908,12 @@ void *skypopen_do_tcp_srv_thread_func(void *obj)
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
len = recv(fd, (char *) srv_in, BYTES_PER_FRAME * 2, 0);
} else {
skypopen_sleep(10000);
//skypopen_sleep(10000);
continue;
}
if (tech_pvt->begin_to_read == 0) {
DEBUGA_SKYPE("len=%d\n", SKYPOPEN_P_LOG, len);
skypopen_sleep(10000);
//skypopen_sleep(10000);
continue;
}
@ -1054,6 +1057,8 @@ void *skypopen_do_tcp_cli_thread_func(void *obj)
if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next
&& tech_pvt->interface_state != SKYPOPEN_STATE_HANGUP_REQUESTED) {
switch_core_timer_next(&tech_pvt->timer_write);
} else {
skypopen_sleep(20000);
}
if (tech_pvt->begin_to_write == 0) {
@ -1064,7 +1069,7 @@ void *skypopen_do_tcp_cli_thread_func(void *obj)
DEBUGA_SKYPE("len=%d, error: %s\n", SKYPOPEN_P_LOG, len, strerror(errno));
break;
}
skypopen_sleep(10000);
//skypopen_sleep(10000);
continue;
} else {
@ -1367,7 +1372,7 @@ LRESULT APIENTRY skypopen_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
}
break;
case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
skypopen_sleep(5000);
skypopen_sleep(20000);
break;
case SKYPECONTROLAPI_ATTACH_REFUSED:
ERRORA("Skype client refused to be connected by Skypopen!\n", SKYPOPEN_P_LOG);
@ -1377,7 +1382,7 @@ LRESULT APIENTRY skypopen_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
break;
case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
DEBUGA_SKYPE("Skype API available\n", SKYPOPEN_P_LOG);
skypopen_sleep(5000);
skypopen_sleep(20000);
break;
default:
WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPOPEN_P_LOG);
@ -1681,7 +1686,7 @@ void skypopen_clean_disp(void *data)
DEBUGA_SKYPE("NOT destroyed disp\n", SKYPOPEN_P_LOG);
}
DEBUGA_SKYPE("OUT destroyed disp\n", SKYPOPEN_P_LOG);
skypopen_sleep(1000);
skypopen_sleep(20000);
}
void *skypopen_do_skypeapi_thread_func(void *obj)
@ -1927,13 +1932,14 @@ void *skypopen_do_skypeapi_thread_func(void *obj)
SKYPOPEN_P_LOG, buf);
skypopen_sleep(1000000); //1 sec
}
skypopen_sleep(1000); //0.1 msec
skypopen_sleep(20000); //20 msec
break;
}
}
if (continue_is_broken) {
XFlush(disp);
skypopen_sleep(1000); //0.1 msec
skypopen_sleep(20000); //20 msec
WARNINGA("continue_is_broken\n", SKYPOPEN_P_LOG);
continue;
}
strcat(buffer, buf);

View File

@ -553,9 +553,8 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
*tech_pvt->sofia_private->uuid = '\0';
}
sofia_glue_set_rtp_stats(tech_pvt);
switch_mutex_unlock(tech_pvt->sofia_mutex);
return SWITCH_STATUS_SUCCESS;
@ -4358,7 +4357,10 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
if (tech_pvt->local_url) {
switch_channel_set_variable(nchannel, "sip_local_url", tech_pvt->local_url);
if (profile->pres_type) {
switch_channel_set_variable(nchannel, "presence_id", tech_pvt->local_url);
const char *presence_id = switch_channel_get_variable(nchannel, "presence_id");
if (zstr(presence_id)) {
switch_channel_set_variable(nchannel, "presence_id", tech_pvt->local_url);
}
}
}
switch_channel_set_variable(nchannel, "sip_destination_url", tech_pvt->dest);
@ -4960,7 +4962,7 @@ static void general_event_handler(switch_event_t *event)
}
}
switch_status_t list_profiles(const char *line, const char *cursor, switch_console_callback_match_t **matches)
switch_status_t list_profiles_full(const char *line, const char *cursor, switch_console_callback_match_t **matches, switch_bool_t show_aliases)
{
sofia_profile_t *profile = NULL;
switch_hash_index_t *hi;
@ -4972,7 +4974,12 @@ switch_status_t list_profiles(const char *line, const char *cursor, switch_conso
switch_mutex_lock(mod_sofia_globals.hash_mutex);
for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, &vvar, NULL, &val);
profile = (sofia_profile_t *) val;
if (!show_aliases && strcmp((char *)vvar, profile->name)) {
continue;
}
if (sofia_test_pflag(profile, PFLAG_RUNNING)) {
switch_console_push_match(&my_matches, (const char *) vvar);
}
@ -4988,6 +4995,11 @@ switch_status_t list_profiles(const char *line, const char *cursor, switch_conso
return status;
}
switch_status_t list_profiles(const char *line, const char *cursor, switch_console_callback_match_t **matches)
{
return list_profiles_full(line, cursor, matches, SWITCH_TRUE);
}
static switch_status_t list_gateways(const char *line, const char *cursor, switch_console_callback_match_t **matches)
{
sofia_profile_t *profile = NULL;

View File

@ -33,7 +33,7 @@
* mod_sofia.h -- SOFIA SIP Endpoint
*
*/
//#define HAVE_MEMLEAK_LOG 1
/*Defines etc..*/
/*************************************************************************************************************************************************************/
#define MANUAL_BYE 1
@ -151,10 +151,11 @@ struct sofia_private {
char gateway_name[256];
char auth_gateway_name[256];
int destroy_nh;
int destroy_me;
int is_call;
int got_bye;
int is_static;
sofia_dispatch_event_t *de;
nua_handle_t *nh;
};
#define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);}
@ -317,8 +318,8 @@ typedef enum {
TFLAG_MAX
} TFLAGS;
#define SOFIA_MAX_MSG_QUEUE 26
#define SOFIA_MSG_QUEUE_SIZE 20
#define SOFIA_MAX_MSG_QUEUE 51
#define SOFIA_MSG_QUEUE_SIZE 200
struct mod_sofia_globals {
switch_memory_pool_t *pool;
@ -1080,8 +1081,10 @@ switch_status_t sofia_set_loglevel(const char *name, int level);
* \note Valid components are "default" (sofia's default logger), "tport", "iptsec", "nea", "nta", "nth_client", "nth_server", "nua", "soa", "sresolv", "stun"
* \return the component's loglevel, or -1 if the component isn't valid
*/
switch_status_t list_profiles(const char *line, const char *cursor, switch_console_callback_match_t **matches);
int sofia_get_loglevel(const char *name);
switch_status_t list_profiles_full(const char *line, const char *cursor, switch_console_callback_match_t **matches, switch_bool_t show_aliases);
switch_status_t list_profiles(const char *line, const char *cursor, switch_console_callback_match_t **matches);
sofia_cid_type_t sofia_cid_name2type(const char *name);
void sofia_glue_tech_set_local_sdp(private_object_t *tech_pvt, const char *sdp_str, switch_bool_t dup);
void sofia_glue_set_rtp_stats(private_object_t *tech_pvt);

View File

@ -486,12 +486,7 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
end:
if (sub_state == nua_substate_terminated && sofia_private && sofia_private != &mod_sofia_globals.destroy_private &&
sofia_private != &mod_sofia_globals.keep_private) {
sofia_private->destroy_nh = 1;
sofia_private->destroy_me = 1;
}
return;
}
void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
@ -558,13 +553,9 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
switch_channel_hangup(channel, cause);
nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
switch_safe_free(extra_headers);
if (sofia_private) {
sofia_private->destroy_me = 1;
sofia_private->destroy_nh = 1;
}
#endif
@ -585,6 +576,8 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
}
tech_pvt->got_bye = 1;
sofia_private->got_bye = 1;
switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_bye");
return;
@ -1075,28 +1068,19 @@ static void our_sofia_event_callback(nua_event_t event,
}
if (check_destroy) {
if (nh && ((sofia_private && sofia_private->destroy_nh) || !nua_handle_magic(nh))) {
if (0 && nh && ((sofia_private && sofia_private->destroy_nh) || !nua_handle_magic(nh))) {
printf("FUCKER2\n");
if (sofia_private) {
nua_handle_bind(nh, NULL);
}
nua_handle_destroy(nh);
nh = NULL;
}
}
if (sofia_private && sofia_private->destroy_me) {
if (tech_pvt) {
tech_pvt->sofia_private = NULL;
}
if (nh) {
nua_handle_bind(nh, NULL);
}
sofia_private->destroy_me = 12;
sofia_private_free(sofia_private);
}
if (gateway) {
sofia_reg_release_gateway(gateway);
}
@ -1115,15 +1099,22 @@ void sofia_process_dispatch_event(sofia_dispatch_event_t **dep)
sofia_dispatch_event_t *de = *dep;
nua_handle_t *nh = de->nh;
nua_t *nua = de->nua;
sofia_private_t *sofia_private = nua_handle_magic(de->nh);
*dep = NULL;
our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile,
de->nh, nua_handle_magic(de->nh), de->sip, de, (tagi_t *) de->data->e_tags);
sofia_private = nua_handle_magic(nh);
nua_destroy_event(de->event);
su_free(nh->nh_home, de);
//printf("QUEUE EVENT %s\n", nua_event_name(de->data->e_event));
our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile,
nh, sofia_private, de->sip, de, (tagi_t *) de->data->e_tags);
//printf("/QUEUE EVENT %s\n", nua_event_name(de->data->e_event));
nua_destroy_event(de->event);
su_free(nh->nh_home, de);
nua_handle_unref(nh);
nua_stack_unref(nua);
}
@ -1222,24 +1213,55 @@ void sofia_event_callback(nua_event_t event,
{
sofia_dispatch_event_t *de;
//printf("EVENT %s\n", nua_event_name(event));
if (event == nua_i_terminated) {
if (sofia_private && sofia_private->nh) {
nua_handle_bind(nh, NULL);
nua_handle_destroy(sofia_private->nh);
}
return;
}
de = su_alloc(nh->nh_home, sizeof(*de));
memset(de, 0, sizeof(*de));
nua_save_event(nua, de->event);
de->nh = nua_handle_ref(nh);
de->nh = nh;
de->data = nua_event_data(de->event);
de->sip = sip_object(de->data->e_msg);
de->profile = profile;
de->nua = nua_stack_ref(nua);
if (event == nua_i_state) {
int ss_state = nua_callstate_init;
tl_gets(tags, NUTAG_CALLSTATE_REF(ss_state), TAG_END());
//printf("state [%s][%d]\n", nua_callstate_name(ss_state), status);
if (ss_state == nua_callstate_terminated || ss_state == nua_callstate_terminating) {
sofia_process_dispatch_event(&de);
return;
}
}
if (event == nua_i_invite && !sofia_private) {
if (!(sofia_private = su_alloc(nh->nh_home, sizeof(*sofia_private)))) {
abort();
}
memset(sofia_private, 0, sizeof(*sofia_private));
sofia_private->is_call++;
sofia_private->is_call = 2;
sofia_private->de = de;
sofia_private->nh = nua_handle_ref(nh);
nua_handle_bind(nh, sofia_private);
return;
}
@ -1266,7 +1288,6 @@ void sofia_event_callback(nua_event_t event,
}
}
sofia_queue_message(de);
}
@ -3615,7 +3636,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
profile->client_rport_level = 1;
} else if (val && !strcasecmp(val, "server-only")) {
profile->client_rport_level = 0;
profile->client_rport_level = 1;
profile->server_rport_level = 1;
} else if (switch_true(val)) {
profile->server_rport_level = 2;
profile->client_rport_level = 1;
@ -4347,7 +4368,6 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
if (sofia_private && !zstr(sofia_private->gateway_name)) {
gateway = sofia_reg_find_gateway(sofia_private->gateway_name);
sofia_private->destroy_me = 1;
}
if (gateway) {
@ -5067,10 +5087,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
goto done;
}
}
if (sofia_private) {
sofia_private->destroy_me = 1;
}
}
if (session) {
@ -5806,21 +5822,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_channel_hangup(channel, cause);
}
if (ss_state == nua_callstate_terminated) {
if (tech_pvt->sofia_private) {
tech_pvt->sofia_private = NULL;
}
nua_handle_unref(tech_pvt->nh);
tech_pvt->nh = NULL;
if (nh) {
nua_handle_bind(nh, NULL);
nua_handle_destroy(nh);
}
}
break;
}
@ -7501,13 +7502,15 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
}
if (profile->pres_type) {
const char *user = switch_str_nil(sip->sip_from->a_url->url_user);
const char *host = switch_str_nil(sip->sip_from->a_url->url_host);
char *tmp = switch_mprintf("%s@%s", user, host);
switch_assert(tmp);
switch_channel_set_variable(channel, "presence_id", tmp);
free(tmp);
const char *presence_id = switch_channel_get_variable(channel, "presence_id");
if (zstr(presence_id)) {
const char *user = switch_str_nil(sip->sip_from->a_url->url_user);
const char *host = switch_str_nil(sip->sip_from->a_url->url_host);
char *tmp = switch_mprintf("%s@%s", user, host);
switch_assert(tmp);
switch_channel_set_variable(channel, "presence_id", tmp);
free(tmp);
}
}
@ -7817,7 +7820,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
tech_pvt->sofia_private = sofia_private;
tech_pvt->nh = nua_handle_ref(nh);
tech_pvt->nh = nh;
if (profile->pres_type && sofia_test_pflag(profile, PFLAG_IN_DIALOG_CHAT)) {
sofia_presence_set_chat_hash(tech_pvt, sip);
@ -7927,8 +7930,6 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
switch_mutex_unlock(tech_pvt->profile->flag_mutex);
}
nua_handle_bind(nh, NULL);
sofia_private_free(sofia_private);
switch_core_session_destroy(&session);
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
return;

View File

@ -2214,7 +2214,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
switch_safe_free(d_url);
return SWITCH_STATUS_FALSE;
}
nua_handle_ref(tech_pvt->nh);
if (tech_pvt->dest && (strstr(tech_pvt->dest, ";fs_nat") || strstr(tech_pvt->dest, ";received")
|| ((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val)))) {
@ -2309,6 +2308,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
memset(sofia_private, 0, sizeof(*sofia_private));
sofia_private->is_call++;
sofia_private->nh = nua_handle_ref(tech_pvt->nh);
tech_pvt->sofia_private = sofia_private;
switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
@ -5541,7 +5541,7 @@ int sofia_glue_recover(switch_bool_t flush)
switch_console_callback_match_t *matches;
if (list_profiles(NULL, NULL, &matches) == SWITCH_STATUS_SUCCESS) {
if (list_profiles_full(NULL, NULL, &matches, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
switch_console_callback_match_node_t *m;
for (m = matches->head; m; m = m->next) {
if ((profile = sofia_glue_find_profile(m->val))) {

View File

@ -282,7 +282,7 @@ void sofia_presence_cancel(void)
return;
}
if (list_profiles(NULL, NULL, &matches) == SWITCH_STATUS_SUCCESS) {
if (list_profiles_full(NULL, NULL, &matches, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
switch_console_callback_match_node_t *m;
sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
@ -409,7 +409,7 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
sql = switch_mprintf("select profile_name from sip_registrations where sip_host='%s' or mwi_host='%s'", host, host);
if (list_profiles(NULL, NULL, &matches) == SWITCH_STATUS_SUCCESS) {
if (list_profiles_full(NULL, NULL, &matches, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
switch_console_callback_match_node_t *m;
for (m = matches->head; m; m = m->next) {
@ -592,7 +592,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
switch_assert(sql != NULL);
if (list_profiles(NULL, NULL, &matches) == SWITCH_STATUS_SUCCESS) {
if (list_profiles_full(NULL, NULL, &matches, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
switch_console_callback_match_node_t *m;
for (m = matches->head; m; m = m->next) {
@ -788,7 +788,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
goto done;
}
if (list_profiles(NULL, NULL, &matches) == SWITCH_STATUS_SUCCESS) {
if (list_profiles_full(NULL, NULL, &matches, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
switch_console_callback_match_node_t *m;
for (m = matches->head; m; m = m->next) {
@ -1790,8 +1790,12 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
switch_safe_free(pl);
switch_safe_free(to);
if (nh && kill_handle) {
nua_handle_destroy(nh);
if (nh) {
if (kill_handle) {
nua_handle_destroy(nh);
} else {
nua_handle_unref(nh);
}
}
return 0;
@ -1841,6 +1845,10 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
end:
if (nh) {
nua_handle_unref(nh);
}
if (ext_profile) {
sofia_glue_release_profile(ext_profile);
}
@ -1931,6 +1939,8 @@ static int broadsoft_sla_notify_callback(void *pArg, int argc, char **argv, char
nua_notify(nh,
SIPTAG_EXPIRES_STR("0"),
SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), SIPTAG_EVENT_STR("line-seize"), SIPTAG_CALL_INFO_STR(tmp), TAG_END());
nua_handle_unref(nh);
return 0;
}
@ -1939,6 +1949,7 @@ static int broadsoft_sla_notify_callback(void *pArg, int argc, char **argv, char
TAG_IF(*expires_str, SIPTAG_EXPIRES_STR(expires_str)),
SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR("call-info"), SIPTAG_CALL_INFO_STR(tmp), TAG_END());
nua_handle_unref(nh);
}
return 0;
@ -2629,6 +2640,7 @@ static int sofia_counterpath_crutch(void *pArg, int argc, char **argv, char **co
SIPTAG_EXPIRES_STR(expstr),
SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(event_type),
SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
nua_handle_unref(nh);
}
return 0;

View File

@ -54,8 +54,9 @@ static void sofia_reg_new_handle(sofia_gateway_t *gateway_ptr, int attach)
NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END());
if (attach) {
if (!gateway_ptr->sofia_private) {
gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private));
switch_assert(gateway_ptr->sofia_private);
if (!(gateway_ptr->sofia_private = su_alloc(gateway_ptr->nh->nh_home, sizeof(*gateway_ptr->sofia_private)))) {
abort();
}
}
memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private));
@ -186,9 +187,10 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name);
gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private));
switch_assert(gateway_ptr->sofia_private);
if (!(gateway_ptr->sofia_private = su_alloc(gateway_ptr->sub_nh->nh_home, sizeof(*gateway_ptr->sofia_private)))) {
abort();
}
memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private));
gateway_ptr->sofia_private->gateway = gateway_ptr;
@ -290,7 +292,6 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
if (gateway_ptr->ping && !gateway_ptr->pinging && (now >= gateway_ptr->ping && (ostate == REG_STATE_NOREG || ostate == REG_STATE_REGED)) &&
!gateway_ptr->deleted) {
nua_handle_t *nh = nua_handle(profile->nua, NULL, NUTAG_URL(gateway_ptr->register_url), TAG_END());
sofia_private_t *pvt;
register_host = sofia_glue_get_register_host(gateway_ptr->register_proxy);
@ -301,13 +302,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
switch_safe_free(register_host);
pvt = malloc(sizeof(*pvt));
switch_assert(pvt);
memset(pvt, 0, sizeof(*pvt));
pvt->destroy_nh = 1;
pvt->destroy_me = 1;
switch_copy_string(pvt->gateway_name, gateway_ptr->name, sizeof(pvt->gateway_name));
nua_handle_bind(nh, pvt);
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
gateway_ptr->pinging = 1;
nua_options(nh,

View File

@ -219,6 +219,7 @@ SWITCH_DECLARE(void) switch_channel_perform_set_callstate(switch_channel_t *chan
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_CALLSTATE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Original-Channel-Call-State", switch_channel_callstate2str(o_callstate));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Call-State-Number", "%d", callstate);
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}

View File

@ -304,9 +304,9 @@ SWITCH_DECLARE(const char *) switch_core_get_switchname(void)
SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname)
{
char *val;
switch_mutex_lock(runtime.global_var_mutex);
switch_thread_rwlock_rdlock(runtime.global_var_rwlock);
val = (char *) switch_event_get_header(runtime.global_vars, varname);
switch_mutex_unlock(runtime.global_var_mutex);
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
return val;
}
@ -314,11 +314,11 @@ SWITCH_DECLARE(char *) switch_core_get_variable_dup(const char *varname)
{
char *val = NULL, *v;
switch_mutex_lock(runtime.global_var_mutex);
switch_thread_rwlock_rdlock(runtime.global_var_rwlock);
if ((v = (char *) switch_event_get_header(runtime.global_vars, varname))) {
val = strdup(v);
}
switch_mutex_unlock(runtime.global_var_mutex);
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
return val;
}
@ -327,21 +327,21 @@ SWITCH_DECLARE(char *) switch_core_get_variable_pdup(const char *varname, switch
{
char *val = NULL, *v;
switch_mutex_lock(runtime.global_var_mutex);
switch_thread_rwlock_rdlock(runtime.global_var_rwlock);
if ((v = (char *) switch_event_get_header(runtime.global_vars, varname))) {
val = switch_core_strdup(pool, v);
}
switch_mutex_unlock(runtime.global_var_mutex);
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
return val;
}
static void switch_core_unset_variables(void)
{
switch_mutex_lock(runtime.global_var_mutex);
switch_thread_rwlock_wrlock(runtime.global_var_rwlock);
switch_event_destroy(&runtime.global_vars);
switch_event_create_plain(&runtime.global_vars, SWITCH_EVENT_CHANNEL_DATA);
switch_mutex_unlock(runtime.global_var_mutex);
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
}
SWITCH_DECLARE(void) switch_core_set_variable(const char *varname, const char *value)
@ -349,7 +349,7 @@ SWITCH_DECLARE(void) switch_core_set_variable(const char *varname, const char *v
char *val;
if (varname) {
switch_mutex_lock(runtime.global_var_mutex);
switch_thread_rwlock_wrlock(runtime.global_var_rwlock);
val = (char *) switch_event_get_header(runtime.global_vars, varname);
if (val) {
switch_event_del_header(runtime.global_vars, varname);
@ -361,7 +361,7 @@ SWITCH_DECLARE(void) switch_core_set_variable(const char *varname, const char *v
} else {
switch_event_del_header(runtime.global_vars, varname);
}
switch_mutex_unlock(runtime.global_var_mutex);
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
}
}
@ -370,17 +370,17 @@ SWITCH_DECLARE(switch_bool_t) switch_core_set_var_conditional(const char *varnam
char *val;
if (varname) {
switch_mutex_lock(runtime.global_var_mutex);
switch_thread_rwlock_wrlock(runtime.global_var_rwlock);
val = (char *) switch_event_get_header(runtime.global_vars, varname);
if (val) {
if (!val2 || strcmp(val, val2) != 0) {
switch_mutex_unlock(runtime.global_var_mutex);
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
return SWITCH_FALSE;
}
switch_event_del_header(runtime.global_vars, varname);
} else if (!zstr(val2)) {
switch_mutex_unlock(runtime.global_var_mutex);
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
return SWITCH_FALSE;
}
@ -391,7 +391,7 @@ SWITCH_DECLARE(switch_bool_t) switch_core_set_var_conditional(const char *varnam
} else {
switch_event_del_header(runtime.global_vars, varname);
}
switch_mutex_unlock(runtime.global_var_mutex);
switch_thread_rwlock_unlock(runtime.global_var_rwlock);
}
return SWITCH_TRUE;
}
@ -1400,7 +1400,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
switch_mutex_init(&runtime.session_hash_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
switch_mutex_init(&runtime.global_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
switch_mutex_init(&runtime.global_var_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
switch_thread_rwlock_create(&runtime.global_var_rwlock, runtime.memory_pool);
switch_core_set_globals();
switch_core_session_init(runtime.memory_pool);
switch_event_create_plain(&runtime.global_vars, SWITCH_EVENT_CHANNEL_DATA);

View File

@ -35,6 +35,8 @@
#include <switch.h>
#include "private/switch_core_pvt.h"
//#define DEBUG_SQL 1
#define SWITCH_SQL_QUEUE_LEN 100000
#define SWITCH_SQL_QUEUE_PAUSE_LEN 90000
struct switch_cache_db_handle {
char name[CACHE_DB_LEN];
@ -942,7 +944,6 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
switch_size_t newlen;
int lc = 0, wrote = 0, do_sleep = 1;
uint32_t sanity = 120;
int too_long = SWITCH_SQL_QUEUE_LEN / 2;
int auto_pause = 0;
switch_assert(sqlbuf);
@ -964,6 +965,12 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
switch_mutex_lock(sql_manager.cond_mutex);
switch_cache_db_execute_sql(sql_manager.event_db, "PRAGMA synchronous=OFF;", NULL);
switch_cache_db_execute_sql(sql_manager.event_db, "PRAGMA count_changes=OFF;", NULL);
switch_cache_db_execute_sql(sql_manager.event_db, "PRAGMA temp_store=MEMORY;", NULL);
switch_cache_db_execute_sql(sql_manager.event_db, "PRAGMA journal_mode=OFF;", NULL);
while (sql_manager.thread_running == 1) {
if (save_sql || switch_queue_trypop(sql_manager.sql_queue[0], &pop) == SWITCH_STATUS_SUCCESS ||
switch_queue_trypop(sql_manager.sql_queue[1], &pop) == SWITCH_STATUS_SUCCESS) {
@ -1024,7 +1031,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
lc = switch_queue_size(sql_manager.sql_queue[0]) + switch_queue_size(sql_manager.sql_queue[1]);
if (lc > too_long) {
if (lc > SWITCH_SQL_QUEUE_PAUSE_LEN) {
if (!auto_pause) {
auto_pause = 1;
switch_core_session_ctl(SCSC_PAUSE_INBOUND, &auto_pause);
@ -1055,6 +1062,8 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
#ifdef DEBUG_SQL
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DONE\n");
#endif
iterations = 0;
trans = 0;
len = 0;
@ -1062,6 +1071,8 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
lc = 0;
if (do_sleep) {
switch_yield(200000);
} else {
switch_yield(1000);
}
wrote = 1;
}
@ -1228,6 +1239,7 @@ static void core_event_handler(switch_event_t *event)
);
break;
case SWITCH_EVENT_CODEC:
new_sql() =
switch_mprintf
("update channels set read_codec='%q',read_rate='%q',read_bit_rate='%q',write_codec='%q',write_rate='%q',write_bit_rate='%q' where uuid='%q' and hostname='%q'",
@ -1322,9 +1334,18 @@ static void core_event_handler(switch_event_t *event)
break;
case SWITCH_EVENT_CHANNEL_CALLSTATE:
{
new_sql() = switch_mprintf("update channels set callstate='%q' where uuid='%q' and hostname='%q'",
switch_event_get_header_nil(event, "channel-call-state"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
char *num = switch_event_get_header_nil(event, "channel-call-state-number");
switch_channel_callstate_t callstate = CCS_DOWN;
if (num) {
callstate = atoi(num);
}
if (callstate != CCS_DOWN && callstate != CCS_HANGUP) {
new_sql() = switch_mprintf("update channels set callstate='%q' where uuid='%q' and hostname='%q'",
switch_event_get_header_nil(event, "channel-call-state"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
}
}
break;
@ -1338,8 +1359,10 @@ static void core_event_handler(switch_event_t *event)
}
switch (state_i) {
case CS_NEW:
case CS_HANGUP:
case CS_DESTROY:
case CS_REPORTING:
break;
case CS_ROUTING:
if ((extra_cols = parse_presence_data_cols(event))) {
@ -1802,8 +1825,9 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
switch_cache_db_execute_sql(dbh, "drop table tasks", NULL);
switch_cache_db_execute_sql(dbh, "PRAGMA synchronous=OFF;", NULL);
switch_cache_db_execute_sql(dbh, "PRAGMA count_changes=OFF;", NULL);
switch_cache_db_execute_sql(dbh, "PRAGMA cache_size=8000", NULL);
switch_cache_db_execute_sql(dbh, "PRAGMA default_cache_size=8000", NULL);
switch_cache_db_execute_sql(dbh, "PRAGMA temp_store=MEMORY;", NULL);
switch_cache_db_execute_sql(dbh, "PRAGMA journal_mode=OFF;", NULL);
}
break;
}

View File

@ -175,8 +175,9 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
if (impl->decoded_bytes_per_packet > SWITCH_RECOMMENDED_BUFFER_SIZE) {
load_interface = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
"Failed to load codec interface %s from %s due to bytes per frame exceeding buffer size.\n", ptr->interface_name,
key);
"Failed to load codec interface %s from %s due to bytes per frame %d exceeding buffer size %d.\n",
ptr->interface_name,
key, impl->decoded_bytes_per_packet, SWITCH_RECOMMENDED_BUFFER_SIZE);
break;
}
}