Skip to content
Snippets Groups Projects
  1. Oct 31, 2022
    • Nikolay Shirokovskiy's avatar
      app: fix crash on logrotate and immediate exit · 99de5b74
      Nikolay Shirokovskiy authored
      `say_logrotate` does not rotate logs synchronously. It posts tasks to
      coio which executes them in it's pool thread. On application exit we
      destroy logs calling `log_destroy`. This function waits for rotate task
      to finish because if it will free resources immediately then unfinished
      rotate task can have use-after-free issues. Waiting crashes because at
      this moment event loop is not running which is required for
      `fiber_cond_wait` to work.
      
      Note that if there is no crash then we will hang forever waiting in
      `log_destroy` because event loop is not running and
      `log_rotate_async_cb` will never be executed.
      
      Let's use mutexes and conditions instead. It solves both problems with
      crash and hang. Thanks Vladimir Davydov for idea.
      
      Fixes #4450
      
      NO_DOC=bugfix
      
      (cherry picked from commit eed09192)
      99de5b74
  2. Sep 12, 2022
    • Vladimir Davydov's avatar
      Use MT-Safe strerror_r instead of strerror · 03ceaafc
      Vladimir Davydov authored
      strerror() is MT-Unsafe, because it uses a static buffer under the hood.
      We should use strerror_r() instead, which takes a user-provided buffer.
      The problem is there are two implementations of strerror_r(): XSI and
      GNU. The first one returns an error code and always writes the message
      to the beginning of the buffer while the second one returns a pointer to
      a location within the buffer where the message starts. Let's introduce a
      macro HAVE_STRERROR_R_GNU set if the GNU version is available and define
      tt_strerror() which writes the message to the static buffer, like
      tt_cstr() or tt_sprintf().
      
      Note, we have to export tt_strerror(), because it is used by Lua via
      FFI. We also need to make it available in the module API header, because
      the say_syserror() macro uses strerror() directly. In order to avoid
      adding tt_strerror() to the module API, we introduce an internal helper
      function _say_strerror(), which calls tt_strerror().
      
      NO_DOC=bug fix
      NO_TEST=code is covered by existing tests
      
      (cherry picked from commit 44f46dc8)
      03ceaafc
  3. Sep 22, 2018
  4. Apr 05, 2018
    • Ilya Markov's avatar
      log: Fix syslog logger · 7c7a2fa1
      Ilya Markov authored
      * Remove rewriting format of default logger in case of syslog option.
      * Add facility option parsing and use parsed results in format message
        according to RFC3164. Possible values and default value of syslog
        facility are taken from nginx (https://nginx.ru/en/docs/syslog.html)
      * Move initialization of logger type and format fucntion before
        initialization of descriptor in log_XXX_init, so that we can test
        format function of syslog logger.
      
      Closes gh-3244.
      7c7a2fa1
  5. Mar 29, 2018
    • Ilya Markov's avatar
      say: Fix log_rotate · 26a4effe
      Ilya Markov authored
      * Refactor tests.
      * Add ev_async and fiber_cond for thread-safe log_rotate usage.
      
      Follow up #3015
      26a4effe
  6. Mar 20, 2018
    • Konstantin Belyavskiy's avatar
      [FreeBSD] Fix FreeBSD build · 0f965db5
      Konstantin Belyavskiy authored
      Under FreeBSD getline prototype is not provided by
      default due to compatibility problems.
      Get rid of getline (use fgets instead).
      Based on @locker proposal.
      
      Closes #3217.
      0f965db5
  7. Mar 13, 2018
    • IlyaMarkovMipt's avatar
      say: Wrap logrotate signal handler with ev_signal · 9f99bc62
      IlyaMarkovMipt authored
      Current log rotation is not async signal safe.
      In order to make it so refactor signal handling
      with ev_signal.
      
      Log rotation for each logger performs in separate
      coio_task to provide async and thread-safe execution.
      
      Relates #3015
      9f99bc62
  8. Dec 21, 2017
    • Ilya's avatar
      say: fix format functions · 3c61cd03
      Ilya authored
      * Add check on NULL filename in format functions
      * The need of this fix was inspired by possible need of custom loggers
      which want to reuse our format functions
      3c61cd03
    • Ilya's avatar
      say: Add several loggers support · 6d7437da
      Ilya authored
      * Add struct log
      * Add possibility to add logger configuration to global scope
      * Refactor functions in say to use them with specified config,
       not only global variable
      
       This patch was inspired by need of additional logger in audit log
       Relates #2912
      6d7437da
    • Ilya's avatar
      say: Refactor system error processing · f59ac234
      Ilya authored
      * Pull error processing from functions say_XXX_init(file, pipe, sys)
      to say_log_init
      * Remove error processing with passing point error
      message as an argument
      * Add new exception IllegalParameters
      f59ac234
  9. Oct 12, 2017
  10. Jan 10, 2017
  11. Nov 09, 2015
Loading