FS-2936 stage 1

This commit is contained in:
Anthony Minessale 2011-11-29 11:13:11 -06:00
parent f41020a625
commit e58ed35d17
8 changed files with 22 additions and 8 deletions

View File

@ -30,7 +30,7 @@
*/
#include <switch.h>
#include <curl/curl.h>
#include <switch_curl.h>
#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;
}

View File

@ -30,7 +30,7 @@
*/
#include <switch.h>
#include <curl/curl.h>
#include <switch_curl.h>
#include <json.h>
/* 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;
}

View File

@ -30,7 +30,7 @@
*
*/
#include <switch.h>
#include <curl/curl.h>
#include <switch_curl.h>
/* 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);

View File

@ -32,7 +32,7 @@
*/
#include <sys/stat.h>
#include <switch.h>
#include <curl/curl.h>
#include <switch_curl.h>
#include <json.h>
#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++) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}