diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-12 18:27:24 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-13 09:07:03 +0300 |
commit | 1689be3a275dd8b4bb26c2f8501bd6050ac17e98 (patch) | |
tree | 9520bc447b08a4320731475346739eecb399977f | |
parent | f8502a2e07a5e3402431d6218252879c46621f46 (diff) | |
download | libmicrohttpd-1689be3a275dd8b4bb26c2f8501bd6050ac17e98.tar.gz libmicrohttpd-1689be3a275dd8b4bb26c2f8501bd6050ac17e98.zip |
daemon: merged processing of two similar options
-rw-r--r-- | src/microhttpd/daemon.c | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 9135af8c..35405f9f 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -6416,26 +6416,38 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
6416 | #endif | 6416 | #endif |
6417 | break; | 6417 | break; |
6418 | case MHD_OPTION_HTTPS_PRIORITIES: | 6418 | case MHD_OPTION_HTTPS_PRIORITIES: |
6419 | case MHD_OPTION_HTTPS_PRIORITIES_APPEND: | ||
6419 | pstr = va_arg (ap, | 6420 | pstr = va_arg (ap, |
6420 | const char *); | 6421 | const char *); |
6421 | if (0 != (daemon->options & MHD_USE_TLS)) | 6422 | if (0 != (daemon->options & MHD_USE_TLS)) |
6422 | { | 6423 | { |
6423 | int init_res; | ||
6424 | if (NULL != daemon->priority_cache) | 6424 | if (NULL != daemon->priority_cache) |
6425 | gnutls_priority_deinit (daemon->priority_cache); | 6425 | gnutls_priority_deinit (daemon->priority_cache); |
6426 | init_res = gnutls_priority_init (&daemon->priority_cache, | 6426 | |
6427 | pstr, | 6427 | if (MHD_OPTION_HTTPS_PRIORITIES == opt) |
6428 | NULL); | ||
6429 | if (GNUTLS_E_SUCCESS != init_res) | ||
6430 | { | 6428 | { |
6429 | int init_res; | ||
6430 | init_res = gnutls_priority_init (&daemon->priority_cache, | ||
6431 | pstr, | ||
6432 | NULL); | ||
6433 | if (GNUTLS_E_SUCCESS != init_res) | ||
6434 | { | ||
6431 | #ifdef HAVE_MESSAGES | 6435 | #ifdef HAVE_MESSAGES |
6432 | MHD_DLOG (daemon, | 6436 | MHD_DLOG (daemon, |
6433 | _ ("Setting priorities to `%s' failed: %s\n"), | 6437 | _ ("Setting priorities to `%s' failed: %s\n"), |
6434 | pstr, | 6438 | pstr, |
6435 | gnutls_strerror (init_res)); | 6439 | gnutls_strerror (init_res)); |
6436 | #endif | 6440 | #endif |
6441 | daemon->priority_cache = NULL; | ||
6442 | return MHD_NO; | ||
6443 | } | ||
6444 | } | ||
6445 | else | ||
6446 | { | ||
6447 | /* The cache has been deinited */ | ||
6437 | daemon->priority_cache = NULL; | 6448 | daemon->priority_cache = NULL; |
6438 | return MHD_NO; | 6449 | if (! daemon_tls_priorities_init_append (daemon, pstr)) |
6450 | return MHD_NO; | ||
6439 | } | 6451 | } |
6440 | } | 6452 | } |
6441 | #ifdef HAVE_MESSAGES | 6453 | #ifdef HAVE_MESSAGES |
@@ -6446,26 +6458,6 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
6446 | opt); | 6458 | opt); |
6447 | #endif | 6459 | #endif |
6448 | break; | 6460 | break; |
6449 | case MHD_OPTION_HTTPS_PRIORITIES_APPEND: | ||
6450 | pstr = va_arg (ap, | ||
6451 | const char *); | ||
6452 | if (0 != (daemon->options & MHD_USE_TLS)) | ||
6453 | { | ||
6454 | if (NULL != daemon->priority_cache) | ||
6455 | gnutls_priority_deinit (daemon->priority_cache); | ||
6456 | daemon->priority_cache = NULL; | ||
6457 | /* The next function log error messages if needed */ | ||
6458 | if (! daemon_tls_priorities_init_append (daemon, pstr)) | ||
6459 | return MHD_NO; | ||
6460 | } | ||
6461 | #ifdef HAVE_MESSAGES | ||
6462 | else | ||
6463 | MHD_DLOG (daemon, | ||
6464 | _ ("MHD HTTPS option %d passed to MHD but " \ | ||
6465 | "MHD_USE_TLS not set.\n"), | ||
6466 | opt); | ||
6467 | #endif | ||
6468 | break; | ||
6469 | case MHD_OPTION_HTTPS_CERT_CALLBACK: | 6461 | case MHD_OPTION_HTTPS_CERT_CALLBACK: |
6470 | #if GNUTLS_VERSION_MAJOR < 3 | 6462 | #if GNUTLS_VERSION_MAJOR < 3 |
6471 | #ifdef HAVE_MESSAGES | 6463 | #ifdef HAVE_MESSAGES |