1. 25 Aug, 2020 1 commit
  2. 17 Aug, 2020 1 commit
    • Fabrice Fontaine's avatar
      CMakeLists.txt: add C language to project statement (#813) · 718aabba
      Fabrice Fontaine authored
      This will fix the detection of atomic:
      
      -- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB
      -- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB - Failed
      -- Looking for __atomic_load_8 in atomic
      -- Looking for __atomic_load_8 in atomic - not found
      CMake Error at CMakeModules/CheckAtomic.cmake:76 (message):
        Host compiler appears to require libatomic for 64-bit operations, but
        cannot find it.
      Call Stack (most recent call first):
        CMakeLists.txt:19 (include)
      
      Indeed if C language is not enabled, the test will be run with the C++
      compiler resulting in the following error:
      
      Building CXX object CMakeFiles/cmTC_fad22.dir/CheckFunctionExists.cxx.o
      /tmp/instance-0/output-1/host/bin/mipsel-linux-g++ --sysroot=/tmp/instance-0/output-1/host/mipsel-buildroot-linux-gnu/sysroot    -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -D_FORTIFY_SOURCE=1 -Wall -Wconversion -pedantic -Wextra -Wno-missing-field-initializers -DCHECK_FUNCTION_EXISTS=__atomic_load_8  -DNDEBUG   -o CMakeFiles/cmTC_fad22.dir/CheckFunctionExists.cxx.o -c /tmp/instance-0/output-1/build/pistache-f2f5a50f/CMakeFiles/CheckLibraryExists/CheckFunctionExists.cxx
      <command-line>: error: new declaration 'char __atomic_load_8()' ambiguates built-in declaration 'long long unsigned int __atomic_load_8(const volatile void*, int)' [-fpermissive]
      /tmp/instance-0/output-1/build/pistache-f2f5a50f/CMakeFiles/CheckLibraryExists/CheckFunctionExists.cxx:7:3: note: in expansion of macro 'CHECK_FUNCTION_EXISTS'
         CHECK_FUNCTION_EXISTS(void);
         ^~~~~~~~~~~~~~~~~~~~~
      /tmp/instance-0/output-1/build/pistache-f2f5a50f/CMakeFiles/CheckLibraryExists/CheckFunctionExists.cxx: In function 'int main(int, char**)':
      /tmp/instance-0/output-1/build/pistache-f2f5a50f/CMakeFiles/CheckLibraryExists/CheckFunctionExists.cxx:17:25: error: too few arguments to function 'long long unsigned int __atomic_load_8(const volatile void*, int)'
         CHECK_FUNCTION_EXISTS();
                               ^
      
      whereas with a C compiler, we'll get:
      
      Building C object CMakeFiles/cmTC_4b0f4.dir/CheckFunctionExists.c.o
      /home/fabrice/buildroot/output/host/bin/riscv32-linux-gcc --sysroot=/home/fabrice/buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot   -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -DCHECK_FUNCTION_EXISTS=__atomic_load_8  -DNDEBUG   -o CMakeFiles/cmTC_4b0f4.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-3.16/Modules/CheckFunctionExists.c
      <command-line>: warning: conflicting types for built-in function ‘__atomic_load_8’ [-Wbuiltin-declaration-mismatch]
      /usr/share/cmake-3.16/Modules/CheckFunctionExists.c:7:3: note: in expansion of macro ‘CHECK_FUNCTION_EXISTS’
         CHECK_FUNCTION_EXISTS(void);
         ^~~~~~~~~~~~~~~~~~~~~
      Linking C executable cmTC_4b0f4
      /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4b0f4.dir/link.txt --verbose=1
      /home/fabrice/buildroot/output/host/bin/riscv32-linux-gcc --sysroot=/home/fabrice/buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -DCHECK_FUNCTION_EXISTS=__atomic_load_8  -DNDEBUG    CMakeFiles/cmTC_4b0f4.dir/CheckFunctionExists.c.o  -o cmTC_4b0f4  -latomic
      
      Fixes:
       - http://autobuild.buildroot.org/results/2bf06c6a9e55b449ec5875cf9415a9e55b2065d6Signed-off-by: default avatarFabrice Fontaine <fontaine.fabrice@gmail.com>
      718aabba
  3. 16 Aug, 2020 1 commit
  4. 15 Aug, 2020 1 commit
  5. 03 Aug, 2020 1 commit
    • Kip's avatar
      Shared-library soname is now generated correctly (#809) · ab52c549
      Kip authored
      * Add support for interface versioning so applications don't break...
      
      * {CMakeLists.txt,src/CMakeLists.txt}: Shared-library soname is now generated correctly...
      version.txt: Added SONAME major and minor fields...
      README.md: Add versioning notes. In particular, when to update interface version...
      debian/changelog: Fixed lintian complaining about a malformed changelog for non-native package...
      ab52c549
  6. 02 Aug, 2020 1 commit
  7. 22 Jul, 2020 1 commit
  8. 21 Jul, 2020 1 commit
  9. 20 Jul, 2020 1 commit
  10. 18 Jul, 2020 1 commit
  11. 17 Jul, 2020 1 commit
  12. 08 Jul, 2020 1 commit
    • suokko's avatar
      Cmake build improvements for find_package(Pistache) (#795) · 4ed3f8e1
      suokko authored
      * Set default build type using _INIT variable
      
      Language support checking offers a standardized method to set default
      build type using CMAKE_BUILD_TYPE_INIT variable. The variable must be
      set before enable_language is called implicitly from project
      
      * Enable only C++ compiler
      
      * Let C++ compiler detection to check for standard support
      
      Setting CMAKE_CXX_STANDARD variables before implicit call to
      enable_language handles checking for standard support automatically.
      
      * Fix pistache_shared export
      
      Exporting targets allows find_package(Pistache) to import them
      correctly. The import makes it easier to use Pistache in a porject using
      cmake build system.
      
      * Add wildcard ignore for multiple build directories
      
      I used multiple build directories to test different configurations work.
      My alternative test configuration is a Debian Stretch chroot for an old
      distro test.
      
      * Detect Threads which is implicit requirement
      
      Static library requires PistancheConfig.cmake to detect all dependencies
      to allow simple linking to imported library to work.
      
      * Use find_package to detect OpenSSL
      
      Add OpenSSL configure time detection for the development package.
      FindOpenSSL.cmake started support IMPORTED libraries only in 3.4. The
      IMPORTED library helps users to link correctly to pistache static
      library.
      
      Headers use libssl directly which forces pistache to use public
      definition and library link.
      
      * Export include directories to IMPORTED library
      
      * Do not add pistache to global build configuration
      
      PistacheConfig shouldn't add include directories and libraries to the
      global build configuration. Imported libraries provide all required
      build configurations to a depending target.
      
      * Check if atomic library is required
      
      Pistache should link to atomic library only if system requires the
      library. The easiest method appears to be use a modified LLVM
      CheckAtomic helper.
      
      * Use target include directories for GTest
      
      * Detect libcurl and remove pthread linking
      
      * Update CMake Pistache example
      
      * Add CMake ConfigVersion file
      
      * Update the date part of version
      4ed3f8e1
  13. 07 Jul, 2020 1 commit
  14. 05 Jul, 2020 1 commit
  15. 26 Jun, 2020 1 commit
    • chrisvroberts's avatar
      Ensure no epoll events are processed for closed peer files (#788) · 13a92b81
      chrisvroberts authored
      An error existed in transport.cc where it incorrectly assumed that
      it would not receive epoll events relating to a closed peer
      connection. This is not the case because file descriptors can be
      shared between processes e.g. on exec. When they are, events could
      still be generated. The solution is to explicitly de-register our
      interest in the file descriptor before we close it using
      epoll_ctl(EPOLL_CTL_DEL). In addition the call to accept in
      listener.cc has been updated to set CLOEXEC on the peer file
      descriptors as these should not be shared with other processes
      anyway.
      Co-authored-by: default avatarRoberts, Chris (UK Gloucester) <chris.v.roberts@baesystems.com>
      13a92b81
  16. 24 Jun, 2020 1 commit
  17. 23 Jun, 2020 1 commit
  18. 13 Jun, 2020 2 commits
    • Dennis Jenkins's avatar
    • jiankyu's avatar
      Add middleware support (#779) · 059171b1
      jiankyu authored
      This commit partially resolves #24, which is a common requirement on
      many RESTful services.
      
      A vector of middleware handlers is added to Router, these handlers are
      executed before the URL match and handler invocation, in the order of
      registration.
      
      A middleware function has the signature:
      
      bool func(Pistache::Http::Request &request,
                Pistache::Http::ResponseWriter &response);
      
      The first parameter is a reference to Http::Request, not Rest::Request,
      at the moment middlewares are called, the request parameters are not yet
      filled. This allows some generic operation on the request, such as
      authentication or rate limiting.
      
      Parameters are passed as references, to allow the middlewares be able to
      modify them, such as injecting custom headers.
      
      If a function returns true, the next function is executed, until all
      middleware functions are called and all of them return true, the
      registered handler is called.
      
      If one of them returns false, this means there is no need to further
      call the subsequent functions and the handler, the handling of this
      request completes. Typical case is missing auth info or reaching limit.
      Basically, the middleware function that returns false is responsible to
      call response.send() to send the response to client.
      
      Like Route::bind, a new method, Route::middleware(), with different
      signatures, is added, to convert different callables into a middleware.
      
      There is also requirements on the "post-handling" handlers, such as
      logging response, measuring handler latency, and so on, in a centralized
      place. This commit doesn't implement it: The response is passed to
      handler using std::move, it's not retrievable again after handler
      processing.
      Signed-off-by: default avatarJiankun Yu <yujiankun@hotmail.com>
      059171b1
  19. 04 Jun, 2020 1 commit
    • mplellison's avatar
      Separated macro-based logging API from impl, renamed default impl. (#777) · 14ecdf51
      mplellison authored
      The separation of the impl from the API means that it is more possible
      to independently test variations of the API by changing the macro
      definitions in log.h.
      
      The default StringLogger impl is now called StringToStreamLogger, and
      takes an optional ostream pointer on input - this makes it more
      testable. It is assumed that std::cerr will be used here nearly all of
      the time in practice.
      14ecdf51
  20. 03 Jun, 2020 1 commit
    • mplellison's avatar
      Travis fix to collect coredumps from build configuration subdirs - #720 (#776) · 22509199
      mplellison authored
      * Travis fix to collect coredumps from build configuration subdirs - #720
      
      Previously, Travis would only attempt to collect coredumps from the last
      directory the build script was in, or the home directory. This meant
      that most coredumps were missed, and debug information was lost.
      
      The new setup configures apport to watch for crashes on any executables
      (by default it watches for executables from Ubuntu packages). These
      crash dumps are picked up, extracted, and analysed using GDB to provide
      a backtrace (this needs the executable to be passed to GDB as well so
      that debug symbols are provided).
      
      * Restructured .travis.yml to avoid underspecified builds.
      22509199
  21. 29 May, 2020 1 commit
    • mplellison's avatar
      Logging api - addresses issue #771 (#775) · a2215ba9
      mplellison authored
      * Added a basic logger object and relevant macros.
      
      * Modify logging macros for more flexibility.
      
      Supplied logger types and sample values using macros for flexibility in
      recompiling the library against a different logging engine - the macros
      can be redefined to make calls to the relevant functions.
      
      * Updated endpoint and listener to use new logging structure.
      
      It remains to update the SSL portions of listener.cc to output SSL
      errors via the new loggers.
      
      * Add error logging for SSL errors in listener.cc.
      
      This needed an extension to the RAII setup for SSL objects to handle BIO
      objects. Also modified some exception types to ensure they get caught
      and logged by existing code. Moved anonymous function definitions to the
      top of listener.cc so that they are available in the entire file.
      
      These changes don't significantly change the behaviour of the Pistache
      library - it still logs errors and throws an exception for most errors
      that occur internally. It would likely be more sensible to only throw
      a descriptive exception and not log if the exception is expected to be
      handled by the library user - this gives them better control of the
      output of the software. Logging could be reserved for tracking events
      and debug; when the user is not expected to provide input.
      
      * Renamed macros and types to "string logger" and similar.
      
      This aligns the names of the types and macros, as well as leaving space
      for future logging APIs that handle different message types.
      a2215ba9
  22. 26 May, 2020 1 commit
    • mplellison's avatar
      Allow Pistache::Listener to load and serve certificate chains (#772) · 21ca7a69
      mplellison authored
      * Update test certificate generation to use explicit cert config.
      
      Previously, no configuration was supplied on certificate generation, so
      the certificates being used for testing were completely generic. This
      limited the effectiveness and transparency of testing.
      
      * Fix listener.cc to load a cert chain and provide it for server auth.
      
      Added test with a server cert signed by an intermediate CA.
      
      Previously, listener.cc would only load the first cert in a cert pack
      and use this to authenticate itself to clients. This meant that if the
      server held a cert signed by an intermediate CA, a client trusting only
      the root CA would be unable to authenticate the server's cert.
      
      See the OpenSSL docs here:
      https://www.openssl.org/docs/man1.0.2/man3/SSL_CTX_use_certificate_file.html
      for an overview of the SSL_CTX_use_certificate_file() and
      SSL_CTX_use_certificate_chain_file() functions.
      21ca7a69
  23. 21 May, 2020 1 commit
    • robertomdv's avatar
      Update listener.cc (#770) · b4e9e55e
      robertomdv authored
      added GetSSLContext() at line  393 to prevent compilation with OpenSSL From fail  (see issue #769)
      b4e9e55e
  24. 12 May, 2020 4 commits
  25. 11 May, 2020 1 commit
  26. 03 May, 2020 1 commit
  27. 02 May, 2020 1 commit
    • chrisvroberts's avatar
      Fix shutdown data race in listner.cc (#761) · a328d724
      chrisvroberts authored
      A race exists between the runThreaded and shutdown/dtor as follows:
      
       runThreaded - called
       shutdown - called
       shutdown - check for shutdownFd.isBound returns false (so no notify)
       runThreaded - thread executing 'run' starts
       runThreaded - thread calls shutdownFd.bind
       shutdown - blocks waiting for run thread
       runThreaded - continues to run as no notification received
      
      This deadlock avoided by ensuring the shutdownFd.bind is called before
      the thread is created rather than doing it at the start of the thread's
      execution.
      a328d724
  28. 29 Mar, 2020 1 commit
  29. 22 Mar, 2020 1 commit
  30. 16 Mar, 2020 3 commits
  31. 14 Mar, 2020 1 commit
    • miketsts's avatar
      Add -Wconversion compilation flag and fix related warnings (originated by #733) (#734) · 96ee08ec
      miketsts authored
      * CMakeLists.txt: add -Wconversion flag to CMAKE_CXX_CFLAGS
      
      * date.h: fix type conversion warnings
      
      Fix type conversion warnings occurring when using -Wconversion flag
      of gcc
      
      * base64.cc: fix type conversion warnings
      
      Fix type conversion warnings occurring when using -Wconversion flag
      of gcc.
      
      All the fixes actually convert std::byte to unsigned char for
      calculation purposes.
      
      Provided the number of such static_cast uses, I would reconsider using
      std::byte as a base data type, as std::byte is defined as "not a
      character type and is not an arithmetic type ... the only operators
      defined for it are the bitwise ones". At the same time, most of the
      fixes do deal with the arithmetics.
      
      Reference:
      https://en.cppreference.com/w/cpp/types/byte
      
      * Transport: fix type conversion warnings with Fd
      
      Fix type conversion warnings occurring when using -Wconversion flag
      of gcc.
      
      Most of the fixed locations deal with static cast from Polling::Tag
      to Fd.
      
      * stream.cc: fix type conversion warnings
      
      Fix type conversion warnings occurring when using -Wconversion flag
      of gcc.
      
      It appears that std::tolower has two different signatures:
      
      int tolower( int ch );
      and
      template< class charT >
      charT tolower( charT ch, const locale& loc );
      
      This commit doesn't replace the calls to tolower() but merely adds
      static_cast<char> in corresponding locations
      
      * listener.cc: fix type conversion warnings
      
      Fix type conversion warnings occurring when using -Wconversion flag
      of gcc.
      
      * Fix type conversion warnings
      
      Fix type conversion warnings in different files occurring when using
      -Wconversion flag of gcc
      
      * Fix type conversion warnings with OpenSSL
      
      with PISTACHE_USE_SSL
      
      Fix type conversion (size_t -> int) warnings occurring when using
      -Wconversion flag of gcc and PISTACHE_USE_SSL is defined
      
      OpenSSL 1.1.1 has new functions SSL_read_ex / SSL_write_ex which allow
      size_t parameter, but 1.0.2 has only SSL_read / SSL_write with int
      type parameter
      
      * Fix type conversion warnings in examples
      
      Fix type conversion warnings in examples occurring when using
      -Wconversion flag of gcc. The commit contains also
      tests/rest_server_test.cc with the similar fix.
      
      One of questionable change types was caused by
      Http::Endpoint::options()::threads(int val), and was invoked with size_t
      argument. Maybe it makes sense to modify the function argument type.
      
      After this commit, there still remain a lot of -Wconversion warnings in
      rapidjson library
      
      * Fix type conversion warnings in unit tests
      
      Fix type conversion warnings in unit tests occurring when using
      -Wconversion flag of gcc.
      Co-authored-by: default avatarMichael Tseitlin <michael.tseitlin@concertio.com>
      96ee08ec
  32. 10 Mar, 2020 1 commit
  33. 05 Mar, 2020 1 commit
  34. 03 Mar, 2020 1 commit