git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1445 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-05-12 15:33:49 +00:00
parent 1dfa2ce576
commit d314140374
5 changed files with 45 additions and 19 deletions

View File

@ -127,6 +127,13 @@ SWITCH_DECLARE(unsigned char) switch_char_to_rfc2833(char key);
*/
#define switch_copy_flags(dest, src, flags) (dest)->flags &= ~(flags); (dest)->flags |= ((src)->flags & (flags))
/*!
\brief Free a pointer and set it to NULL unles it already is NULL
\param it the pointer
*/
#define switch_safe_free(it) if (it) {free(it);it=NULL;}
/*!
\brief Test for NULL or zero length string
\param s the string to test

View File

@ -30,6 +30,8 @@
*
*/
#define MY_EVENT_REGISTER "exosip::register"
#define MY_EVENT_EXPIRE "exosip::expire"
@ -1361,6 +1363,10 @@ static switch_status_t exosip_create_call(eXosip_event_t * event)
}
}
switch_safe_free(dname);
switch_safe_free(drate);
switch_safe_free(dpayload);
if (activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
exosip_on_hangup(session);
switch_core_session_destroy(&session);
@ -1493,10 +1499,8 @@ static void handle_message_new(eXosip_event_t *je)
if (osip_message_get_contact(je->request, x++, &contact) < 0) {
break;
}
if (lame) {
free(lame);
lame = NULL;
}
switch_safe_free(lame);
osip_contact_to_str((const osip_contact_t *) contact, &lame);
contact_uri = osip_contact_get_url(contact);
@ -1544,11 +1548,8 @@ static void handle_message_new(eXosip_event_t *je)
}
}
} else {
/* Unimplemented */
}
switch_safe_free(lame);
}
}
@ -1650,9 +1651,9 @@ static void handle_answer(eXosip_event_t * event)
eXosip_call_send_ack(event->did, ack);
eXosip_unlock();
free(dname);
free(drate);
free(dpayload);
switch_safe_free(dname);
switch_safe_free(drate);
switch_safe_free(dpayload);
if (activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
@ -2018,8 +2019,6 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
break;
case EXOSIP_CALL_INVITE:
if (exosip_create_call(event) != SWITCH_STATUS_SUCCESS) {
destroy_call_by_event(event);
}
break;

View File

@ -661,11 +661,18 @@ static JSBool session_hangup(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
{
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
char *cause_name = NULL;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
if (argc > 1) {
cause_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
cause = switch_channel_str2cause(cause_name);
}
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
switch_channel_hangup(channel, cause);
switch_core_session_kill_channel(jss->session, SWITCH_SIG_KILL);
return JS_TRUE;
}
@ -747,7 +754,7 @@ static JSBool js_fetchurl_hash(JSContext *cx, JSObject *obj, uintN argc, jsval *
url = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
if (!strncasecmp(url, "https", 5)) {
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
@ -2206,6 +2213,14 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &spidermonkey_module_interface;
curl_global_init(CURL_GLOBAL_ALL);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
{
curl_global_cleanup();
return SWITCH_STATUS_SUCCESS;
}

View File

@ -77,13 +77,12 @@ static switch_xml_t xml_url_fetch(char *section,
char url[1024] = "", filename[1024] = "";
CURL *curl_handle = NULL;
struct config_data config_data;
switch_xml_t xml;
switch_xml_t xml = NULL;
snprintf(url, sizeof(url), "%s?section=%s&tag_name=%s&key_name=%s&key_value=%s%s%s\n",
globals.url, section, tag_name, key_name, key_value, params ? "&" : "", params ? params : "");
srand((unsigned int)(time(NULL) + strlen(url)));
snprintf(filename, sizeof(filename), "%s%04x.tmp", SWITCH_GLOBAL_dirs.temp_dir, (rand() & 0xffff));
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
if (!strncasecmp(url, "https", 5)) {
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
@ -172,6 +171,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
switch_xml_bind_search_function(xml_url_fetch);
}
curl_global_init(CURL_GLOBAL_ALL);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
@ -306,6 +307,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
{
globals.running = 0;
curl_global_cleanup();
return SWITCH_STATUS_SUCCESS;
}

View File

@ -2535,7 +2535,9 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
switch_time_t last_commit = switch_time_now();
uint32_t freq = 1000, target = 500, diff = 0;
runtime.event_db = switch_core_db_handle();
if (!runtime.event_db) {
runtime.event_db = switch_core_db_handle();
}
switch_queue_create(&runtime.sql_queue, SWITCH_SQL_QUEUE_LEN, runtime.memory_pool);
for(;;) {
@ -2880,6 +2882,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
switch_yield(1000);
}
switch_core_db_close(runtime.db);
switch_core_db_close(runtime.event_db);
switch_xml_destroy();
if (runtime.memory_pool) {