libmicrohttpd

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

commit 54e83ba5ee023873390e84b11bb6abddc6e4e373
parent 993fd001ab578ecfc9edd2ffad6b18ab8f911b90
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 12 Dec 2021 20:03:43 +0300

test_https_time_out: fixed test, now testing is real

Diffstat:
Msrc/testcurl/https/test_https_time_out.c | 33++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/src/testcurl/https/test_https_time_out.c b/src/testcurl/https/test_https_time_out.c @@ -44,7 +44,33 @@ extern const char srv_key_pem[]; extern const char srv_self_signed_cert_pem[]; -static const int TIME_OUT = 3; +static const int TIME_OUT = 2; + +static unsigned int num_connects = 0; +static unsigned int num_disconnects = 0; + +void +socket_cb (void *cls, + struct MHD_Connection *c, + void **socket_context, + enum MHD_ConnectionNotificationCode toe) +{ + struct sckt_notif_cb_param *param = (struct sckt_notif_cb_param *) cls; + if (NULL == socket_context) + abort (); + if (NULL == c) + abort (); + if (NULL == param) + abort (); + + if (MHD_CONNECTION_NOTIFY_STARTED == toe) + num_connects++; + else if (MHD_CONNECTION_NOTIFY_CLOSED == toe) + num_disconnects++; + else + abort (); +} + static int test_tls_session_time_out (gnutls_session_t session, int port) @@ -87,13 +113,14 @@ test_tls_session_time_out (gnutls_session_t session, int port) (void) sleep (TIME_OUT + 1); /* check that server has closed the connection */ - /* TODO better RST trigger */ - if (send (sd, "", 1, 0) >= 0) + if (1 == num_disconnects) { fprintf (stderr, "Connection failed to time-out\n"); MHD_socket_close_chk_ (sd); return -1; } + else if (0 != num_disconnects) + abort (); MHD_socket_close_chk_ (sd); return 0;