libmicrohttpd

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

commit 0ea5d514477a8b109a922afe5cdd1343d94c63bd
parent 0a478564f7ca32e7e5e6e20559149067515082a6
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sat, 15 Jan 2022 17:45:48 +0300

test_upgrade{,_large}: used the same port for all checks.

Fixed port conflict for platforms with broken detection of autobind port

Diffstat:
Msrc/microhttpd/test_upgrade.c | 14++++++++------
Msrc/microhttpd/test_upgrade_large.c | 14++++++++------
2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c @@ -174,6 +174,8 @@ fflush_allstd (void) static int verbose = 0; +static uint16_t global_port; + enum tls_tool { TLS_CLI_NO_TOOL = 0, @@ -1265,9 +1267,7 @@ test_upgrade (int flags, if (! test_tls) d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE, - MHD_is_feature_supported ( - MHD_FEATURE_AUTODETECT_BIND_PORT) ? - 0 : 1090, + global_port, NULL, NULL, &ahc_upgrade, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, @@ -1281,9 +1281,7 @@ test_upgrade (int flags, else d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE | MHD_USE_TLS, - MHD_is_feature_supported ( - MHD_FEATURE_AUTODETECT_BIND_PORT) ? - 0 : 1090, + global_port, NULL, NULL, &ahc_upgrade, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, @@ -1307,6 +1305,7 @@ test_upgrade (int flags, if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); + global_port = dinfo->port; /* Re-use the same port for the next checks */ if (! test_tls || (TLS_LIB_GNUTLS == use_tls_tool)) { sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt (); @@ -1434,6 +1433,9 @@ main (int argc, #endif /* ! HTTPS_SUPPORT */ } + global_port = MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT) ? + 0 : (test_tls ? 1091 : 1090); + /* run tests */ if (verbose) printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n", diff --git a/src/microhttpd/test_upgrade_large.c b/src/microhttpd/test_upgrade_large.c @@ -338,6 +338,8 @@ fflush_allstd (void) static int verbose = 0; +static uint16_t global_port; + static struct MHD_itc_ kicker = MHD_ITC_STATIC_INIT_INVALID; enum tls_tool @@ -1453,9 +1455,7 @@ test_upgrade (int flags, if (! test_tls) d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE, - MHD_is_feature_supported ( - MHD_FEATURE_AUTODETECT_BIND_PORT) ? - 0 : 1090, + global_port, NULL, NULL, &ahc_upgrade, NULL, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) 512, @@ -1470,9 +1470,7 @@ test_upgrade (int flags, else d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE | MHD_USE_TLS, - MHD_is_feature_supported ( - MHD_FEATURE_AUTODETECT_BIND_PORT) ? - 0 : 1090, + global_port, NULL, NULL, &ahc_upgrade, NULL, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) 512, @@ -1497,6 +1495,7 @@ test_upgrade (int flags, if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); + global_port = dinfo->port; /* Re-use the same port for the next checks */ if (! test_tls || (TLS_LIB_GNUTLS == use_tls_tool)) { sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt (); @@ -1634,6 +1633,9 @@ main (int argc, #endif /* ! HTTPS_SUPPORT */ } + global_port = MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT) ? + 0 : (test_tls ? 1093 : 1092); + /* run tests */ if (verbose) printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n",