From c8ddb867ee13ea0cbe2f43c63f3aa1062565630c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 23 Sep 2013 12:09:46 +0000 Subject: [PATCH] fully initialze modern gcrypt in MHD_init, only use thread initialization with legacy libgcrypt, update tests accordingly --- src/microhttpd/daemon.c | 7 ++++++- src/testcurl/https/test_empty_response.c | 4 ---- src/testcurl/https/test_https_get.c | 7 ------- src/testcurl/https/test_https_get_parallel.c | 2 -- src/testcurl/https/test_https_get_parallel_threads.c | 7 ------- src/testcurl/https/test_https_get_select.c | 4 ---- src/testcurl/https/test_https_multi_daemon.c | 4 ---- src/testcurl/https/test_https_session_info.c | 4 ---- src/testcurl/https/test_https_time_out.c | 2 -- src/testcurl/https/test_tls_authentication.c | 4 ---- src/testcurl/https/test_tls_extensions.c | 6 ++---- src/testcurl/https/test_tls_options.c | 4 +--- src/testcurl/test_digestauth.c | 2 -- src/testcurl/test_digestauth_with_arguments.c | 4 ---- src/testcurl/test_postform.c | 4 ---- 15 files changed, 9 insertions(+), 56 deletions(-) diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 4fe80f23..0829eebc 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -3841,8 +3841,10 @@ MHD_get_version (void) #endif // __GNUC__ #if HTTPS_SUPPORT +#if GCRYPT_VERSION_NUMBER < 0x010600 GCRY_THREAD_OPTION_PTHREAD_IMPL; #endif +#endif /** @@ -3856,9 +3858,12 @@ MHD_init () #ifdef WINDOWS plibc_init ("GNU", "libmicrohttpd"); -#endif +#endif# #if HTTPS_SUPPORT +#if GCRYPT_VERSION_NUMBER < 0x010600 gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); +#endif + gcry_check_version (NULL); gnutls_global_init (); #endif } diff --git a/src/testcurl/https/test_empty_response.c b/src/testcurl/https/test_empty_response.c index abc2b30a..570febdd 100644 --- a/src/testcurl/https/test_empty_response.c +++ b/src/testcurl/https/test_empty_response.c @@ -183,16 +183,12 @@ testInternalSelectGet () return 0; } -GCRY_THREAD_OPTION_PTHREAD_IMPL; int main (int argc, char *const *argv) { unsigned int errorCount = 0; - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); - if (!gcry_check_version (GCRYPT_VERSION)) - abort (); if (0 != curl_global_init (CURL_GLOBAL_ALL)) { fprintf (stderr, "Error: %s\n", strerror (errno)); diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c index 29e6d0eb..c44eb9ea 100644 --- a/src/testcurl/https/test_https_get.c +++ b/src/testcurl/https/test_https_get.c @@ -95,9 +95,6 @@ test_secure_get (FILE * test_fd, } -GCRY_THREAD_OPTION_PTHREAD_IMPL; - - int main (int argc, char *const *argv) { @@ -106,11 +103,7 @@ main (int argc, char *const *argv) const char *aes256_sha_sslv3 = "AES256-SHA"; const char *des_cbc3_sha_tlsv1 = "DES-CBC3-SHA"; - - if (!gcry_check_version (GCRYPT_VERSION)) - abort (); gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif diff --git a/src/testcurl/https/test_https_get_parallel.c b/src/testcurl/https/test_https_get_parallel.c index 33cf5e42..9ac330f0 100644 --- a/src/testcurl/https/test_https_get_parallel.c +++ b/src/testcurl/https/test_https_get_parallel.c @@ -121,7 +121,6 @@ test_parallel_clients (void * cls, const char *cipher_suite, return 0; } -GCRY_THREAD_OPTION_PTHREAD_IMPL; int main (int argc, char *const *argv) @@ -132,7 +131,6 @@ main (int argc, char *const *argv) /* initialize random seed used by curl clients */ unsigned int iseed = (unsigned int) time (NULL); srand (iseed); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); if (0 != curl_global_init (CURL_GLOBAL_ALL)) { fprintf (stderr, "Error: %s\n", strerror (errno)); diff --git a/src/testcurl/https/test_https_get_parallel_threads.c b/src/testcurl/https/test_https_get_parallel_threads.c index dea6e754..84ce0a18 100644 --- a/src/testcurl/https/test_https_get_parallel_threads.c +++ b/src/testcurl/https/test_https_get_parallel_threads.c @@ -123,10 +123,6 @@ test_parallel_clients (void *cls, const char *cipher_suite, } - -GCRY_THREAD_OPTION_PTHREAD_IMPL; - - int main (int argc, char *const *argv) { @@ -136,9 +132,6 @@ main (int argc, char *const *argv) /* initialize random seed used by curl clients */ unsigned int iseed = (unsigned int) time (NULL); - - gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif diff --git a/src/testcurl/https/test_https_get_select.c b/src/testcurl/https/test_https_get_select.c index 70a16425..ad3142d6 100644 --- a/src/testcurl/https/test_https_get_select.c +++ b/src/testcurl/https/test_https_get_select.c @@ -206,16 +206,12 @@ testExternalGet (int flags) return 0; } -GCRY_THREAD_OPTION_PTHREAD_IMPL; int main (int argc, char *const *argv) { unsigned int errorCount = 0; - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); - if (!gcry_check_version (GCRYPT_VERSION)) - abort (); if (0 != curl_global_init (CURL_GLOBAL_ALL)) { fprintf (stderr, "Error: %s\n", strerror (errno)); diff --git a/src/testcurl/https/test_https_multi_daemon.c b/src/testcurl/https/test_https_multi_daemon.c index 30b76713..e25513d1 100644 --- a/src/testcurl/https/test_https_multi_daemon.c +++ b/src/testcurl/https/test_https_multi_daemon.c @@ -91,9 +91,6 @@ test_concurent_daemon_pair (void *cls, } -GCRY_THREAD_OPTION_PTHREAD_IMPL; - - int main (int argc, char *const *argv) { @@ -101,7 +98,6 @@ main (int argc, char *const *argv) FILE *cert; gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c index aac3dcea..cc590227 100644 --- a/src/testcurl/https/test_https_session_info.c +++ b/src/testcurl/https/test_https_session_info.c @@ -151,16 +151,12 @@ test_query_session () } -GCRY_THREAD_OPTION_PTHREAD_IMPL; - - int main (int argc, char *const *argv) { unsigned int errorCount = 0; gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif diff --git a/src/testcurl/https/test_https_time_out.c b/src/testcurl/https/test_https_time_out.c index 112f5390..369bb861 100644 --- a/src/testcurl/https/test_https_time_out.c +++ b/src/testcurl/https/test_https_time_out.c @@ -90,7 +90,6 @@ test_tls_session_time_out (gnutls_session_t session) return 0; } -GCRY_THREAD_OPTION_PTHREAD_IMPL; int main (int argc, char *const *argv) @@ -104,7 +103,6 @@ main (int argc, char *const *argv) gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif diff --git a/src/testcurl/https/test_tls_authentication.c b/src/testcurl/https/test_tls_authentication.c index 42a33b4c..17942cf6 100644 --- a/src/testcurl/https/test_tls_authentication.c +++ b/src/testcurl/https/test_tls_authentication.c @@ -69,16 +69,12 @@ test_secure_get (void * cls, char *cipher_suite, int proto_version) } -GCRY_THREAD_OPTION_PTHREAD_IMPL; - - int main (int argc, char *const *argv) { unsigned int errorCount = 0; gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif diff --git a/src/testcurl/https/test_tls_extensions.c b/src/testcurl/https/test_tls_extensions.c index 2859fd9e..6ad3b97a 100644 --- a/src/testcurl/https/test_tls_extensions.c +++ b/src/testcurl/https/test_tls_extensions.c @@ -193,7 +193,6 @@ cleanup: return ret; } -GCRY_THREAD_OPTION_PTHREAD_IMPL int main (int argc, char *const *argv) @@ -206,13 +205,12 @@ main (int argc, char *const *argv) gnutls_datum_t cert; gnutls_certificate_credentials_t xcred; - int ext_arr[] = { GNUTLS_EXTENSION_SERVER_NAME, + const int ext_arr[] = { + GNUTLS_EXTENSION_SERVER_NAME, -1 }; - gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif diff --git a/src/testcurl/https/test_tls_options.c b/src/testcurl/https/test_tls_options.c index e7c85cea..17896b65 100644 --- a/src/testcurl/https/test_tls_options.c +++ b/src/testcurl/https/test_tls_options.c @@ -75,7 +75,6 @@ test_unmatching_ssl_version (void * cls, const char *cipher_suite, return 0; } -GCRY_THREAD_OPTION_PTHREAD_IMPL; /* setup a temporary transfer test file */ int @@ -83,12 +82,11 @@ main (int argc, char *const *argv) { unsigned int errorCount = 0; const char *ssl_version; - int daemon_flags = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | MHD_USE_DEBUG; + gcry_control (GCRYCTL_DISABLE_SECMEM, 0); gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif diff --git a/src/testcurl/test_digestauth.c b/src/testcurl/test_digestauth.c index d6c145f1..4838fc37 100644 --- a/src/testcurl/test_digestauth.c +++ b/src/testcurl/test_digestauth.c @@ -222,7 +222,6 @@ testDigestAuth () return 0; } -GCRY_THREAD_OPTION_PTHREAD_IMPL; int @@ -231,7 +230,6 @@ main (int argc, char *const *argv) unsigned int errorCount = 0; gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif diff --git a/src/testcurl/test_digestauth_with_arguments.c b/src/testcurl/test_digestauth_with_arguments.c index 08761fad..fb99fb7a 100644 --- a/src/testcurl/test_digestauth_with_arguments.c +++ b/src/testcurl/test_digestauth_with_arguments.c @@ -222,16 +222,12 @@ testDigestAuth () } -GCRY_THREAD_OPTION_PTHREAD_IMPL; - - int main (int argc, char *const *argv) { unsigned int errorCount = 0; gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif diff --git a/src/testcurl/test_postform.c b/src/testcurl/test_postform.c index 61e3fdf6..da9eac33 100644 --- a/src/testcurl/test_postform.c +++ b/src/testcurl/test_postform.c @@ -463,16 +463,12 @@ testExternalPost () } -GCRY_THREAD_OPTION_PTHREAD_IMPL; - - int main (int argc, char *const *argv) { unsigned int errorCount = 0; gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif