gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 12/31: test_https_time_out: second attempt to really che


From: gnunet
Subject: [libmicrohttpd] 12/31: test_https_time_out: second attempt to really check something with this test
Date: Mon, 10 Oct 2022 13:00:57 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit a710f6270813ad935a98893b483d58814f17cdf8
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu Oct 6 08:52:46 2022 +0300

    test_https_time_out: second attempt to really check something with this test
---
 src/testcurl/https/test_https_time_out.c | 37 ++++++++++++++++++++++----------
 1 file 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 @@
 #endif
 #include "tls_test_keys.h"
 
-static const int TIME_OUT = 2;
+static const unsigned int timeout_val = 2;
 
-static unsigned int num_connects = 0;
-static unsigned int num_disconnects = 0;
+static volatile unsigned int num_connects = 0;
+static volatile unsigned int num_disconnects = 0;
 
 
 /**
@@ -104,18 +104,27 @@ socket_cb (void *cls,
            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)
+  if (NULL != cls)
     abort ();
 
   if (MHD_CONNECTION_NOTIFY_STARTED == toe)
+  {
     num_connects++;
+#ifdef _DEBUG
+    fprintf (stderr, "MHD: Connection has started.\n");
+#endif /* _DEBUG */
+  }
   else if (MHD_CONNECTION_NOTIFY_CLOSED == toe)
+  {
     num_disconnects++;
+#ifdef _DEBUG
+    fprintf (stderr, "MHD: Connection has closed.\n");
+#endif /* _DEBUG */
+  }
   else
     abort ();
 }
@@ -163,17 +172,21 @@ test_tls_session_time_out (gnutls_session_t session, 
uint16_t port)
     return 2;
   }
 
-  _MHD_sleep (TIME_OUT * 1000 + 1200);
+  _MHD_sleep (timeout_val * 1000 + 1700);
 
+  if (0 == num_connects)
+  {
+    fprintf (stderr, "MHD has not detected any connection attempt.\n");
+    MHD_socket_close_chk_ (sd);
+    return 4;
+  }
   /* check that server has closed the connection */
-  if (1 == num_disconnects)
+  if (0 == num_disconnects)
   {
-    fprintf (stderr, "Connection failed to time-out\n");
+    fprintf (stderr, "MHD has not detected any disconnections.\n");
     MHD_socket_close_chk_ (sd);
     return 1;
   }
-  else if (0 != num_disconnects)
-    abort ();
 
   MHD_socket_close_chk_ (sd);
   return 0;
@@ -225,7 +238,9 @@ main (int argc, char *const *argv)
                         | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS
                         | MHD_USE_ERROR_LOG, port,
                         NULL, NULL, &http_dummy_ahc, NULL,
-                        MHD_OPTION_CONNECTION_TIMEOUT, TIME_OUT,
+                        MHD_OPTION_CONNECTION_TIMEOUT,
+                        (unsigned int) timeout_val,
+                        MHD_OPTION_NOTIFY_CONNECTION, &socket_cb, NULL,
                         MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
                         MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
                         MHD_OPTION_END);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]