diff --git a/src/curl.cpp b/src/curl.cpp index d977f2f..22014b7 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -155,6 +155,21 @@ int destroy_curl_handles_mutex(void) return pthread_mutex_destroy(&curl_handles_lock); } +bool init_curl_global_all(void) +{ + if(CURLE_OK != curl_global_init(CURL_GLOBAL_ALL)){ + FGPRINT("init_curl_global_all returns error.\n"); + SYSLOGERR("init_curl_global_all returns error."); + return false; + } + return true; +} + +void cleanup_curl_global_all(void) +{ + curl_global_cleanup(); +} + static void lock_curl_share(CURL* handle, curl_lock_data nLockData, curl_lock_access laccess, void* useptr) { if(hCurlShare && CURL_LOCK_DATA_DNS == nLockData){ diff --git a/src/curl.h b/src/curl.h index cfa7a05..12c1301 100644 --- a/src/curl.h +++ b/src/curl.h @@ -115,6 +115,8 @@ class auto_head { // int init_curl_handles_mutex(void); int destroy_curl_handles_mutex(void); +bool init_curl_global_all(void); +void cleanup_curl_global_all(void); int init_curl_share(bool isCache); int destroy_curl_share(bool isCache); void my_set_curl_share(CURL* curl); diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 4003f2f..860feb1 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -4471,9 +4471,15 @@ int main(int argc, char *argv[]) { // exists. skip check if mounting a public bucket if(public_bucket.substr(0,1) != "1"){ int result; + // Initiate curl global for ssl. + if(!init_curl_global_all()){ + exit(EXIT_FAILURE); + } if(EXIT_SUCCESS != (result = s3fs_check_service())){ + cleanup_curl_global_all(); exit(result); } + cleanup_curl_global_all(); } if (utility_mode) { @@ -4515,9 +4521,15 @@ int main(int argc, char *argv[]) { s3fs_oper.access = s3fs_access; s3fs_oper.create = s3fs_create; + // Re-Initiate curl global for ssl before calling fuse. + if(!init_curl_global_all()){ + exit(EXIT_FAILURE); + } + // now passing things off to fuse, fuse will finish evaluating the command line args fuse_res = fuse_main(custom_args.argc, custom_args.argv, &s3fs_oper, NULL); fuse_opt_free_args(&custom_args); + cleanup_curl_global_all(); exit(fuse_res); }