diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-06 08:52:46 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-10 11:54:30 +0300 |
commit | a710f6270813ad935a98893b483d58814f17cdf8 (patch) | |
tree | 29b81c7ee20f7443e9cd79ac459adfd79af9ddf9 | |
parent | 8fea3c91926e00a8810ac3e68d9d5a24ce5cc823 (diff) | |
download | libmicrohttpd-a710f6270813ad935a98893b483d58814f17cdf8.tar.gz libmicrohttpd-a710f6270813ad935a98893b483d58814f17cdf8.zip |
test_https_time_out: second attempt to really check something with this test
-rw-r--r-- | src/testcurl/https/test_https_time_out.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/testcurl/https/test_https_time_out.c b/src/testcurl/https/test_https_time_out.c index 86859ca3..8893c16b 100644 --- a/src/testcurl/https/test_https_time_out.c +++ b/src/testcurl/https/test_https_time_out.c | |||
@@ -54,10 +54,10 @@ | |||
54 | #endif | 54 | #endif |
55 | #include "tls_test_keys.h" | 55 | #include "tls_test_keys.h" |
56 | 56 | ||
57 | static const int TIME_OUT = 2; | 57 | static const unsigned int timeout_val = 2; |
58 | 58 | ||
59 | static unsigned int num_connects = 0; | 59 | static volatile unsigned int num_connects = 0; |
60 | static unsigned int num_disconnects = 0; | 60 | static volatile unsigned int num_disconnects = 0; |
61 | 61 | ||
62 | 62 | ||
63 | /** | 63 | /** |
@@ -104,18 +104,27 @@ socket_cb (void *cls, | |||
104 | void **socket_context, | 104 | void **socket_context, |
105 | enum MHD_ConnectionNotificationCode toe) | 105 | enum MHD_ConnectionNotificationCode toe) |
106 | { | 106 | { |
107 | struct sckt_notif_cb_param *param = (struct sckt_notif_cb_param *) cls; | ||
108 | if (NULL == socket_context) | 107 | if (NULL == socket_context) |
109 | abort (); | 108 | abort (); |
110 | if (NULL == c) | 109 | if (NULL == c) |
111 | abort (); | 110 | abort (); |
112 | if (NULL == param) | 111 | if (NULL != cls) |
113 | abort (); | 112 | abort (); |
114 | 113 | ||
115 | if (MHD_CONNECTION_NOTIFY_STARTED == toe) | 114 | if (MHD_CONNECTION_NOTIFY_STARTED == toe) |
115 | { | ||
116 | num_connects++; | 116 | num_connects++; |
117 | #ifdef _DEBUG | ||
118 | fprintf (stderr, "MHD: Connection has started.\n"); | ||
119 | #endif /* _DEBUG */ | ||
120 | } | ||
117 | else if (MHD_CONNECTION_NOTIFY_CLOSED == toe) | 121 | else if (MHD_CONNECTION_NOTIFY_CLOSED == toe) |
122 | { | ||
118 | num_disconnects++; | 123 | num_disconnects++; |
124 | #ifdef _DEBUG | ||
125 | fprintf (stderr, "MHD: Connection has closed.\n"); | ||
126 | #endif /* _DEBUG */ | ||
127 | } | ||
119 | else | 128 | else |
120 | abort (); | 129 | abort (); |
121 | } | 130 | } |
@@ -163,17 +172,21 @@ test_tls_session_time_out (gnutls_session_t session, uint16_t port) | |||
163 | return 2; | 172 | return 2; |
164 | } | 173 | } |
165 | 174 | ||
166 | _MHD_sleep (TIME_OUT * 1000 + 1200); | 175 | _MHD_sleep (timeout_val * 1000 + 1700); |
167 | 176 | ||
177 | if (0 == num_connects) | ||
178 | { | ||
179 | fprintf (stderr, "MHD has not detected any connection attempt.\n"); | ||
180 | MHD_socket_close_chk_ (sd); | ||
181 | return 4; | ||
182 | } | ||
168 | /* check that server has closed the connection */ | 183 | /* check that server has closed the connection */ |
169 | if (1 == num_disconnects) | 184 | if (0 == num_disconnects) |
170 | { | 185 | { |
171 | fprintf (stderr, "Connection failed to time-out\n"); | 186 | fprintf (stderr, "MHD has not detected any disconnections.\n"); |
172 | MHD_socket_close_chk_ (sd); | 187 | MHD_socket_close_chk_ (sd); |
173 | return 1; | 188 | return 1; |
174 | } | 189 | } |
175 | else if (0 != num_disconnects) | ||
176 | abort (); | ||
177 | 190 | ||
178 | MHD_socket_close_chk_ (sd); | 191 | MHD_socket_close_chk_ (sd); |
179 | return 0; | 192 | return 0; |
@@ -225,7 +238,9 @@ main (int argc, char *const *argv) | |||
225 | | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | 238 | | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS |
226 | | MHD_USE_ERROR_LOG, port, | 239 | | MHD_USE_ERROR_LOG, port, |
227 | NULL, NULL, &http_dummy_ahc, NULL, | 240 | NULL, NULL, &http_dummy_ahc, NULL, |
228 | MHD_OPTION_CONNECTION_TIMEOUT, TIME_OUT, | 241 | MHD_OPTION_CONNECTION_TIMEOUT, |
242 | (unsigned int) timeout_val, | ||
243 | MHD_OPTION_NOTIFY_CONNECTION, &socket_cb, NULL, | ||
229 | MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, | 244 | MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, |
230 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, | 245 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, |
231 | MHD_OPTION_END); | 246 | MHD_OPTION_END); |