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)) #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 \brief Test for NULL or zero length string
\param s the string to test \param s the string to test

View File

@ -30,6 +30,8 @@
* *
*/ */
#define MY_EVENT_REGISTER "exosip::register" #define MY_EVENT_REGISTER "exosip::register"
#define MY_EVENT_EXPIRE "exosip::expire" #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) { if (activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
exosip_on_hangup(session); exosip_on_hangup(session);
switch_core_session_destroy(&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) { if (osip_message_get_contact(je->request, x++, &contact) < 0) {
break; break;
} }
if (lame) {
free(lame); switch_safe_free(lame);
lame = NULL;
}
osip_contact_to_str((const osip_contact_t *) contact, &lame); osip_contact_to_str((const osip_contact_t *) contact, &lame);
contact_uri = osip_contact_get_url(contact); contact_uri = osip_contact_get_url(contact);
@ -1544,11 +1548,8 @@ static void handle_message_new(eXosip_event_t *je)
} }
} }
switch_safe_free(lame);
} else {
/* Unimplemented */
} }
} }
@ -1650,9 +1651,9 @@ static void handle_answer(eXosip_event_t * event)
eXosip_call_send_ack(event->did, ack); eXosip_call_send_ack(event->did, ack);
eXosip_unlock(); eXosip_unlock();
free(dname); switch_safe_free(dname);
free(drate); switch_safe_free(drate);
free(dpayload); switch_safe_free(dpayload);
if (activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) { if (activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
@ -2018,8 +2019,6 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
break; break;
case EXOSIP_CALL_INVITE: case EXOSIP_CALL_INVITE:
if (exosip_create_call(event) != SWITCH_STATUS_SUCCESS) { if (exosip_create_call(event) != SWITCH_STATUS_SUCCESS) {
destroy_call_by_event(event); destroy_call_by_event(event);
} }
break; 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); struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel; 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); channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL); 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); switch_core_session_kill_channel(jss->session, SWITCH_SIG_KILL);
return JS_TRUE; 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])); url = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
name = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init(); curl_handle = curl_easy_init();
if (!strncasecmp(url, "https", 5)) { if (!strncasecmp(url, "https", 5)) {
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); 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 */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = &spidermonkey_module_interface; *module_interface = &spidermonkey_module_interface;
curl_global_init(CURL_GLOBAL_ALL);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; 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] = ""; char url[1024] = "", filename[1024] = "";
CURL *curl_handle = NULL; CURL *curl_handle = NULL;
struct config_data config_data; 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", 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 : ""); globals.url, section, tag_name, key_name, key_value, params ? "&" : "", params ? params : "");
srand((unsigned int)(time(NULL) + strlen(url))); srand((unsigned int)(time(NULL) + strlen(url)));
snprintf(filename, sizeof(filename), "%s%04x.tmp", SWITCH_GLOBAL_dirs.temp_dir, (rand() & 0xffff)); 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(); curl_handle = curl_easy_init();
if (!strncasecmp(url, "https", 5)) { if (!strncasecmp(url, "https", 5)) {
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); 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); switch_xml_bind_search_function(xml_url_fetch);
} }
curl_global_init(CURL_GLOBAL_ALL);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; 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) SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
{ {
globals.running = 0; globals.running = 0;
curl_global_cleanup();
return SWITCH_STATUS_SUCCESS; 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(); switch_time_t last_commit = switch_time_now();
uint32_t freq = 1000, target = 500, diff = 0; uint32_t freq = 1000, target = 500, diff = 0;
if (!runtime.event_db) {
runtime.event_db = switch_core_db_handle(); runtime.event_db = switch_core_db_handle();
}
switch_queue_create(&runtime.sql_queue, SWITCH_SQL_QUEUE_LEN, runtime.memory_pool); switch_queue_create(&runtime.sql_queue, SWITCH_SQL_QUEUE_LEN, runtime.memory_pool);
for(;;) { for(;;) {
@ -2880,6 +2882,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
switch_yield(1000); switch_yield(1000);
} }
switch_core_db_close(runtime.db); switch_core_db_close(runtime.db);
switch_core_db_close(runtime.event_db);
switch_xml_destroy(); switch_xml_destroy();
if (runtime.memory_pool) { if (runtime.memory_pool) {