提交 e58ed35d authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-2936 stage 1

上级 f41020a6
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
*/ */
#include <switch.h> #include <switch.h>
#include <curl/curl.h> #include <switch_curl.h>
#define SWITCH_REWIND_STREAM(s) s.end = s.data #define SWITCH_REWIND_STREAM(s) s.end = s.data
...@@ -839,6 +839,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load) ...@@ -839,6 +839,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load)
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
switch_curl_init();
SWITCH_ADD_API(api_interface, "cidlookup", "cidlookup API", cidlookup_function, SYNTAX); 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", 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); cidlookup_app_function, "[number [skipurl]]", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
...@@ -852,7 +854,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load) ...@@ -852,7 +854,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load)
Macro expands to: switch_status_t mod_cidlookup_shutdown() */ Macro expands to: switch_status_t mod_cidlookup_shutdown() */
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cidlookup_shutdown) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cidlookup_shutdown)
{ {
switch_curl_destroy();
switch_event_unbind(&reload_xml_event); switch_event_unbind(&reload_xml_event);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
*/ */
#include <switch.h> #include <switch.h>
#include <curl/curl.h> #include <switch_curl.h>
#include <json.h> #include <json.h>
/* Prototypes */ /* Prototypes */
...@@ -412,6 +412,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load) ...@@ -412,6 +412,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load)
globals.pool = pool; globals.pool = pool;
switch_curl_init();
SWITCH_ADD_API(api_interface, "curl", "curl API", curl_function, SYNTAX); 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", SWITCH_ADD_APP(app_interface, "curl", "Perform a http request", "Perform a http request",
curl_app_function, SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); curl_app_function, SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
...@@ -426,7 +428,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load) ...@@ -426,7 +428,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_curl_shutdown) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_curl_shutdown)
{ {
/* Cleanup dynamically allocated config settings */ /* Cleanup dynamically allocated config settings */
switch_curl_destroy();
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
*/ */
#include <switch.h> #include <switch.h>
#include <curl/curl.h> #include <switch_curl.h>
/* Defines module interface to FreeSWITCH */ /* Defines module interface to FreeSWITCH */
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_http_cache_shutdown); 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, ...@@ -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_UPLOAD, 1);
curl_easy_setopt(curl_handle, CURLOPT_PUT, 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_URL, url);
curl_easy_setopt(curl_handle, CURLOPT_READDATA, file_to_put); 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); 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) ...@@ -1011,7 +1012,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_http_cache_load)
setup_dir(&gcache); setup_dir(&gcache);
/* init CURL */ /* init CURL */
curl_global_init(CURL_GLOBAL_ALL); switch_curl_init();
/* 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;
...@@ -1022,6 +1023,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_http_cache_load) ...@@ -1022,6 +1023,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_http_cache_load)
*/ */
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_http_cache_shutdown) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_http_cache_shutdown)
{ {
switch_curl_destroy();
url_cache_clear(&gcache, NULL); url_cache_clear(&gcache, NULL);
switch_core_hash_destroy(&gcache.map); switch_core_hash_destroy(&gcache.map);
switch_mutex_destroy(gcache.mutex); switch_mutex_destroy(gcache.mutex);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
*/ */
#include <sys/stat.h> #include <sys/stat.h>
#include <switch.h> #include <switch.h>
#include <curl/curl.h> #include <switch_curl.h>
#include <json.h> #include <json.h>
#define MAX_URLS 20 #define MAX_URLS 20
...@@ -724,6 +724,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) ...@@ -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_HTTPHEADER, headers);
curl_easy_setopt(curl_handle, CURLOPT_POST, 1); 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_POSTFIELDS, curl_json_text);
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-json/1.0"); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-json/1.0");
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, httpCallBack); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, httpCallBack);
...@@ -1040,6 +1041,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_json_cdr_load) ...@@ -1040,6 +1041,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_json_cdr_load)
globals.retries++; globals.retries++;
switch_curl_init();
set_json_cdr_log_dirs(); set_json_cdr_log_dirs();
switch_xml_free(xml); switch_xml_free(xml);
...@@ -1052,6 +1054,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_json_cdr_shutdown) ...@@ -1052,6 +1054,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_json_cdr_shutdown)
globals.shutdown = 1; globals.shutdown = 1;
switch_curl_destroy();
switch_safe_free(globals.log_dir); switch_safe_free(globals.log_dir);
for (;err_dir_index < globals.err_dir_count; err_dir_index++) { for (;err_dir_index < globals.err_dir_count; err_dir_index++) {
......
...@@ -2520,6 +2520,7 @@ static JSBool js_fetchurl_hash(JSContext * cx, JSObject * obj, uintN argc, jsval ...@@ -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_URL, url);
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1); 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_MAXREDIRS, 10);
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, hash_callback); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, hash_callback);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &config_data); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &config_data);
......
...@@ -183,6 +183,7 @@ static JSBool curl_run(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, ...@@ -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"); 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_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_WRITEFUNCTION, file_callback);
curl_easy_setopt(co->curl_handle, CURLOPT_WRITEDATA, (void *) co); curl_easy_setopt(co->curl_handle, CURLOPT_WRITEDATA, (void *) co);
......
...@@ -297,6 +297,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session) ...@@ -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_HTTPHEADER, headers);
curl_easy_setopt(curl_handle, CURLOPT_POST, 1); 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_POSTFIELDS, curl_xml_text);
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-xml/1.0"); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-xml/1.0");
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, httpCallBack); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, httpCallBack);
......
...@@ -1377,6 +1377,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc ...@@ -1377,6 +1377,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
memset(&runtime, 0, sizeof(runtime)); memset(&runtime, 0, sizeof(runtime));
gethostname(runtime.hostname, sizeof(runtime.hostname)); gethostname(runtime.hostname, sizeof(runtime.hostname));
switch_ssl_init_ssl_locks();
runtime.max_db_handles = 50; runtime.max_db_handles = 50;
runtime.db_handle_timeout = 5000000;; runtime.db_handle_timeout = 5000000;;
...@@ -1512,7 +1514,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc ...@@ -1512,7 +1514,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
switch_uuid_get(&uuid); switch_uuid_get(&uuid);
switch_uuid_format(runtime.uuid_str, &uuid); switch_uuid_format(runtime.uuid_str, &uuid);
switch_ssl_init_ssl_locks();
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论