libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit a2425da6f9ba532d8a82906cdbb9ea6076d6a091
parent 4c1b251d7591d28257afd7bf7711350596f247ba
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 15 Sep 2013 20:22:40 +0000

proper gcrypt thread initialization in tests

Diffstat:
Msrc/testcurl/https/test_https_get.c | 8++++++++
Msrc/testcurl/https/test_https_get_parallel_threads.c | 12++++++++++++
Msrc/testcurl/https/test_https_multi_daemon.c | 19+++++++++++++++----
Msrc/testcurl/https/test_https_session_info.c | 10+++++++++-
Msrc/testcurl/https/test_https_time_out.c | 11++++++++++-
Msrc/testcurl/https/test_tls_authentication.c | 10+++++++++-
Msrc/testcurl/https/test_tls_extensions.c | 8++++++++
Msrc/testcurl/https/test_tls_options.c | 8+++++++-
Msrc/testcurl/https/tls_test_common.c | 3++-
Msrc/testcurl/https/tls_test_common.h | 3++-
10 files changed, 82 insertions(+), 10 deletions(-)

diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c @@ -95,6 +95,9 @@ test_secure_get (FILE * test_fd, } +GCRY_THREAD_OPTION_PTHREAD_IMPL; + + int main (int argc, char *const *argv) { @@ -106,6 +109,11 @@ main (int argc, char *const *argv) 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 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 @@ -32,6 +32,7 @@ #include <sys/stat.h> #include <limits.h> #include <curl/curl.h> +#include <gcrypt.h> #include "tls_test_common.h" extern const char srv_key_pem[]; @@ -122,6 +123,10 @@ test_parallel_clients (void *cls, const char *cipher_suite, } + +GCRY_THREAD_OPTION_PTHREAD_IMPL; + + int main (int argc, char *const *argv) { @@ -130,6 +135,13 @@ 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 srand (iseed); ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == ssl_version) diff --git a/src/testcurl/https/test_https_multi_daemon.c b/src/testcurl/https/test_https_multi_daemon.c @@ -29,7 +29,7 @@ #include <curl/curl.h> #include <limits.h> #include <sys/stat.h> - +#include <gcrypt.h> #include "tls_test_common.h" extern int curl_check_version (const char *req_version, ...); @@ -40,14 +40,16 @@ extern const char srv_self_signed_cert_pem[]; * assert initiating two separate daemons and having one shut down * doesn't affect the other */ -int -test_concurent_daemon_pair (void * cls, char *cipher_suite, +static int +test_concurent_daemon_pair (void *cls, + const char *cipher_suite, int proto_version) { int ret; struct MHD_Daemon *d1; struct MHD_Daemon *d2; + d1 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | MHD_USE_DEBUG, DEAMON_TEST_PORT, NULL, NULL, &http_ahc, NULL, @@ -88,12 +90,21 @@ test_concurent_daemon_pair (void * cls, char *cipher_suite, return ret; } + +GCRY_THREAD_OPTION_PTHREAD_IMPL; + + int main (int argc, char *const *argv) { unsigned int errorCount = 0; 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 if (0 != curl_global_init (CURL_GLOBAL_ALL)) { fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__, @@ -106,7 +117,7 @@ main (int argc, char *const *argv) return -1; } - char *aes256_sha = "AES256-SHA"; + const char *aes256_sha = "AES256-SHA"; if (curl_uses_nss_ssl() == 0) { aes256_sha = "rsa_aes_256_sha"; diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c @@ -27,7 +27,7 @@ #include "platform.h" #include "microhttpd.h" #include <curl/curl.h> - +#include <gcrypt.h> #include "tls_test_common.h" extern int curl_check_version (const char *req_version, ...); @@ -151,11 +151,19 @@ 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 if (0 != curl_global_init (CURL_GLOBAL_ALL)) { fprintf (stderr, "Error (code: %u)\n", errorCount); diff --git a/src/testcurl/https/test_https_time_out.c b/src/testcurl/https/test_https_time_out.c @@ -29,13 +29,14 @@ #include "microhttpd.h" #include "internal.h" #include "tls_test_common.h" +#include <gcrypt.h> extern const char srv_key_pem[]; extern const char srv_self_signed_cert_pem[]; static const int TIME_OUT = 3; -char *http_get_req = "GET / HTTP/1.1\r\n\r\n"; +static const char *http_get_req = "GET / HTTP/1.1\r\n\r\n"; static int test_tls_session_time_out (gnutls_session_t session) @@ -89,6 +90,8 @@ test_tls_session_time_out (gnutls_session_t session) return 0; } +GCRY_THREAD_OPTION_PTHREAD_IMPL; + int main (int argc, char *const *argv) { @@ -99,6 +102,12 @@ main (int argc, char *const *argv) gnutls_datum_t cert; gnutls_certificate_credentials_t xcred; + + 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 gnutls_global_init (); gnutls_global_set_log_level (11); diff --git a/src/testcurl/https/test_tls_authentication.c b/src/testcurl/https/test_tls_authentication.c @@ -29,7 +29,7 @@ #include <curl/curl.h> #include <limits.h> #include <sys/stat.h> - +#include <gcrypt.h> #include "tls_test_common.h" extern int curl_check_version (const char *req_version, ...); @@ -69,11 +69,19 @@ 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 if (setup_ca_cert () == NULL) { fprintf (stderr, MHD_E_TEST_FILE_CREAT); diff --git a/src/testcurl/https/test_tls_extensions.c b/src/testcurl/https/test_tls_extensions.c @@ -193,6 +193,8 @@ cleanup: return ret; } +GCRY_THREAD_OPTION_PTHREAD_IMPL + int main (int argc, char *const *argv) { @@ -208,6 +210,12 @@ main (int argc, char *const *argv) -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 MHD_gtls_global_set_log_level (11); if ((test_fd = setup_test_file ()) == NULL) diff --git a/src/testcurl/https/test_tls_options.c b/src/testcurl/https/test_tls_options.c @@ -75,6 +75,8 @@ test_unmatching_ssl_version (void * cls, const char *cipher_suite, return 0; } +GCRY_THREAD_OPTION_PTHREAD_IMPL; + /* setup a temporary transfer test file */ int main (int argc, char *const *argv) @@ -85,7 +87,11 @@ main (int argc, char *const *argv) MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | MHD_USE_DEBUG; gcry_control (GCRYCTL_DISABLE_SECMEM, 0); gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - if (curl_check_version (MHD_REQ_CURL_VERSION)) + gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); +#ifdef GCRYCTL_INITIALIZATION_FINISHED + gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); +#endif + if (curl_check_version (MHD_REQ_CURL_VERSION)) { return 0; } diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c @@ -63,7 +63,8 @@ setup_ca_cert () * test HTTPS transfer */ int -test_daemon_get (void *cls, char *cipher_suite, int proto_version, +test_daemon_get (void *cls, + const char *cipher_suite, int proto_version, int port, int ver_peer) { diff --git a/src/testcurl/https/tls_test_common.h b/src/testcurl/https/tls_test_common.h @@ -80,7 +80,8 @@ setup_ca_cert (); * perform cURL request for file */ int -test_daemon_get (void * cls, char *cipher_suite, int proto_version, +test_daemon_get (void * cls, + const char *cipher_suite, int proto_version, int port, int ver_peer); void print_test_result (int test_outcome, char *test_name);