diff --git a/src/mod/applications/mod_cidlookup/mod_cidlookup.c b/src/mod/applications/mod_cidlookup/mod_cidlookup.c index ba69f6fb6b..19364429ba 100755 --- a/src/mod/applications/mod_cidlookup/mod_cidlookup.c +++ b/src/mod/applications/mod_cidlookup/mod_cidlookup.c @@ -30,7 +30,7 @@ */ #include -#include +#include #define SWITCH_REWIND_STREAM(s) s.end = s.data @@ -839,6 +839,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load) return SWITCH_STATUS_TERM; } + switch_curl_init(); + SWITCH_ADD_API(api_interface, "cidlookup", "cidlookup API", cidlookup_function, SYNTAX); SWITCH_ADD_APP(app_interface, "cidlookup", "Perform a CID lookup", "Perform a CID lookup", cidlookup_app_function, "[number [skipurl]]", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); @@ -852,7 +854,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load) Macro expands to: switch_status_t mod_cidlookup_shutdown() */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cidlookup_shutdown) { - + switch_curl_destroy(); switch_event_unbind(&reload_xml_event); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_curl/mod_curl.c b/src/mod/applications/mod_curl/mod_curl.c index adcfe453de..e8e5e6f400 100644 --- a/src/mod/applications/mod_curl/mod_curl.c +++ b/src/mod/applications/mod_curl/mod_curl.c @@ -30,7 +30,7 @@ */ #include -#include +#include #include /* Prototypes */ @@ -412,6 +412,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load) globals.pool = pool; + switch_curl_init(); + SWITCH_ADD_API(api_interface, "curl", "curl API", curl_function, SYNTAX); SWITCH_ADD_APP(app_interface, "curl", "Perform a http request", "Perform a http request", curl_app_function, SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); @@ -426,7 +428,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_curl_shutdown) { /* Cleanup dynamically allocated config settings */ - + switch_curl_destroy(); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_http_cache/mod_http_cache.c b/src/mod/applications/mod_http_cache/mod_http_cache.c index 99bd9ca6e8..5ac7251023 100644 --- a/src/mod/applications/mod_http_cache/mod_http_cache.c +++ b/src/mod/applications/mod_http_cache/mod_http_cache.c @@ -30,7 +30,7 @@ * */ #include -#include +#include /* Defines module interface to FreeSWITCH */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_http_cache_shutdown); @@ -205,6 +205,7 @@ static switch_status_t http_put(switch_core_session_t *session, const char *url, } curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1); curl_easy_setopt(curl_handle, CURLOPT_PUT, 1); + curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl_handle, CURLOPT_URL, url); curl_easy_setopt(curl_handle, CURLOPT_READDATA, file_to_put); curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); @@ -1011,7 +1012,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_http_cache_load) setup_dir(&gcache); /* init CURL */ - curl_global_init(CURL_GLOBAL_ALL); + switch_curl_init(); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; @@ -1022,6 +1023,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_http_cache_load) */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_http_cache_shutdown) { + switch_curl_destroy(); url_cache_clear(&gcache, NULL); switch_core_hash_destroy(&gcache.map); switch_mutex_destroy(gcache.mutex); diff --git a/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c b/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c index 0600607e3a..9cdecfca1b 100644 --- a/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c +++ b/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c @@ -32,7 +32,7 @@ */ #include #include -#include +#include #include #define MAX_URLS 20 @@ -724,6 +724,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle, CURLOPT_POST, 1); + curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, curl_json_text); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-json/1.0"); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, httpCallBack); @@ -1040,6 +1041,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_json_cdr_load) globals.retries++; + switch_curl_init(); set_json_cdr_log_dirs(); switch_xml_free(xml); @@ -1052,6 +1054,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_json_cdr_shutdown) globals.shutdown = 1; + switch_curl_destroy(); switch_safe_free(globals.log_dir); for (;err_dir_index < globals.err_dir_count; err_dir_index++) { diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index a09cfdf02a..825273c1aa 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -2520,6 +2520,7 @@ static JSBool js_fetchurl_hash(JSContext * cx, JSObject * obj, uintN argc, jsval } curl_easy_setopt(curl_handle, CURLOPT_URL, url); curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, hash_callback); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &config_data); diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c index c2e64ee0aa..42402e1368 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c @@ -183,6 +183,7 @@ static JSBool curl_run(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, method, url_p, data, switch_str_nil(cred), co->function ? "yes" : "no"); curl_easy_setopt(co->curl_handle, CURLOPT_URL, url_p); + curl_easy_setopt(co->curl_handle, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(co->curl_handle, CURLOPT_WRITEFUNCTION, file_callback); curl_easy_setopt(co->curl_handle, CURLOPT_WRITEDATA, (void *) co); diff --git a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c index 7cfd3592bb..59e8ec6427 100644 --- a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c +++ b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c @@ -297,6 +297,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle, CURLOPT_POST, 1); + curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, curl_xml_text); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-xml/1.0"); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, httpCallBack); diff --git a/src/switch_core.c b/src/switch_core.c index 8a97de13a9..0f3bc36455 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1377,6 +1377,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc memset(&runtime, 0, sizeof(runtime)); gethostname(runtime.hostname, sizeof(runtime.hostname)); + switch_ssl_init_ssl_locks(); + runtime.max_db_handles = 50; runtime.db_handle_timeout = 5000000;; @@ -1512,7 +1514,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc switch_uuid_get(&uuid); switch_uuid_format(runtime.uuid_str, &uuid); - switch_ssl_init_ssl_locks(); + return SWITCH_STATUS_SUCCESS; }