*/
#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
*
*/
+
+
#define MY_EVENT_REGISTER "exosip::register"
#define MY_EVENT_EXPIRE "exosip::expire"
}
}
+ 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);
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);
}
}
-
- } else {
- /* Unimplemented */
- }
-
+ switch_safe_free(lame);
+ }
}
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) {
break;
case EXOSIP_CALL_INVITE:
if (exosip_create_call(event) != SWITCH_STATUS_SUCCESS) {
-
-
destroy_call_by_event(event);
}
break;
{
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;
}
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);
/* 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;
+}
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);
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;
}
SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
{
globals.running = 0;
+ curl_global_cleanup();
return SWITCH_STATUS_SUCCESS;
}
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(;;) {
switch_yield(1000);
}
switch_core_db_close(runtime.db);
+ switch_core_db_close(runtime.event_db);
switch_xml_destroy();
if (runtime.memory_pool) {