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

This commit is contained in:
Giovanni Maruzzelli
2011-07-13 06:04:45 -05:00
13 changed files with 140 additions and 42 deletions
+1 -1
View File
@@ -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;
+4 -1
View File
@@ -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);
+2 -2
View File
@@ -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;
+9 -7
View File
@@ -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);
}
}
+1
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);
}
+16 -15
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);
+27 -4
View File
@@ -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;
}