gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (72d1acb3 -> 36f1c42d)


From: gnunet
Subject: [libmicrohttpd] branch master updated (72d1acb3 -> 36f1c42d)
Date: Sun, 09 Jul 2023 18:32:35 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 72d1acb3 perf_replies: added various response sizes, minor fixes
     new e5103067 perf_replies: added short aliases for polling function modes
     new 36f1c42d perf_replies: added 'thread-per-connection' mode

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/tools/perf_replies.c | 121 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 101 insertions(+), 20 deletions(-)

diff --git a/src/tools/perf_replies.c b/src/tools/perf_replies.c
index 2fd58c12..58000338 100644
--- a/src/tools/perf_replies.c
+++ b/src/tools/perf_replies.c
@@ -333,15 +333,18 @@ show_help (void)
   printf ("  -A,     --all-cpus        use all available CPU cores (for \n"
           "                            testing with remote client)\n");
   printf ("  -t NUM, --threads=NUM     use NUM threads\n");
+  printf ("  -P,     --thread-per-conn use thread-per-connection mode,\n"
+          "                            the number of threads are limited 
only\n"
+          "                            by the number of connection\n");
   printf ("\n");
   printf ("Force polling function (mutually exclusive):\n");
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_EPOLL))
-    printf ("          --epoll           use 'epoll' functionality\n");
+    printf ("  -e,     --epoll           use 'epoll' functionality\n");
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_POLL))
-    printf ("          --poll            use poll() function\n");
-  printf ("          --select          use select() function\n");
+    printf ("  -p,     --poll            use poll() function\n");
+  printf ("  -s,     --select          use select() function\n");
   printf ("\n");
-  printf ("Response size options (mutually exclusive):\n");
+  printf ("Response body size options (mutually exclusive):\n");
   printf ("  -E,     --empty           empty response, 0 bytes\n");
   printf ("  -T,     --tiny            tiny response, 3 bytes (default)\n");
   printf ("  -M,     --medium          medium response, 8 KB\n");
@@ -367,6 +370,7 @@ struct PerfRepl_parameters
   unsigned int port;
   int all_cpus;
   unsigned int threads;
+  int thread_per_conn;
   int epoll;
   int poll;
   int select;
@@ -396,9 +400,32 @@ static struct PerfRepl_parameters tool_params = {
   0,
   0,
   0,
+  0,
   0
 };
 
+
+static enum PerfRepl_param_result
+process_param__all_cpus (const char *param_name)
+{
+  if (0 != tool_params.threads)
+  {
+    fprintf (stderr, "Parameter '%s' cannot be used together "
+             "with '-t' or '--threads'.\n", param_name);
+    return PERF_RPL_PARAM_ERROR;
+  }
+  if (tool_params.thread_per_conn)
+  {
+    fprintf (stderr, "Parameter '%s' cannot be used together "
+             "with '-P' or '--thread-per-conn'.\n", param_name);
+    return PERF_RPL_PARAM_ERROR;
+  }
+  tool_params.all_cpus = ! 0;
+  return '-' == param_name[1] ?
+         PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR;
+}
+
+
 /**
  * Process parameter '-t' or '--threads'
  * @param param_name the name of the parameter as specified in command line
@@ -421,6 +448,12 @@ process_param__threads (const char *param_name, const char 
*param_tail,
              "with '-A' or '--all-cpus'.\n", param_name);
     return PERF_RPL_PARAM_ERROR;
   }
+  if (tool_params.thread_per_conn)
+  {
+    fprintf (stderr, "Parameter '%s' cannot be used together "
+             "with '-P' or '--thread-per-conn'.\n", param_name);
+    return PERF_RPL_PARAM_ERROR;
+  }
   value_res = get_param_value (param_name, param_tail, next_param,
                                &param_value);
   if (PERF_RPL_PARAM_ERROR == value_res)
@@ -438,15 +471,21 @@ process_param__threads (const char *param_name, const 
char *param_tail,
 
 
 static enum PerfRepl_param_result
-process_param__all_cpus (const char *param_name)
+process_param__thread_per_conn (const char *param_name)
 {
+  if (tool_params.all_cpus)
+  {
+    fprintf (stderr, "Parameter '%s' cannot be used together "
+             "with '-A' or '--all-cpus'.\n", param_name);
+    return PERF_RPL_PARAM_ERROR;
+  }
   if (0 != tool_params.threads)
   {
     fprintf (stderr, "Parameter '%s' cannot be used together "
              "with '-t' or '--threads'.\n", param_name);
     return PERF_RPL_PARAM_ERROR;
   }
-  tool_params.all_cpus = ! 0;
+  tool_params.thread_per_conn = ! 0;
   return '-' == param_name[1] ?
          PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR;
 }
@@ -458,13 +497,13 @@ process_param__epoll (const char *param_name)
   if (tool_params.poll)
   {
     fprintf (stderr, "Parameter '%s' cannot be used together "
-             "with '--poll'.\n", param_name);
+             "with '-p' or '--poll'.\n", param_name);
     return PERF_RPL_PARAM_ERROR;
   }
   if (tool_params.select)
   {
     fprintf (stderr, "Parameter '%s' cannot be used together "
-             "with '--select'.\n", param_name);
+             "with '-s' or '--select'.\n", param_name);
     return PERF_RPL_PARAM_ERROR;
   }
   tool_params.epoll = ! 0;
@@ -479,13 +518,13 @@ process_param__poll (const char *param_name)
   if (tool_params.epoll)
   {
     fprintf (stderr, "Parameter '%s' cannot be used together "
-             "with '--epoll'.\n", param_name);
+             "with '-e' or '--epoll'.\n", param_name);
     return PERF_RPL_PARAM_ERROR;
   }
   if (tool_params.select)
   {
     fprintf (stderr, "Parameter '%s' cannot be used together "
-             "with '--select'.\n", param_name);
+             "with '-s' or '--select'.\n", param_name);
     return PERF_RPL_PARAM_ERROR;
   }
   tool_params.poll = ! 0;
@@ -500,13 +539,13 @@ process_param__select (const char *param_name)
   if (tool_params.epoll)
   {
     fprintf (stderr, "Parameter '%s' cannot be used together "
-             "with '--epoll'.\n", param_name);
+             "with '-e' or '--epoll'.\n", param_name);
     return PERF_RPL_PARAM_ERROR;
   }
   if (tool_params.poll)
   {
     fprintf (stderr, "Parameter '%s' cannot be used together "
-             "with '--poll'.\n", param_name);
+             "with '-p' or '--poll'.\n", param_name);
     return PERF_RPL_PARAM_ERROR;
   }
   tool_params.select = ! 0;
@@ -728,6 +767,14 @@ process_short_param (const char *param, const char 
*next_param)
     return process_param__all_cpus ("-A");
   else if ('t' == param_chr)
     return process_param__threads ("-t", param + 1, next_param);
+  else if ('P' == param_chr)
+    return process_param__thread_per_conn ("-P");
+  else if ('e' == param_chr)
+    return process_param__epoll ("-e");
+  else if ('p' == param_chr)
+    return process_param__poll ("-p");
+  else if ('s' == param_chr)
+    return process_param__select ("-s");
   else if ('E' == param_chr)
     return process_param__empty ("-E");
   else if ('T' == param_chr)
@@ -795,6 +842,10 @@ process_long_param (const char *param, const char 
*next_param)
     return process_param__threads ("--threads",
                                    param + MHD_STATICSTR_LEN_ ("threads"),
                                    next_param);
+  else if ((MHD_STATICSTR_LEN_ ("thread-per-conn") == param_len) &&
+           (0 == memcmp (param, "thread-per-conn",
+                         MHD_STATICSTR_LEN_ ("thread-per-conn"))))
+    return process_param__thread_per_conn ("--thread-per-conn");
   else if ((MHD_STATICSTR_LEN_ ("epoll") == param_len) &&
            (0 == memcmp (param, "epoll", MHD_STATICSTR_LEN_ ("epoll"))))
     return process_param__epoll ("--epoll");
@@ -936,6 +987,16 @@ print_all_cores_used (void)
 }
 
 
+static void
+check_param_port (void)
+{
+  if (0 != tool_params.port)
+    return;
+  if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
+    tool_params.port = PERF_REPL_PORT_FALLBACK;
+}
+
+
 /**
  * Apply parameter '-A' or '--all-cpus'
  */
