Migrate to openssl 1.1 66/211066/2 submit/tizen/20190829.105349 submit/tizen/20190905.080725 submit/tizen/20190909.061136
authorDariusz Michaluk <d.michaluk@samsung.com>
Mon, 29 Jul 2019 13:45:11 +0000 (15:45 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Mon, 26 Aug 2019 12:16:21 +0000 (12:16 +0000)
Locking mechanism is not needed anymore

Change-Id: If11be650c3366084c7bd28da90b5463348b1c880

agent/download-agent-dl-info.c
agent/download-agent-interface.c
agent/include/download-agent-dl-info.h

index b1d42a7..a8036c1 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <curl/curl.h>
-#include <openssl/crypto.h>
 
 #include "download-agent-dl-info.h"
 #include "download-agent-http-mgr.h"
 #include "download-agent-http-msg-handler.h"
 
 static pthread_mutex_t mutex_da_info_list = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t *g_openssl_locks_list;
 da_info_t *da_info_list[DA_MAX_ID];
 
-/* locking mechnism for safe use of openssl context */
-static void openssl_lock_callback(int mode, int type, char *file, int line)
-{
-       DA_LOGV("type [%d], mode [%d]", type, mode);
-       (void)file;
-       (void)line;
-
-       if (mode & CRYPTO_LOCK)
-               pthread_mutex_lock(&(g_openssl_locks_list[type]));
-       else
-               pthread_mutex_unlock(&(g_openssl_locks_list[type]));
-}
-
-static unsigned long thread_id(void)
-{
-       unsigned long ret = (unsigned long)pthread_self();
-       return ret;
-}
-
-da_ret_t init_openssl_locks(void)
-{
-       DA_LOGD("");
-       int index;
-       int crypto_num_locks = CRYPTO_num_locks();
-       DA_LOGD("crypto_num_locks [%d]", crypto_num_locks);
-       g_openssl_locks_list = (pthread_mutex_t *)OPENSSL_malloc(crypto_num_locks * sizeof(pthread_mutex_t));
-       if (g_openssl_locks_list == DA_NULL) {
-               DA_LOGE("Failed to OPENSSL_malloc");
-               return DA_ERR_FAIL_TO_MEMALLOC;
-       }
-       for (index = 0; index < crypto_num_locks; index++)
-               pthread_mutex_init(&(g_openssl_locks_list[index]), NULL);
-
-       CRYPTO_set_id_callback((unsigned long (*)())thread_id);
-       CRYPTO_set_locking_callback((void (*)())openssl_lock_callback);
-
-       return DA_RESULT_OK;
-}
-da_ret_t deinit_openssl_locks(void)
-{
-       DA_LOGD("");
-       int index;
-       int crypto_num_locks = CRYPTO_num_locks();
-       for (index = 0; index < crypto_num_locks; index++)
-               pthread_mutex_destroy(&(g_openssl_locks_list[index]));
-
-       CRYPTO_set_id_callback(NULL);
-       CRYPTO_set_locking_callback(NULL);
-       OPENSSL_free(g_openssl_locks_list);
-       g_openssl_locks_list = NULL;
-
-       return DA_RESULT_OK;
-}
-
 static void __init_da_info(int id)
 {
        da_info_t *da_info = DA_NULL;
index 9b16308..4f1b4af 100755 (executable)
 int da_init()
 {
        DA_LOGV("");
-       da_ret_t ret = DA_RESULT_OK;
-       ret = init_openssl_locks();
-       DA_LOGI("Return ret = %d", ret);
-       return ret;
+       return DA_RESULT_OK;
 }
 
 int da_deinit()
@@ -32,7 +29,6 @@ int da_deinit()
 
        DA_LOGV("");
        destroy_da_info_list();
-       deinit_openssl_locks();
        DA_LOGI("====== da_deint EXIT =====");
        return ret;
 }
index 50192e9..58665f5 100644 (file)
@@ -181,8 +181,6 @@ extern da_info_t *da_info_list[DA_MAX_ID];
        DA_MUTEX_UNLOCK(&GET_STATE_MUTEX(INFO));\
        }
 
-da_ret_t init_openssl_locks(void);
-da_ret_t deinit_openssl_locks(void);
 da_ret_t get_available_da_id(int *available_id);
 da_ret_t copy_user_input_data(da_info_t *da_info, const char *url,
                req_data_t *ext_data, da_cb_t *da_cb_data);