aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/https/test_https_multi_daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/https/test_https_multi_daemon.c')
-rw-r--r--src/testcurl/https/test_https_multi_daemon.c106
1 files changed, 55 insertions, 51 deletions
diff --git a/src/testcurl/https/test_https_multi_daemon.c b/src/testcurl/https/test_https_multi_daemon.c
index 130fa9df..de153ff6 100644
--- a/src/testcurl/https/test_https_multi_daemon.c
+++ b/src/testcurl/https/test_https_multi_daemon.c
@@ -43,70 +43,74 @@ extern const char srv_self_signed_cert_pem[];
43 */ 43 */
44static int 44static int
45test_concurent_daemon_pair (void *cls, 45test_concurent_daemon_pair (void *cls,
46 const char *cipher_suite, 46 const char *cipher_suite,
47 int proto_version) 47 int proto_version)
48{ 48{
49 int ret; 49 int ret;
50 struct MHD_Daemon *d1; 50 struct MHD_Daemon *d1;
51 struct MHD_Daemon *d2; 51 struct MHD_Daemon *d2;
52 int port1, port2; 52 int port1, port2;
53 (void)cls; /* Unused. Silent compiler warning. */ 53 (void) cls; /* Unused. Silent compiler warning. */
54 54
55 55
56 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 56 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
57 port1 = port2 = 0; 57 port1 = port2 = 0;
58 else 58 else
59 { 59 {
60 port1 = 3050; 60 port1 = 3050;
61 port2 = 3051; 61 port2 = 3051;
62 } 62 }
63 63
64 d1 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | 64 d1 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION
65 MHD_USE_ERROR_LOG, port1, 65 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS
66 | MHD_USE_ERROR_LOG, port1,
66 NULL, NULL, &http_ahc, NULL, 67 NULL, NULL, &http_ahc, NULL,
67 MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, 68 MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
68 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 69 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
69 MHD_OPTION_END); 70 MHD_OPTION_END);
70 71
71 if (d1 == NULL) 72 if (d1 == NULL)
72 { 73 {
73 fprintf (stderr, MHD_E_SERVER_INIT); 74 fprintf (stderr, MHD_E_SERVER_INIT);
74 return -1; 75 return -1;
75 } 76 }
76 if (0 == port1) 77 if (0 == port1)
78 {
79 const union MHD_DaemonInfo *dinfo;
80 dinfo = MHD_get_daemon_info (d1, MHD_DAEMON_INFO_BIND_PORT);
81 if ((NULL == dinfo) ||(0 == dinfo->port) )
77 { 82 {
78 const union MHD_DaemonInfo *dinfo; 83 MHD_stop_daemon (d1); return -1;
79 dinfo = MHD_get_daemon_info (d1, MHD_DAEMON_INFO_BIND_PORT);
80 if (NULL == dinfo || 0 == dinfo->port)
81 { MHD_stop_daemon (d1); return -1; }
82 port1 = (int)dinfo->port;
83 } 84 }
85 port1 = (int) dinfo->port;
86 }
84 87
85 d2 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | 88 d2 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION
86 MHD_USE_ERROR_LOG, port2, 89 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS
90 | MHD_USE_ERROR_LOG, port2,
87 NULL, NULL, &http_ahc, NULL, 91 NULL, NULL, &http_ahc, NULL,
88 MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, 92 MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
89 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 93 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
90 MHD_OPTION_END); 94 MHD_OPTION_END);
91 95
92 if (d2 == NULL) 96 if (d2 == NULL)
97 {
98 MHD_stop_daemon (d1);
99 fprintf (stderr, MHD_E_SERVER_INIT);
100 return -1;
101 }
102 if (0 == port2)
103 {
104 const union MHD_DaemonInfo *dinfo;
105 dinfo = MHD_get_daemon_info (d2, MHD_DAEMON_INFO_BIND_PORT);
106 if ((NULL == dinfo) ||(0 == dinfo->port) )
93 { 107 {
94 MHD_stop_daemon (d1); 108 MHD_stop_daemon (d1);
95 fprintf (stderr, MHD_E_SERVER_INIT); 109 MHD_stop_daemon (d2);
96 return -1; 110 return -1;
97 } 111 }
98 if (0 == port2) 112 port2 = (int) dinfo->port;
99 { 113 }
100 const union MHD_DaemonInfo *dinfo;
101 dinfo = MHD_get_daemon_info (d2, MHD_DAEMON_INFO_BIND_PORT);
102 if (NULL == dinfo || 0 == dinfo->port)
103 {
104 MHD_stop_daemon (d1);
105 MHD_stop_daemon (d2);
106 return -1;
107 }
108 port2 = (int)dinfo->port;
109 }
110 114
111 ret = 115 ret =
112 test_daemon_get (NULL, cipher_suite, proto_version, port1, 0); 116 test_daemon_get (NULL, cipher_suite, proto_version, port1, 0);
@@ -128,7 +132,7 @@ main (int argc, char *const *argv)
128 unsigned int errorCount = 0; 132 unsigned int errorCount = 0;
129 FILE *cert; 133 FILE *cert;
130 const char *aes256_sha = "AES256-SHA"; 134 const char *aes256_sha = "AES256-SHA";
131 (void)argc; (void)argv; /* Unused. Silent compiler warning. */ 135 (void) argc; (void) argv; /* Unused. Silent compiler warning. */
132 136
133#ifdef MHD_HTTPS_REQUIRE_GRYPT 137#ifdef MHD_HTTPS_REQUIRE_GRYPT
134 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); 138 gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
@@ -136,25 +140,25 @@ main (int argc, char *const *argv)
136 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 140 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
137#endif 141#endif
138#endif /* MHD_HTTPS_REQUIRE_GRYPT */ 142#endif /* MHD_HTTPS_REQUIRE_GRYPT */
139 if (!testsuite_curl_global_init ()) 143 if (! testsuite_curl_global_init ())
140 return 99; 144 return 99;
141 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) 145 if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version)
142 { 146 {
143 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); 147 fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n");
144 curl_global_cleanup (); 148 curl_global_cleanup ();
145 return 77; 149 return 77;
146 } 150 }
147 if ((cert = setup_ca_cert ()) == NULL) 151 if ((cert = setup_ca_cert ()) == NULL)
148 { 152 {
149 fprintf (stderr, MHD_E_TEST_FILE_CREAT); 153 fprintf (stderr, MHD_E_TEST_FILE_CREAT);
150 curl_global_cleanup (); 154 curl_global_cleanup ();
151 return 99; 155 return 99;
152 } 156 }
153 157
154 if (curl_uses_nss_ssl() == 0) 158 if (curl_uses_nss_ssl () == 0)
155 { 159 {
156 aes256_sha = "rsa_aes_256_sha"; 160 aes256_sha = "rsa_aes_256_sha";
157 } 161 }
158 162
159 errorCount += 163 errorCount +=
160 test_concurent_daemon_pair (NULL, aes256_sha, CURL_SSLVERSION_TLSv1); 164 test_concurent_daemon_pair (NULL, aes256_sha, CURL_SSLVERSION_TLSv1);
@@ -165,7 +169,7 @@ main (int argc, char *const *argv)
165 fclose (cert); 169 fclose (cert);
166 if (0 != remove (ca_cert_file_name)) 170 if (0 != remove (ca_cert_file_name))
167 fprintf (stderr, 171 fprintf (stderr,
168 "Failed to remove `%s'\n", 172 "Failed to remove `%s'\n",
169 ca_cert_file_name); 173 ca_cert_file_name);
170 return errorCount != 0 ? 1 : 0; 174 return errorCount != 0 ? 1 : 0;
171} 175}