From 5247d559f2ffa06f45c4931182d177b0aa858c6e Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Tue, 12 Jul 2011 14:35:53 -0500 Subject: [PATCH 1/6] FS-3414 --resolve --- Freeswitch.2008.express.sln | 1 + 1 file changed, 1 insertion(+) diff --git a/Freeswitch.2008.express.sln b/Freeswitch.2008.express.sln index 43cbc02d0e..cd0033bba2 100644 --- a/Freeswitch.2008.express.sln +++ b/Freeswitch.2008.express.sln @@ -168,6 +168,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libaprutil", "libs\win32\apr-util\libaprutil.2008.vcproj", "{F057DA7F-79E5-4B00-845C-EF446EF055E3}" ProjectSection(ProjectDependencies) = postProject {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} + {155844C3-EC5F-407F-97A4-A2DDADED9B2F} = {155844C3-EC5F-407F-97A4-A2DDADED9B2F} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iksemel", "libs\win32\iksemel\iksemel.2008.vcproj", "{E727E8F6-935D-46FE-8B0E-37834748A0E3}" From f0578a801182fb78f41cae27cd52bacd941fdda3 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 12 Jul 2011 17:26:44 -0400 Subject: [PATCH 2/6] chlog: freetdm: ISDN - Fix for Caller ID name on DMS-100 --- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 3 +- .../ftmod_sangoma_isdn_stack_hndl.c | 5 +- .../ftmod_sangoma_isdn_support.c | 49 ++++++++++++++++++- .../ftmod_sangoma_isdn_trace.c | 20 ++++++-- .../ftmod_sangoma_isdn_trace.h | 14 +++++- 5 files changed, 79 insertions(+), 12 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index 08adc6ef6b..5cb8fbe0c0 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -452,8 +452,7 @@ ftdm_status_t get_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb); ftdm_status_t get_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb); ftdm_status_t get_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb); ftdm_status_t get_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb); -ftdm_status_t get_calling_name_from_display(ftdm_channel_t *ftdmchan, Display *display); -ftdm_status_t get_calling_name_from_usr_usr(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr); +ftdm_status_t get_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt); ftdm_status_t get_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad); ftdm_status_t get_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd); ftdm_status_t get_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index 44538bba61..4caad20ee1 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -135,11 +135,8 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) get_calling_subaddr(ftdmchan, &conEvnt->cgPtySad); get_prog_ind_ie(ftdmchan, &conEvnt->progInd); get_facility_ie(ftdmchan, &conEvnt->facilityStr); + get_calling_name(ftdmchan, conEvnt); - if (get_calling_name_from_display(ftdmchan, &conEvnt->display) != FTDM_SUCCESS) { - get_calling_name_from_usr_usr(ftdmchan, &conEvnt->usrUsr); - } - ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Incoming call: Called No:[%s] Calling No:[%s]\n", ftdmchan->caller_data.dnis.digits, ftdmchan->caller_data.cid_num.digits); if (conEvnt->bearCap[0].eh.pres) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index b0c3efe271..a2bca1f8fa 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -45,6 +45,9 @@ SNGISDN_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_loc, ftdm_sngisdn_progind_loc2str static uint8_t get_trillium_val(ftdm2trillium_t *vals, uint8_t ftdm_val, uint8_t default_val); static uint8_t get_ftdm_val(ftdm2trillium_t *vals, uint8_t trillium_val, uint8_t default_val); +ftdm_status_t get_calling_name_from_usr_usr(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr); +ftdm_status_t get_calling_name_from_display(ftdm_channel_t *ftdmchan, Display *display); +ftdm_status_t get_calling_name_from_ntDisplay(ftdm_channel_t *ftdmchan, NtDisplay *display); extern ftdm_sngisdn_data_t g_sngisdn_data; @@ -355,6 +358,20 @@ ftdm_status_t get_calling_name_from_display(ftdm_channel_t *ftdmchan, Display *d return FTDM_SUCCESS; } +ftdm_status_t get_calling_name_from_ntDisplay(ftdm_channel_t *ftdmchan, NtDisplay *display) +{ + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; + if (display->eh.pres != PRSNT_NODEF) { + return FTDM_FAIL; + } + if (display->dispInfo.pres != PRSNT_NODEF) { + return FTDM_FAIL; + } + + ftdm_copy_string(caller_data->cid_name, (const char*)display->dispInfo.val, display->dispInfo.len+1); + return FTDM_SUCCESS; +} + ftdm_status_t get_calling_name_from_usr_usr(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr) { ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; @@ -374,6 +391,24 @@ ftdm_status_t get_calling_name_from_usr_usr(ftdm_channel_t *ftdmchan, UsrUsr *us return FTDM_SUCCESS; } +ftdm_status_t get_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt) +{ + ftdm_status_t status = FTDM_FAIL; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; + + if (signal_data->switchtype == SNGISDN_SWITCH_DMS100) { + status = get_calling_name_from_ntDisplay(ftdmchan, &conEvnt->ntDisplay[0]); + } else { + status = get_calling_name_from_display(ftdmchan, &conEvnt->display); + + } + if (status != FTDM_SUCCESS) { + status = get_calling_name_from_usr_usr(ftdmchan, &conEvnt->usrUsr); + } + return status; +} + + ftdm_status_t get_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad) { char subaddress[100]; @@ -694,12 +729,22 @@ ftdm_status_t set_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt) /* follow through */ case SNGISDN_SWITCH_5ESS: case SNGISDN_SWITCH_4ESS: - case SNGISDN_SWITCH_DMS100: - conEvnt->display.eh.pres = PRSNT_NODEF; conEvnt->display.dispInfo.pres = PRSNT_NODEF; conEvnt->display.dispInfo.len = len; memcpy(conEvnt->display.dispInfo.val, caller_data->cid_name, len); break; + case SNGISDN_SWITCH_DMS100: + conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].dispTypeNt.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].dispTypeNt.val = 0x01; /* Calling Party Name */ + conEvnt->ntDisplay[0].assocInfo.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].assocInfo.val = 0x03; /* Included */ + conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].dispInfo.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].dispInfo.len = len; + memcpy(conEvnt->ntDisplay[0].dispInfo.val, caller_data->cid_name, len); + break; case SNGISDN_SWITCH_QSIG: /* It seems like QSIG does not support Caller ID Name */ break; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c index f44f1032a3..e127e7fc1e 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c @@ -584,11 +584,18 @@ uint32_t sngisdn_decode_ie(char *str, uint32_t *str_len, uint8_t current_codeset break; case PROT_Q931_IE_DISPLAY: { - uint8_t displayStrOct=2, j; + uint8_t j, displayType, assocInfo; char displayStr[82]; + uint8_t displayNtEnabled = 0; + uint8_t displayStrOct = 2; + memset(displayStr, 0, sizeof(displayStr)); if(get_bits(OCTET(3),8,8)) { + displayType = get_bits(OCTET(3),1,4); + assocInfo = get_bits(OCTET(3),5,7); + + displayNtEnabled = 1; displayStrOct++; } j = 0; @@ -599,8 +606,15 @@ uint32_t sngisdn_decode_ie(char *str, uint32_t *str_len, uint8_t current_codeset displayStr[j++]=ia5[get_bits(OCTET(displayStrOct),1,4)][get_bits(OCTET(displayStrOct),5,8)]; } displayStr[j]='\0'; - *str_len+= sprintf(&str[*str_len], "%s(l:%d)\n", - displayStr, len); + if (displayNtEnabled) { + *str_len+= sprintf(&str[*str_len], "%s(l:%d) type:%s(%d) info:%s(%d)\n", + displayStr, len, + get_code_2_str(displayType, dcodQ931DisplayTypeTable), displayType, + get_code_2_str(assocInfo, dcodQ931AssocInfoTable), assocInfo); + } else { + *str_len+= sprintf(&str[*str_len], "%s(l:%d)\n", + displayStr, len); + } } break; case PROT_Q931_IE_RESTART_IND: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h index ca6683d4e3..37b799d007 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h @@ -578,5 +578,17 @@ struct code2str dcodQ931TypeOfSubaddressTable[] = { { -1, "Invalid"}, }; -#endif /* __FTMOD_SANGOMA_ISDN_TRACE_H__ */ +struct code2str dcodQ931DisplayTypeTable[] = { + { 0x00, "Calling Party Name"}, + { 0x01, "Connected Party Name"}, + { 0x05, "Original Called Party Name"}, + { -1, "Invalid"}, +}; +struct code2str dcodQ931AssocInfoTable[] = { + { 0x00, "Requested"}, + { 0x03, "Included"}, + { -1, "Invalid"}, +}; + +#endif /* __FTMOD_SANGOMA_ISDN_TRACE_H__ */ From 9f1b731164a2dd7c4aa20920184751066a560afc Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 12 Jul 2011 20:33:58 -0500 Subject: [PATCH 3/6] up vals --- src/mod/endpoints/mod_sofia/mod_sofia.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 3350b7b7f8..8b1422ba8c 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -317,8 +317,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 2000 struct mod_sofia_globals { switch_memory_pool_t *pool; From 11690aff4c4b819e981c4763abff37c33700f5ab Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 12 Jul 2011 20:36:08 -0500 Subject: [PATCH 4/6] remove some unnecessary sql stmts --- src/switch_core_sqldb.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 7d40114ed1..b3c2e7112c 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -964,6 +964,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) { @@ -1055,6 +1061,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 +1070,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 +1238,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 +1333,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 +1358,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 +1824,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; } From 0521886de89621ab6cc76b71f6557f5e8867ca81 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 12 Jul 2011 20:36:36 -0500 Subject: [PATCH 5/6] use rwlock for global vars to reduce contention --- src/include/private/switch_core_pvt.h | 2 +- src/switch_channel.c | 1 + src/switch_core.c | 31 ++++++++++++++------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index 3b530b3940..6115e70ede 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -221,7 +221,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; diff --git a/src/switch_channel.c b/src/switch_channel.c index b1abb86cd8..f5667100a8 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -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); } diff --git a/src/switch_core.c b/src/switch_core.c index 721d53cfef..e7cd60d58f 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -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); From 7cdc8342dcac8c0563486f2a200c9a69620c9a15 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 13 Jul 2011 04:32:00 +0000 Subject: [PATCH 6/6] if user has set presence_id, don't override it --- src/mod/endpoints/mod_sofia/mod_sofia.c | 5 ++++- src/mod/endpoints/mod_sofia/sofia.c | 16 +++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 8504dc137e..7ebbe33f70 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -4358,7 +4358,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); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 8817062e59..6823acf133 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -7501,13 +7501,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); + } }