aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-12-12 20:03:43 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-12-12 20:51:28 +0300
commit54e83ba5ee023873390e84b11bb6abddc6e4e373 (patch)
tree70f1d601d89f51b6d000fb799120e819f9f8fefc
parent993fd001ab578ecfc9edd2ffad6b18ab8f911b90 (diff)
downloadlibmicrohttpd-54e83ba5ee023873390e84b11bb6abddc6e4e373.tar.gz
libmicrohttpd-54e83ba5ee023873390e84b11bb6abddc6e4e373.zip
test_https_time_out: fixed test, now testing is real
-rw-r--r--src/testcurl/https/test_https_time_out.c33
1 files 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
index e77c8c66..c86aaccd 100644
--- a/src/testcurl/https/test_https_time_out.c
+++ b/src/testcurl/https/test_https_time_out.c
@@ -44,7 +44,33 @@
44extern const char srv_key_pem[]; 44extern const char srv_key_pem[];
45extern const char srv_self_signed_cert_pem[]; 45extern const char srv_self_signed_cert_pem[];
46 46
47static const int TIME_OUT = 3; 47static const int TIME_OUT = 2;
48
49static unsigned int num_connects = 0;
50static unsigned int num_disconnects = 0;
51
52void
53socket_cb (void *cls,
54 struct MHD_Connection *c,
55 void **socket_context,
56 enum MHD_ConnectionNotificationCode toe)
57{
58 struct sckt_notif_cb_param *param = (struct sckt_notif_cb_param *) cls;
59 if (NULL == socket_context)
60 abort ();
61 if (NULL == c)
62 abort ();
63 if (NULL == param)
64 abort ();
65
66 if (MHD_CONNECTION_NOTIFY_STARTED == toe)
67 num_connects++;
68 else if (MHD_CONNECTION_NOTIFY_CLOSED == toe)
69 num_disconnects++;
70 else
71 abort ();
72}
73
48 74
49static int 75static int
50test_tls_session_time_out (gnutls_session_t session, int port) 76test_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)
87 (void) sleep (TIME_OUT + 1); 113 (void) sleep (TIME_OUT + 1);
88 114
89 /* check that server has closed the connection */ 115 /* check that server has closed the connection */
90 /* TODO better RST trigger */ 116 if (1 == num_disconnects)
91 if (send (sd, "", 1, 0) >= 0)
92 { 117 {
93 fprintf (stderr, "Connection failed to time-out\n"); 118 fprintf (stderr, "Connection failed to time-out\n");
94 MHD_socket_close_chk_ (sd); 119 MHD_socket_close_chk_ (sd);
95 return -1; 120 return -1;
96 } 121 }
122 else if (0 != num_disconnects)
123 abort ();
97 124
98 MHD_socket_close_chk_ (sd); 125 MHD_socket_close_chk_ (sd);
99 return 0; 126 return 0;