[Freeswitch-branches] [commit] r4937 - in freeswitch/branches/mikej/sofiasip-upgrade/src/mod: applications/mod_commands endpoints/mod_sofia endpoints/mod_wanpipe event_handlers/mod_cdr xml_int/mod_xml_curl
Freeswitch SVN
mikej at freeswitch.org
Sat Apr 14 21:33:25 EDT 2007
Author: mikej
Date: Sat Apr 14 21:33:25 2007
New Revision: 4937
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c
Log:
merged changes from trunk revisions 4927-4936.
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c Sat Apr 14 21:33:25 2007
@@ -844,7 +844,7 @@
}
snprintf(id, sizeof(id), "%d", holder->rows);
- switch_xml_set_attr_d(row, "id", id);
+ switch_xml_set_attr_d(row, "row_id", id);
for(x = 0; x < argc; x++) {
if ((field = switch_xml_add_child_d(row, columnNames[x], f_off++))) {
@@ -990,15 +990,20 @@
} else if (!strcasecmp(as, "xml")) {
switch_core_db_exec(db, sql, show_as_xml_callback, &holder, &errmsg);
if (holder.xml) {
- char *xmlstr = switch_xml_toxml(holder.xml);
+ char count[50];
+ char *xmlstr;
+ snprintf(count, sizeof(count), "%d", holder.count);
+ switch_xml_set_attr_d(holder.xml, "row_count", count);
+ xmlstr = switch_xml_toxml(holder.xml);
+
if (xmlstr) {
holder.stream->write_function(holder.stream, "%s", xmlstr);
free(xmlstr);
} else {
- holder.stream->write_function(holder.stream, "ERROR\n");
+ holder.stream->write_function(holder.stream, "<result row_count=\"0\"/>\n");
}
} else {
- holder.stream->write_function(holder.stream, "ERROR\n");
+ holder.stream->write_function(holder.stream, "<result row_count=\"0\"/>\n");
}
} else {
holder.stream->write_function(holder.stream, "Cannot find format %s\n", as);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c Sat Apr 14 21:33:25 2007
@@ -1002,8 +1002,13 @@
switch_core_hash_init(&mod_sofia_globals.gateway_hash, module_pool);
switch_mutex_init(&mod_sofia_globals.hash_mutex, SWITCH_MUTEX_NESTED, module_pool);
- config_sofia(0);
+ if (config_sofia(0) != SWITCH_STATUS_SUCCESS) {
+ return SWITCH_STATUS_GENERR;
+ }
+ switch_mutex_lock(mod_sofia_globals.mutex);
+ mod_sofia_globals.running = 1;
+ switch_mutex_unlock(mod_sofia_globals.mutex);
if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL)
!= SWITCH_STATUS_SUCCESS) {
@@ -1045,17 +1050,21 @@
SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
{
-
+ int sanity = 0;
+
sofia_presence_cancel();
switch_mutex_lock(mod_sofia_globals.mutex);
if (mod_sofia_globals.running == 1) {
- mod_sofia_globals.running = -1;
+ mod_sofia_globals.running = 0;
}
switch_mutex_unlock(mod_sofia_globals.mutex);
- while (mod_sofia_globals.running) {
+ while (mod_sofia_globals.threads) {
switch_yield(1000);
+ if (++sanity >= 5000) {
+ break;
+ }
}
su_deinit();
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.h Sat Apr 14 21:33:25 2007
@@ -146,6 +146,7 @@
switch_mutex_t *hash_mutex;
uint32_t callid;
int32_t running;
+ int32_t threads;
switch_mutex_t *mutex;
char guess_ip[80];
};
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia.c Sat Apr 14 21:33:25 2007
@@ -240,6 +240,10 @@
uint32_t gateway_loops = 0;
switch_event_t *s_event;
+ switch_mutex_lock(mod_sofia_globals.mutex);
+ mod_sofia_globals.threads++;
+ switch_mutex_unlock(mod_sofia_globals.mutex);
+
profile->s_root = su_root_create(NULL);
profile->home = su_home_new(sizeof(*profile->home));
@@ -287,7 +291,7 @@
if (!sofia_glue_init_sql(profile)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database!\n");
- return NULL;
+ goto end;
}
@@ -350,8 +354,11 @@
su_root_destroy(profile->s_root);
pool = profile->pool;
switch_core_destroy_memory_pool(&pool);
+
+ end:
+
switch_mutex_lock(mod_sofia_globals.mutex);
- mod_sofia_globals.running = 0;
+ mod_sofia_globals.threads--;
switch_mutex_unlock(mod_sofia_globals.mutex);
return NULL;
@@ -402,9 +409,7 @@
switch_status_t status = SWITCH_STATUS_SUCCESS;
sofia_profile_t *profile = NULL;
char url[512] = "";
- switch_mutex_lock(mod_sofia_globals.mutex);
- mod_sofia_globals.running = 1;
- switch_mutex_unlock(mod_sofia_globals.mutex);
+
if (!reload) {
su_init();
@@ -937,7 +942,7 @@
switch_core_session_thread_launch(session);
goto done;
} else {
- sdp_parser_t *parser = sdp_parse(tech_pvt->sofia_private->home, r_sdp, (int) strlen(r_sdp), 0);
+ sdp_parser_t *parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0);
sdp_session_t *sdp;
uint8_t match = 0;
@@ -1018,7 +1023,7 @@
if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
goto done;
} else {
- sdp_parser_t *parser = sdp_parse(tech_pvt->sofia_private->home, r_sdp, (int) strlen(r_sdp), 0);
+ sdp_parser_t *parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0);
sdp_session_t *sdp;
uint8_t match = 0;
@@ -1086,7 +1091,7 @@
}
goto done;
} else {
- sdp_parser_t *parser = sdp_parse(tech_pvt->sofia_private->home, r_sdp, (int) strlen(r_sdp), 0);
+ sdp_parser_t *parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0);
sdp_session_t *sdp;
uint8_t match = 0;
@@ -1648,7 +1653,7 @@
sofia_glue_sofia_glue_tech_set_codecs(tech_pvt);
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "INBOUND CALL");
- sofia_presence_set_chat_hash(tech_pvt, sip);
+
if (switch_test_flag(tech_pvt, TFLAG_INB_NOMEDIA)) {
switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
@@ -1734,7 +1739,7 @@
}
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);
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;
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/sofia_glue.c Sat Apr 14 21:33:25 2007
@@ -543,7 +543,7 @@
sdp_media_t *m;
sdp_connection_t *connection;
- if ((parser = sdp_parse(tech_pvt->sofia_private->home, sdp_str, (int) strlen(sdp_str), 0))) {
+ if ((parser = sdp_parse(NULL, sdp_str, (int) strlen(sdp_str), 0))) {
if ((sdp = sdp_session(parser))) {
for (m = sdp->sdp_media; m; m = m->m_next) {
if (m->m_type != sdp_media_audio) {
@@ -774,7 +774,7 @@
switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, char *r_sdp)
{
- sdp_parser_t *parser = sdp_parse(tech_pvt->sofia_private->home, r_sdp, (int) strlen(r_sdp), 0);
+ sdp_parser_t *parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0);
sdp_session_t *sdp;
uint8_t match = 0;
switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c Sat Apr 14 21:33:25 2007
@@ -876,6 +876,10 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
+ if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->wpsock->fd < 0) {
+ return SWITCH_STATUS_GENERR;
+ }
+
if (!tech_pvt->dtmf_buffer) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocate DTMF Buffer....");
if (switch_buffer_create_dynamic(&tech_pvt->dtmf_buffer, 1024, 3192, 0) != SWITCH_STATUS_SUCCESS) {
@@ -907,6 +911,9 @@
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
assert(tech_pvt != NULL);
+ if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->wpsock->fd < 0) {
+ return SWITCH_STATUS_GENERR;
+ }
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_NOMEDIA:
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp Sat Apr 14 21:33:25 2007
@@ -245,7 +245,10 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot connect to MySQL Server. The error was: %s\n", error1);
}
else
+ {
connectionstate = 1;
+ conn->reconnect = false;
+ }
mysql_autocommit(conn,0);
stmt = mysql_stmt_init(conn);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c Sat Apr 14 21:33:25 2007
@@ -104,7 +104,7 @@
}
config_data.name = filename;
- if ((config_data.fd = open(filename, O_CREAT | O_RDWR | O_TRUNC)) > -1) {
+ if ((config_data.fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
if (!switch_strlen_zero(binding->cred)) {
curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_easy_setopt(curl_handle, CURLOPT_USERPWD, binding->cred);
More information about the Freeswitch-branches
mailing list