mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
tear the hell out of everything and rip it up into itsy bitsy pieces and put it all back together
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5765 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -104,16 +104,16 @@ SWITCH_STANDARD_API(ctl_function)
|
||||
if ((mydata = strdup(cmd))) {
|
||||
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (!strcmp(argv[0], "hupall")) {
|
||||
if (!strcasecmp(argv[0], "hupall")) {
|
||||
arg = 1;
|
||||
switch_core_session_ctl(SCSC_HUPALL, &arg);
|
||||
} else if (!strcmp(argv[0], "pause")) {
|
||||
} else if (!strcasecmp(argv[0], "pause")) {
|
||||
arg = 1;
|
||||
switch_core_session_ctl(SCSC_PAUSE_INBOUND, &arg);
|
||||
} else if (!strcmp(argv[0], "resume")) {
|
||||
} else if (!strcasecmp(argv[0], "resume")) {
|
||||
arg = 0;
|
||||
switch_core_session_ctl(SCSC_PAUSE_INBOUND, &arg);
|
||||
} else if (!strcmp(argv[0], "shutdown")) {
|
||||
} else if (!strcasecmp(argv[0], "shutdown")) {
|
||||
arg = 0;
|
||||
switch_core_session_ctl(SCSC_SHUTDOWN, &arg);
|
||||
} else {
|
||||
@@ -431,7 +431,7 @@ SWITCH_STANDARD_API(uuid_media_function)
|
||||
if (switch_strlen_zero(cmd) || argc < 1) {
|
||||
stream->write_function(stream, "USAGE: %s\n", MEDIA_SYNTAX);
|
||||
} else {
|
||||
if (!strcmp(argv[0], "off")) {
|
||||
if (!strcasecmp(argv[0], "off")) {
|
||||
status = switch_ivr_nomedia(argv[1], SMF_REBRIDGE);
|
||||
} else {
|
||||
status = switch_ivr_media(argv[0], SMF_REBRIDGE);
|
||||
@@ -469,11 +469,11 @@ SWITCH_STANDARD_API(uuid_broadcast_function)
|
||||
switch_media_flag_t flags = SMF_NONE;
|
||||
|
||||
if (argv[2]) {
|
||||
if (!strcmp(argv[2], "both")) {
|
||||
if (!strcasecmp(argv[2], "both")) {
|
||||
flags |= (SMF_ECHO_ALEG | SMF_ECHO_BLEG);
|
||||
} else if (!strcmp(argv[2], "aleg")) {
|
||||
} else if (!strcasecmp(argv[2], "aleg")) {
|
||||
flags |= SMF_ECHO_ALEG;
|
||||
} else if (!strcmp(argv[2], "bleg")) {
|
||||
} else if (!strcasecmp(argv[2], "bleg")) {
|
||||
flags |= SMF_ECHO_BLEG;
|
||||
}
|
||||
} else {
|
||||
@@ -516,11 +516,11 @@ SWITCH_STANDARD_API(sched_broadcast_function)
|
||||
}
|
||||
|
||||
if (argv[3]) {
|
||||
if (!strcmp(argv[3], "both")) {
|
||||
if (!strcasecmp(argv[3], "both")) {
|
||||
flags |= (SMF_ECHO_ALEG | SMF_ECHO_BLEG);
|
||||
} else if (!strcmp(argv[3], "aleg")) {
|
||||
} else if (!strcasecmp(argv[3], "aleg")) {
|
||||
flags |= SMF_ECHO_ALEG;
|
||||
} else if (!strcmp(argv[3], "bleg")) {
|
||||
} else if (!strcasecmp(argv[3], "bleg")) {
|
||||
flags |= SMF_ECHO_BLEG;
|
||||
}
|
||||
} else {
|
||||
@@ -553,7 +553,7 @@ SWITCH_STANDARD_API(uuid_hold_function)
|
||||
if (switch_strlen_zero(cmd) || argc < 1) {
|
||||
stream->write_function(stream, "USAGE: %s\n", HOLD_SYNTAX);
|
||||
} else {
|
||||
if (!strcmp(argv[0], "off")) {
|
||||
if (!strcasecmp(argv[0], "off")) {
|
||||
status = switch_ivr_unhold_uuid(argv[1]);
|
||||
} else {
|
||||
status = switch_ivr_hold_uuid(argv[0]);
|
||||
@@ -799,27 +799,28 @@ SWITCH_STANDARD_API(originate_function)
|
||||
{
|
||||
switch_channel_t *caller_channel;
|
||||
switch_core_session_t *caller_session = NULL;
|
||||
char *mycmd = NULL, *argv[7] = { 0 };
|
||||
char *mycmd = NULL, *argv[10] = { 0 };
|
||||
int i = 0, x, argc = 0;
|
||||
char *aleg, *exten, *dp, *context, *cid_name, *cid_num;
|
||||
uint32_t timeout = 60;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
uint8_t machine = 1;
|
||||
|
||||
if (session) {
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
if (session || switch_strlen_zero(cmd)) {
|
||||
stream->write_function(stream, "Illegal Usage\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
|
||||
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
}
|
||||
|
||||
if (switch_strlen_zero(cmd) || argc < 2 || argc > 7) {
|
||||
mycmd = strdup(cmd);
|
||||
assert(mycmd);
|
||||
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (argc < 2 || argc > 7) {
|
||||
stream->write_function(stream, "USAGE: %s\n", ORIGINATE_SYNTAX);
|
||||
switch_safe_free(mycmd);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
for (x = 0; x < argc; x++) {
|
||||
if (!strcasecmp(argv[x], "undef")) {
|
||||
@@ -857,14 +858,13 @@ SWITCH_STANDARD_API(originate_function)
|
||||
} else {
|
||||
stream->write_function(stream, "Cannot Create Outgoing Channel! [%s] cause: %s\n", aleg, switch_channel_cause2str(cause));
|
||||
}
|
||||
switch_safe_free(mycmd);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
goto done;
|
||||
}
|
||||
|
||||
caller_channel = switch_core_session_get_channel(caller_session);
|
||||
assert(caller_channel != NULL);
|
||||
switch_channel_clear_state_handler(caller_channel, NULL);
|
||||
|
||||
|
||||
if (*exten == '&' && *(exten + 1)) {
|
||||
switch_caller_extension_t *extension = NULL;
|
||||
char *app_name = switch_core_session_strdup(caller_session, (exten + 1));
|
||||
@@ -880,9 +880,7 @@ SWITCH_STANDARD_API(originate_function)
|
||||
|
||||
if ((extension = switch_caller_extension_new(caller_session, app_name, arg)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
switch_safe_free(mycmd);
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
abort();
|
||||
}
|
||||
switch_caller_extension_add_application(caller_session, extension, app_name, arg);
|
||||
switch_channel_set_caller_extension(caller_channel, extension);
|
||||
@@ -901,8 +899,9 @@ SWITCH_STANDARD_API(originate_function)
|
||||
switch_core_session_rwunlock(caller_session);
|
||||
}
|
||||
|
||||
done:
|
||||
switch_safe_free(mycmd);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
static void sch_api_callback(switch_scheduler_task_t *task)
|
||||
@@ -1140,6 +1139,7 @@ SWITCH_STANDARD_API(show_function)
|
||||
char *mydata = NULL, *argv[6] = {0};
|
||||
int argc;
|
||||
char *command = NULL, *as = NULL;
|
||||
switch_core_flag_t cflags = switch_core_flags();
|
||||
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -1159,20 +1159,25 @@ SWITCH_STANDARD_API(show_function)
|
||||
|
||||
holder.print_title = 1;
|
||||
|
||||
if (!(cflags & SCF_USE_SQL) && !strcasecmp(command, "channels")) {
|
||||
stream->write_function(stream, "SQL DISABLED NO CHANNEL DATA AVAILABLE!\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// If you changes the field qty or order of any of these select
|
||||
// statmements, you must also change show_callback and friends to match!
|
||||
if (!command) {
|
||||
stream->write_function(stream, "USAGE: %s\n", SHOW_SYNTAX);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else if (!strcmp(command, "codec") || !strcmp(command, "dialplan") || !strcmp(command, "file") || !strcmp(command, "timer")) {
|
||||
} else if (!strcasecmp(command, "codec") || !strcasecmp(command, "dialplan") || !strcasecmp(command, "file") || !strcasecmp(command, "timer")) {
|
||||
sprintf(sql, "select type, name from interfaces where type = '%s'", command);
|
||||
} else if (!strcmp(command, "tasks")) {
|
||||
} else if (!strcasecmp(command, "tasks")) {
|
||||
sprintf(sql, "select * from %s", command);
|
||||
} else if (!strcmp(command, "application") || !strcmp(command, "api")) {
|
||||
} else if (!strcasecmp(command, "application") || !strcasecmp(command, "api")) {
|
||||
sprintf(sql, "select name, description, syntax from interfaces where type = '%s' and description != ''", command);
|
||||
} else if (!strcmp(command, "calls")) {
|
||||
} else if (!strcasecmp(command, "calls")) {
|
||||
sprintf(sql, "select * from calls");
|
||||
} else if (!strcmp(command, "channels")) {
|
||||
} else if (!strcasecmp(command, "channels")) {
|
||||
sprintf(sql, "select * from channels");
|
||||
} else if (!strncasecmp(command, "help", 4)) {
|
||||
char *cmdname = NULL;
|
||||
|
||||
@@ -5038,6 +5038,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown)
|
||||
/* free api interface help ".syntax" field string */
|
||||
switch_safe_free(api_syntax);
|
||||
}
|
||||
switch_core_hash_destroy(&globals.conference_hash);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
#endif
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_enum_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_enum, mod_enum_load, NULL, NULL);
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_enum_shutdown);
|
||||
SWITCH_MODULE_DEFINITION(mod_enum, mod_enum_load, mod_enum_shutdown, NULL);
|
||||
|
||||
struct enum_record {
|
||||
int order;
|
||||
@@ -582,13 +583,10 @@ SWITCH_STANDARD_APP(enum_app_function)
|
||||
dest = argv[0];
|
||||
root = argv[1] ? argv[1] : globals.root;
|
||||
if (enum_lookup(root, data, &results) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_hash_index_t *hi;
|
||||
void *vval;
|
||||
const void *vvar;
|
||||
|
||||
switch_event_header_t *hi;
|
||||
if ((hi = switch_channel_variable_first(channel))) {
|
||||
for (; hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &vvar, NULL, &vval);
|
||||
for (; hi; hi = hi->next) {
|
||||
char *vvar = hi->name;
|
||||
if (vvar && !strncmp(vvar, "enum_", 5)) {
|
||||
switch_channel_set_variable(channel, (char *) vvar, NULL);
|
||||
}
|
||||
@@ -702,3 +700,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_enum_load)
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_enum_shutdown)
|
||||
{
|
||||
switch_core_hash_destroy(&globals.routes);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ static switch_status_t dialplan_xml_locate(switch_core_session_t *session, switc
|
||||
char *encode_buf = NULL;
|
||||
char *prof[12] = { 0 }, *prof_names[12] = {
|
||||
0}, *e = NULL;
|
||||
switch_hash_index_t *hi;
|
||||
switch_event_header_t *hi;
|
||||
uint32_t x = 0;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
@@ -253,10 +253,9 @@ static switch_status_t dialplan_xml_locate(switch_core_session_t *session, switc
|
||||
}
|
||||
|
||||
if ((hi = switch_channel_variable_first(channel))) {
|
||||
for (; hi; hi = switch_hash_next(hi)) {
|
||||
void *val;
|
||||
const void *var;
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
for (; hi; hi = hi->next) {
|
||||
char *var = hi->name;
|
||||
char *val = hi->value;
|
||||
|
||||
new_len = (strlen((char *) var) * 3) + 1;
|
||||
if (encode_len < new_len) {
|
||||
|
||||
@@ -956,6 +956,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_alsa_shutdown)
|
||||
if (globals.write_codec.implementation) {
|
||||
switch_core_codec_destroy(&globals.write_codec);
|
||||
}
|
||||
switch_core_hash_destroy(&globals.call_hash);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1905,6 +1905,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dingaling_shutdown)
|
||||
ldl_global_destroy();
|
||||
}
|
||||
}
|
||||
switch_core_hash_destroy(&globals.profile_hash);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -973,6 +973,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_portaudio_shutdown)
|
||||
|
||||
switch_core_timer_destroy(&globals.timer);
|
||||
Pa_Terminate();
|
||||
switch_core_hash_destroy(&globals.call_hash);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1360,6 +1360,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
if (!(tech_pvt = (struct private_object *) switch_core_session_alloc(nsession, sizeof(*tech_pvt)))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n");
|
||||
switch_core_session_destroy(&nsession);
|
||||
*pool = NULL;
|
||||
goto done;
|
||||
}
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(nsession));
|
||||
@@ -1375,6 +1376,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
|
||||
switch_core_session_destroy(&nsession);
|
||||
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
|
||||
*pool = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -1384,6 +1386,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
|
||||
switch_core_session_destroy(&nsession);
|
||||
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
|
||||
*pool = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -1393,6 +1396,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Gateway\n");
|
||||
switch_core_session_destroy(&nsession);
|
||||
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
|
||||
*pool = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -1411,6 +1415,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
|
||||
switch_core_session_destroy(&nsession);
|
||||
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
|
||||
*pool = NULL;
|
||||
goto done;
|
||||
}
|
||||
*dest++ = '\0';
|
||||
@@ -1419,6 +1424,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile\n");
|
||||
switch_core_session_destroy(&nsession);
|
||||
cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
|
||||
*pool = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -1440,6 +1446,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", dest, host);
|
||||
cause = SWITCH_CAUSE_NO_ROUTE_DESTINATION;
|
||||
switch_core_session_destroy(&nsession);
|
||||
*pool = NULL;
|
||||
goto done;
|
||||
}
|
||||
} else if (!strchr(dest, '@')) {
|
||||
@@ -1452,6 +1459,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", dest, profile_name);
|
||||
cause = SWITCH_CAUSE_NO_ROUTE_DESTINATION;
|
||||
switch_core_session_destroy(&nsession);
|
||||
*pool = NULL;
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
@@ -1609,6 +1617,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown)
|
||||
|
||||
su_deinit();
|
||||
|
||||
switch_core_hash_destroy(&mod_sofia_globals.profile_hash);
|
||||
switch_core_hash_destroy(&mod_sofia_globals.gateway_hash);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ typedef struct private_object private_object_t;
|
||||
struct sofia_private {
|
||||
char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
sofia_gateway_t *gateway;
|
||||
su_home_t *home;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -419,6 +419,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
||||
|
||||
|
||||
sofia_glue_del_profile(profile);
|
||||
switch_core_hash_destroy(&profile->chat_hash);
|
||||
|
||||
switch_thread_rwlock_unlock(profile->rwlock);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write unlock %s\n", profile->name);
|
||||
@@ -1146,38 +1147,46 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
if (match) {
|
||||
nua_handle_t *bnh;
|
||||
sip_replaces_t *replaces;
|
||||
su_home_t *home = NULL;
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED");
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_READY);
|
||||
switch_channel_set_state(channel, CS_INIT);
|
||||
//switch_core_session_thread_launch(session);
|
||||
|
||||
if (replaces_str && (replaces = sip_replaces_make(tech_pvt->sofia_private->home, replaces_str))
|
||||
&& (bnh = nua_handle_by_replaces(nua, replaces))) {
|
||||
sofia_private_t *b_private;
|
||||
if (replaces_str) {
|
||||
home = su_home_new(sizeof(*home));
|
||||
assert(home != NULL);
|
||||
if ((replaces = sip_replaces_make(home, replaces_str))
|
||||
&& (bnh = nua_handle_by_replaces(nua, replaces))) {
|
||||
sofia_private_t *b_private;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Processing Replaces Attended Transfer\n");
|
||||
while (switch_channel_get_state(channel) < CS_EXECUTE) {
|
||||
switch_yield(10000);
|
||||
}
|
||||
|
||||
if ((b_private = nua_handle_magic(bnh))) {
|
||||
char *br_b = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
|
||||
char *br_a = b_private->uuid;
|
||||
|
||||
if (br_b) {
|
||||
switch_ivr_uuid_bridge(br_a, br_b);
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Processing Replaces Attended Transfer\n");
|
||||
while (switch_channel_get_state(channel) < CS_EXECUTE) {
|
||||
switch_yield(10000);
|
||||
}
|
||||
|
||||
if ((b_private = nua_handle_magic(bnh))) {
|
||||
char *br_b = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
|
||||
char *br_a = b_private->uuid;
|
||||
|
||||
if (br_b) {
|
||||
switch_ivr_uuid_bridge(br_a, br_b);
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
|
||||
} else {
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
}
|
||||
} else {
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
}
|
||||
} else {
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
nua_handle_unref(bnh);
|
||||
}
|
||||
nua_handle_unref(bnh);
|
||||
su_home_unref(home);
|
||||
home = NULL;
|
||||
}
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -1351,9 +1360,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
}
|
||||
|
||||
if (tech_pvt->sofia_private) {
|
||||
if (tech_pvt->sofia_private->home) {
|
||||
su_home_unref(tech_pvt->sofia_private->home);
|
||||
}
|
||||
free(tech_pvt->sofia_private);
|
||||
tech_pvt->sofia_private = NULL;
|
||||
}
|
||||
@@ -1362,9 +1368,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
|
||||
|
||||
} else if (sofia_private) {
|
||||
if (sofia_private->home) {
|
||||
su_home_unref(sofia_private->home);
|
||||
}
|
||||
free(sofia_private);
|
||||
}
|
||||
|
||||
@@ -1391,6 +1394,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
private_object_t *tech_pvt = NULL;
|
||||
char *etmp = NULL, *exten = NULL;
|
||||
switch_channel_t *channel_a = NULL, *channel_b = NULL;
|
||||
su_home_t *home = NULL;
|
||||
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
channel_a = switch_core_session_get_channel(session);
|
||||
@@ -1427,10 +1431,9 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
if ((rep = strchr(refer_to->r_url->url_headers, '='))) {
|
||||
char *br_a = NULL, *br_b = NULL;
|
||||
char *buf;
|
||||
|
||||
rep++;
|
||||
|
||||
|
||||
|
||||
if ((buf = switch_core_session_alloc(session, strlen(rep) + 1))) {
|
||||
rep = url_unescape(buf, (const char *) rep);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Replaces: [%s]\n", rep);
|
||||
@@ -1438,7 +1441,11 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
|
||||
goto done;
|
||||
}
|
||||
if ((replaces = sip_replaces_make(tech_pvt->sofia_private->home, rep))
|
||||
|
||||
home = su_home_new(sizeof(*home));
|
||||
assert(home != NULL);
|
||||
|
||||
if ((replaces = sip_replaces_make(home, rep))
|
||||
&& (bnh = nua_handle_by_replaces(nua, replaces))) {
|
||||
sofia_private_t *b_private = NULL;
|
||||
private_object_t *b_tech_pvt = NULL;
|
||||
@@ -1612,6 +1619,11 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
}
|
||||
|
||||
done:
|
||||
if (home) {
|
||||
su_home_unref(home);
|
||||
home = NULL;
|
||||
}
|
||||
|
||||
if (exten && strchr(exten, '@')) {
|
||||
switch_safe_free(exten);
|
||||
}
|
||||
@@ -1704,7 +1716,7 @@ const char *_url_set_chanvars(switch_core_session_t *session, url_t *url, const
|
||||
} else {
|
||||
uri = switch_core_session_sprintf(session, "%s:%s", host, port);
|
||||
}
|
||||
switch_channel_set_variable_nodup(channel, uri_var, uri);
|
||||
switch_channel_set_variable(channel, uri_var, uri);
|
||||
switch_channel_set_variable(channel, host_var, host);
|
||||
}
|
||||
|
||||
@@ -2024,8 +2036,10 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
abort();
|
||||
}
|
||||
memset(tech_pvt->sofia_private, 0, sizeof(*tech_pvt->sofia_private));
|
||||
tech_pvt->sofia_private->home = su_home_new(sizeof(*tech_pvt->sofia_private->home));
|
||||
sofia_presence_set_chat_hash(tech_pvt, sip);
|
||||
|
||||
if ((profile->pflags & PFLAG_PRESENCE)) {
|
||||
sofia_presence_set_chat_hash(tech_pvt, sip);
|
||||
}
|
||||
switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
|
||||
nua_handle_bind(nh, tech_pvt->sofia_private);
|
||||
tech_pvt->nh = nh;
|
||||
|
||||
@@ -441,10 +441,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
char *e_dest = NULL;
|
||||
const char *holdstr = "";
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
switch_hash_index_t *hi;
|
||||
void *vval;
|
||||
switch_event_header_t *hi;
|
||||
char *extra_headers = NULL;
|
||||
const void *vvar;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
char *rep;
|
||||
|
||||
@@ -541,7 +539,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
}
|
||||
memset(tech_pvt->sofia_private, 0, sizeof(*tech_pvt->sofia_private));
|
||||
|
||||
tech_pvt->sofia_private->home = su_home_new(sizeof(*tech_pvt->sofia_private->home));
|
||||
switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
|
||||
nua_handle_bind(tech_pvt->nh, tech_pvt->sofia_private);
|
||||
|
||||
@@ -575,17 +572,15 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
if ((hi = switch_channel_variable_first(channel))) {
|
||||
for (; hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &vvar, NULL, &vval);
|
||||
if (vvar && vval) {
|
||||
const char *name = vvar;
|
||||
char *value = (char *) vval;
|
||||
|
||||
if (!strncasecmp(name, SOFIA_SIP_HEADER_PREFIX, strlen(SOFIA_SIP_HEADER_PREFIX))) {
|
||||
const char *hname = name + strlen(SOFIA_SIP_HEADER_PREFIX);
|
||||
stream.write_function(&stream, "%s: %s\r\n", hname, value);
|
||||
}
|
||||
for (; hi; hi = hi = hi->next) {
|
||||
const char *name = (char *) hi->name;
|
||||
char *value = (char *) hi->value;
|
||||
|
||||
if (!strncasecmp(name, SOFIA_SIP_HEADER_PREFIX, strlen(SOFIA_SIP_HEADER_PREFIX))) {
|
||||
const char *hname = name + strlen(SOFIA_SIP_HEADER_PREFIX);
|
||||
stream.write_function(&stream, "%s: %s\r\n", hname, value);
|
||||
}
|
||||
|
||||
}
|
||||
switch_channel_variable_last(channel);
|
||||
}
|
||||
@@ -1532,31 +1527,14 @@ switch_status_t sofia_glue_add_profile(char *key, sofia_profile_t *profile)
|
||||
|
||||
void sofia_glue_del_profile(sofia_profile_t *profile)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
void *vval;
|
||||
const void *vvar;
|
||||
sofia_profile_t *this_profile;
|
||||
sofia_gateway_t *gp, *this_gateway;
|
||||
|
||||
sofia_gateway_t *gp;
|
||||
|
||||
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, &vval);
|
||||
this_profile = (sofia_profile_t *) vval;
|
||||
if (this_profile == profile) {
|
||||
switch_core_hash_delete(mod_sofia_globals.profile_hash, vvar);
|
||||
}
|
||||
switch_core_hash_delete(mod_sofia_globals.profile_hash, profile->name);
|
||||
for (gp = profile->gateways; gp; gp = gp->next) {
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, gp->name);
|
||||
}
|
||||
for (hi = switch_hash_first(NULL, mod_sofia_globals.gateway_hash); hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &vvar, NULL, &vval);
|
||||
this_gateway = (sofia_gateway_t *) vval;
|
||||
|
||||
for (gp = profile->gateways; gp; gp = gp->next) {
|
||||
if (gp == this_gateway) {
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, vvar);
|
||||
}
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
|
||||
}
|
||||
|
||||
@@ -1051,15 +1051,20 @@ void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip)
|
||||
{
|
||||
char hash_key[256] = "";
|
||||
char buf[512];
|
||||
su_home_t *home = NULL;
|
||||
|
||||
if (tech_pvt->hash_key || !sip || !sip->sip_from || !sip->sip_from->a_url || !sip->sip_from->a_url->url_user || !sip->sip_from->a_url->url_host) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sofia_reg_find_reg_url(tech_pvt->profile, sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host, buf, sizeof(buf))) {
|
||||
tech_pvt->chat_from = sip_header_as_string(tech_pvt->sofia_private->home, (const sip_header_t *) sip->sip_to);
|
||||
home = su_home_new(sizeof(*home));
|
||||
assert(home != NULL);
|
||||
tech_pvt->chat_from = sip_header_as_string(home, (const sip_header_t *) sip->sip_to);
|
||||
tech_pvt->chat_to = switch_core_session_strdup(tech_pvt->session, buf);
|
||||
sofia_presence_set_hash_key(hash_key, sizeof(hash_key), sip);
|
||||
su_home_unref(home);
|
||||
home = NULL;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,9 @@
|
||||
#endif
|
||||
|
||||
//#define DOTRACE
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_wanpipe_shutdown)
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_wanpipe_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_wanpipe, mod_wanpipe_load, NULL, NULL);
|
||||
SWITCH_MODULE_DEFINITION(mod_wanpipe, mod_wanpipe_load, mod_wanpipe_shutdown, NULL);
|
||||
|
||||
#define STRLEN 15
|
||||
|
||||
@@ -1360,6 +1361,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_wanpipe_load)
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_wanpipe_shutdown)
|
||||
{
|
||||
switch_core_hash_destroy(&globals.call_hash);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*event Handlers */
|
||||
|
||||
static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *pevent)
|
||||
|
||||
@@ -244,6 +244,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_event_multicast_shutdown)
|
||||
x++;
|
||||
switch_yield(1000);
|
||||
}
|
||||
switch_core_hash_destroy(&globals.event_hash);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -510,6 +510,7 @@ struct api_command_struct {
|
||||
listener_t *listener;
|
||||
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
uint8_t bg;
|
||||
switch_memory_pool_t *pool;
|
||||
};
|
||||
|
||||
static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t * thread, void *obj)
|
||||
@@ -520,7 +521,7 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t * thread, void *obj)
|
||||
char *reply, *freply = NULL;
|
||||
switch_status_t status;
|
||||
|
||||
if (switch_thread_rwlock_tryrdlock(acs->listener->rwlock) != SWITCH_STATUS_SUCCESS) {
|
||||
if (!acs->listener || !acs->listener->rwlock || switch_thread_rwlock_tryrdlock(acs->listener->rwlock) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error! cannot get read lock.\n");
|
||||
goto done;
|
||||
}
|
||||
@@ -560,18 +561,16 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t * thread, void *obj)
|
||||
switch_safe_free(stream.data);
|
||||
switch_safe_free(freply);
|
||||
|
||||
switch_thread_rwlock_unlock(acs->listener->rwlock);
|
||||
|
||||
if (acs->listener->rwlock) {
|
||||
switch_thread_rwlock_unlock(acs->listener->rwlock);
|
||||
}
|
||||
|
||||
done:
|
||||
if (acs && acs->bg) {
|
||||
if (acs->api_cmd) {
|
||||
free(acs->api_cmd);
|
||||
}
|
||||
if (acs->arg) {
|
||||
free(acs->arg);
|
||||
}
|
||||
free(acs);
|
||||
switch_memory_pool_t *pool = acs->pool;
|
||||
acs = NULL;
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
pool = NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -758,45 +757,45 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else if (!strncasecmp(cmd, "bgapi ", 6)) {
|
||||
struct api_command_struct *acs;
|
||||
struct api_command_struct *acs = NULL;
|
||||
char *api_cmd = cmd + 6;
|
||||
char *arg = NULL;
|
||||
char *uuid_str = NULL;
|
||||
switch_memory_pool_t *pool;
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
switch_uuid_t uuid;
|
||||
|
||||
strip_cr(api_cmd);
|
||||
|
||||
if ((arg = strchr(api_cmd, ' '))) {
|
||||
*arg++ = '\0';
|
||||
}
|
||||
|
||||
if ((acs = malloc(sizeof(*acs)))) {
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
switch_uuid_t uuid;
|
||||
|
||||
memset(acs, 0, sizeof(*acs));
|
||||
acs->listener = listener;
|
||||
if (api_cmd) {
|
||||
acs->api_cmd = strdup(api_cmd);
|
||||
}
|
||||
if (arg) {
|
||||
acs->arg = strdup(arg);
|
||||
}
|
||||
acs->bg = 1;
|
||||
switch_threadattr_create(&thd_attr, listener->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_create(&thread, thd_attr, api_exec, acs, listener->pool);
|
||||
if ((uuid_str = switch_event_get_header(event, "job-uuid"))) {
|
||||
switch_copy_string(acs->uuid_str, uuid_str, sizeof(acs->uuid_str));
|
||||
} else {
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(acs->uuid_str, &uuid);
|
||||
}
|
||||
snprintf(reply, reply_len, "+OK Job-UUID: %s", acs->uuid_str);
|
||||
} else {
|
||||
snprintf(reply, reply_len, "-ERR memory error!");
|
||||
switch_core_new_memory_pool(&pool);
|
||||
acs = switch_core_alloc(pool, sizeof(*acs));
|
||||
assert(acs);
|
||||
acs->pool = pool;
|
||||
acs->listener = listener;
|
||||
if (api_cmd) {
|
||||
acs->api_cmd = switch_core_strdup(acs->pool, api_cmd);
|
||||
}
|
||||
|
||||
if (arg) {
|
||||
acs->arg = switch_core_strdup(acs->pool, arg);
|
||||
}
|
||||
acs->bg = 1;
|
||||
switch_threadattr_create(&thd_attr, acs->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_create(&thread, thd_attr, api_exec, acs, acs->pool);
|
||||
if ((uuid_str = switch_event_get_header(event, "job-uuid"))) {
|
||||
switch_copy_string(acs->uuid_str, uuid_str, sizeof(acs->uuid_str));
|
||||
} else {
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(acs->uuid_str, &uuid);
|
||||
}
|
||||
snprintf(reply, reply_len, "+OK Job-UUID: %s", acs->uuid_str);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else if (!strncasecmp(cmd, "log", 3)) {
|
||||
|
||||
@@ -861,7 +860,7 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
||||
}
|
||||
|
||||
if (custom) {
|
||||
switch_core_hash_insert_dup(listener->event_hash, cur, MARKER);
|
||||
switch_core_hash_insert(listener->event_hash, cur, MARKER);
|
||||
} else if (switch_name_event(cur, &type) == SWITCH_STATUS_SUCCESS) {
|
||||
key_count++;
|
||||
if (type == SWITCH_EVENT_ALL) {
|
||||
@@ -957,6 +956,7 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
||||
listener->event_list[x] = 0;
|
||||
}
|
||||
/* wipe the hash */
|
||||
switch_core_hash_destroy(&listener->event_hash);
|
||||
switch_core_hash_init(&listener->event_hash, listener->pool);
|
||||
snprintf(reply, reply_len, "+OK no longer listening for events");
|
||||
} else {
|
||||
@@ -1105,14 +1105,15 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t * thread, void *obj
|
||||
done:
|
||||
|
||||
remove_listener(listener);
|
||||
close_socket(&listener->sock);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session complete, waiting for children\n");
|
||||
|
||||
switch_thread_rwlock_wrlock(listener->rwlock);
|
||||
switch_thread_rwlock_unlock(listener->rwlock);
|
||||
close_socket(&listener->sock);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Closed\n");
|
||||
switch_core_hash_destroy(&listener->event_hash);
|
||||
|
||||
if (session) {
|
||||
switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED);
|
||||
|
||||
@@ -365,6 +365,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_local_stream_shutdown)
|
||||
{
|
||||
RUNNING = 0;
|
||||
switch_yield(500000);
|
||||
switch_core_hash_destroy(&globals.source_hash);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
#include <sndfile.h>
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_sndfile_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_sndfile, mod_sndfile_load, NULL, NULL);
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sndfile_shutdown);
|
||||
SWITCH_MODULE_DEFINITION(mod_sndfile, mod_sndfile_load, mod_sndfile_shutdown, NULL);
|
||||
|
||||
static switch_memory_pool_t *module_pool = NULL;
|
||||
|
||||
@@ -370,6 +371,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sndfile_load)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sndfile_shutdown)
|
||||
{
|
||||
switch_core_hash_destroy(&globals.format_hash);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -168,6 +168,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_mono_shutdown)
|
||||
globals.domain = NULL;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deallocated mono runtime.\n");
|
||||
}
|
||||
switch_core_hash_destroy(&globals.plugins);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -3293,6 +3293,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load)
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
switch_core_hash_destroy(&module_manager.mod_hash);
|
||||
switch_core_hash_destroy(&module_manager.load_hash);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,12 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_console_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_console, mod_console_load, NULL, NULL);
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_console_shutdown);
|
||||
SWITCH_MODULE_DEFINITION(mod_console, mod_console_load, mod_console_shutdown, NULL);
|
||||
|
||||
static const uint8_t STATIC_LEVELS[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
static int RUNNING = 0;
|
||||
|
||||
static int COLORIZE = 0;
|
||||
#ifdef WIN32
|
||||
static HANDLE hStdout;
|
||||
@@ -98,6 +101,12 @@ static switch_status_t config_logger(void)
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
if (log_hash) {
|
||||
switch_core_hash_destroy(&log_hash);
|
||||
}
|
||||
if (name_hash) {
|
||||
switch_core_hash_destroy(&name_hash);
|
||||
}
|
||||
switch_core_hash_init(&log_hash, module_pool);
|
||||
switch_core_hash_init(&name_hash, module_pool);
|
||||
|
||||
@@ -137,7 +146,11 @@ static switch_status_t config_logger(void)
|
||||
static switch_status_t switch_console_logger(const switch_log_node_t *node, switch_log_level_t level)
|
||||
{
|
||||
FILE *handle;
|
||||
|
||||
/*
|
||||
if (!RUNNING) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
*/
|
||||
if ((handle = switch_core_data_channel(SWITCH_CHANNEL_ID_LOG))) {
|
||||
uint8_t *lookup = NULL;
|
||||
switch_log_level_t level = SWITCH_LOG_DEBUG;
|
||||
@@ -188,11 +201,19 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_console_load)
|
||||
switch_log_bind_logger(switch_console_logger, SWITCH_LOG_DEBUG);
|
||||
|
||||
config_logger();
|
||||
|
||||
RUNNING = 1;
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_console_shutdown)
|
||||
{
|
||||
//switch_core_hash_destroy(&log_hash);
|
||||
//switch_core_hash_destroy(&name_hash);
|
||||
RUNNING = 0;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
Reference in New Issue
Block a user