File: wsrep_status.cc

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (60 lines) | stat: -rw-r--r-- 1,925 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* Copyright 2021 Codership Oy <info@codership.com>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */

#include "wsrep_status.h"

mysql_mutex_t LOCK_wsrep_status;

#ifdef HAVE_PSI_INTERFACE
PSI_mutex_key key_LOCK_wsrep_status;
#endif

Wsrep_mutex*     Wsrep_status::m_mutex    = 0;
wsrep::reporter* Wsrep_status::m_instance = 0;

void Wsrep_status::report_log_msg(wsrep::reporter::log_level const level,
                                  const char* const tag, size_t const tag_len,
                                  const char* const buf, size_t const buf_len,
                                  double const tstamp)
{
  if (!Wsrep_status::m_instance) return;

  Wsrep_status::m_instance->report_log_msg(level,
    std::string(tag, tag_len) + std::string(buf, buf_len),
    tstamp);
}

void Wsrep_status::init_once(const std::string& file_name)
{
  if (file_name.length() > 0 && m_instance == 0)
  {
    mysql_mutex_init(key_LOCK_wsrep_status, &LOCK_wsrep_status,
                     MY_MUTEX_INIT_FAST);
    m_mutex    = new Wsrep_mutex(&LOCK_wsrep_status);
    m_instance = new wsrep::reporter(*m_mutex, file_name, 4);
  }
}

void Wsrep_status::destroy()
{
  if (m_instance)
  {
    delete m_instance;
    m_instance= 0;
    delete m_mutex;
    m_mutex= 0;
    mysql_mutex_destroy(&LOCK_wsrep_status);
  }
}