# HG changeset patch # User Sebastien Jodogne # Date 1548848480 -3600 # Node ID 6d558598d7133b85e8baac28b74f17495cfe769d # Parent 053e72ff9fc57ca149580c9f0368ca321b2910b2 Fix build with unpatched versions of Civetweb (missing "mg_disable_keep_alive()") diff -r 053e72ff9fc5 -r 6d558598d713 Core/HttpServer/HttpOutput.cpp --- a/Core/HttpServer/HttpOutput.cpp Wed Jan 30 10:24:12 2019 +0100 +++ b/Core/HttpServer/HttpOutput.cpp Wed Jan 30 12:41:20 2019 +0100 @@ -46,6 +46,13 @@ #include +#if ORTHANC_ENABLE_CIVETWEB == 1 +# if !defined(CIVETWEB_HAS_DISABLE_KEEP_ALIVE) +# error Macro CIVETWEB_HAS_DISABLE_KEEP_ALIVE must be defined +# endif +#endif + + namespace Orthanc { HttpOutput::StateMachine::StateMachine(IHttpOutputStream& stream, @@ -432,11 +439,22 @@ throw OrthancException(ErrorCode_NotImplemented, "Multipart answers are not implemented together " "with keep-alive connections if using Mongoose"); -#else + +#elif ORTHANC_ENABLE_CIVETWEB == 1 +# if CIVETWEB_HAS_DISABLE_KEEP_ALIVE == 1 // Turn off Keep-Alive for multipart answers // https://github.com/civetweb/civetweb/issues/727 stream_.DisableKeepAlive(); header += "Connection: close\r\n"; +# else + // The function "mg_disable_keep_alive()" is not available, + // let's continue with Keep-Alive. Performance of WADO-RS will + // decrease. + header += "Connection: keep-alive\r\n"; +# endif + +#else +# error Please support your embedded Web server here #endif } else diff -r 053e72ff9fc5 -r 6d558598d713 Core/HttpServer/HttpServer.cpp --- a/Core/HttpServer/HttpServer.cpp Wed Jan 30 10:24:12 2019 +0100 +++ b/Core/HttpServer/HttpServer.cpp Wed Jan 30 12:41:20 2019 +0100 @@ -47,6 +47,9 @@ #elif ORTHANC_ENABLE_CIVETWEB == 1 # include # define MONGOOSE_USE_CALLBACKS 1 +# if !defined(CIVETWEB_HAS_DISABLE_KEEP_ALIVE) +# error Macro CIVETWEB_HAS_DISABLE_KEEP_ALIVE must be defined +# endif #else # error "Either Mongoose or Civetweb must be enabled to compile this file" @@ -114,8 +117,18 @@ #if ORTHANC_ENABLE_MONGOOSE == 1 throw OrthancException(ErrorCode_NotImplemented, "Only available if using CivetWeb"); + #elif ORTHANC_ENABLE_CIVETWEB == 1 +# if CIVETWEB_HAS_DISABLE_KEEP_ALIVE == 1 mg_disable_keep_alive(connection_); +# else +# warning The function "mg_disable_keep_alive()" is not available, DICOMweb might run slowly + throw OrthancException(ErrorCode_NotImplemented, + "Only available if using a patched version of CivetWeb"); +# endif + +#else +# error Please support your embedded Web server here #endif } }; diff -r 053e72ff9fc5 -r 6d558598d713 NEWS --- a/NEWS Wed Jan 30 10:24:12 2019 +0100 +++ b/NEWS Wed Jan 30 12:41:20 2019 +0100 @@ -13,6 +13,11 @@ * New URI "/tools/metrics" to dynamically enable/disable the collection of metrics * New URI "/tools/metrics-prometheus" to retrieve metrics using Prometheus text format +Maintenance +----------- + +* Fix build with unpatched versions of Civetweb (missing "mg_disable_keep_alive()") + Version 1.5.3 (2019-01-25) ========================== diff -r 053e72ff9fc5 -r 6d558598d713 Resources/CMake/CivetwebConfiguration.cmake --- a/Resources/CMake/CivetwebConfiguration.cmake Wed Jan 30 10:24:12 2019 +0100 +++ b/Resources/CMake/CivetwebConfiguration.cmake Wed Jan 30 12:41:20 2019 +0100 @@ -47,6 +47,10 @@ source_group(ThirdParty\\Civetweb REGULAR_EXPRESSION ${CIVETWEB_SOURCES_DIR}/.*) + add_definitions( + -DCIVETWEB_HAS_DISABLE_KEEP_ALIVE=1 + ) + else() CHECK_INCLUDE_FILE_CXX(civetweb.h HAVE_CIVETWEB_H) if (NOT HAVE_CIVETWEB_H) @@ -61,4 +65,8 @@ endif() link_libraries(civetweb) + + add_definitions( + -DCIVETWEB_HAS_DISABLE_KEEP_ALIVE=0 + ) endif()