@@ -978,13 +1039,25 @@ check_apply_param__threads (void)
 }
 
 
-static void
-check_param_port (void)
+/**
+ * Apply parameter '-P' or '--thread-per-conn'
+ * @return non-zero - OK, zero - error
+ */
+static int
+check_apply_param__thread_per_conn (void)
 {
-  if (0 != tool_params.port)
-    return;
-  if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
-    tool_params.port = PERF_REPL_PORT_FALLBACK;
+  if (! tool_params.thread_per_conn)
+    return ! 0;
+
+  if (tool_params.epoll)
+  {
+    fprintf (stderr, "'Thread-per-connection' mode cannot be used together "
+             "with 'epoll'.\n");
+    return 0;
+  }
+  num_threads = 1;
+
+  return ! 0;
 }
 
 
@@ -1070,6 +1143,8 @@ check_apply_params (void)
   check_param_port ();
   check_apply_param__all_cpus ();
   check_apply_param__threads ();
+  if (! check_apply_param__thread_per_conn ())
+    return PERF_RPL_ERR_CODE_BAD_PARAM;
   if (! check_param__epoll ())
     return PERF_RPL_ERR_CODE_BAD_PARAM;
   if (! check_param__poll ())
@@ -1339,6 +1414,10 @@ run_mhd (void)
     (void) flags; /* No special additional flag */
   else
     flags |= MHD_USE_AUTO;
+
+  if (tool_params.thread_per_conn)
+    flags |= MHD_USE_THREAD_PER_CONNECTION;
+
   if (! tool_params.date_header)
     flags |= MHD_USE_SUPPRESS_DATE_NO_CLOCK;
 
@@ -1397,7 +1476,9 @@ run_mhd (void)
   printf ("  Bind port:          %u\n", (unsigned int) port);
   printf ("  Polling function:   %s\n", poll_mode);
   printf ("  Threading:          ");
-  if (1 == get_num_threads ())
+  if (MHD_USE_THREAD_PER_CONNECTION == (flags & MHD_USE_THREAD_PER_CONNECTION))
+    printf ("thread per connection\n");
+  else if (1 == get_num_threads ())
     printf ("one MHD thread\n");
   else
     printf ("%u MHD threads in thread pool\n", get_num_threads ());
@@ -1406,7 +1487,7 @@ run_mhd (void)
           0 == tool_params.timeout ? " (no timeout)" : "");
   printf ("  'Date:' header:     %s\n",
           tool_params.date_header ? "Yes" : "No");
-  printf ("  Response size:      %s\n",
+  printf ("  Response body size: %s\n",
           get_mhd_response_size ());
   printf ("To test with remote client use            "
           "http://HOST_IP:%u/\n";, (unsigned int) port);

-- 
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]