Debian Codegraph @

storage/innobase/include/srv0mon.ic

raw
1 /*****************************************************************************
2
3 Copyright (c) 2010, 2026, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20 for more details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26 *****************************************************************************/
27
28 /** @file include/srv0mon.ic
29 Server monitoring system
30
31 Created 1/20/2010 Jimmy Yang
32 ************************************************************************/
33
34 /** This function is used to calculate the maximum counter value
35 since the start of monitor counter
36 @return max counter value since start. */
37 static inline mon_type_t srv_mon_calc_max_since_start(
38 monitor_id_t monitor) /*!< in: monitor id */
39 {
40 if (MONITOR_MAX_VALUE_START(monitor) == MAX_RESERVED) {
41 /* MONITOR_MAX_VALUE_START has not yet been
42 initialized, the max value since start is the
43 max count in MONITOR_MAX_VALUE */
44 MONITOR_MAX_VALUE_START(monitor) = MONITOR_MAX_VALUE(monitor);
45
46 } else if (MONITOR_MAX_VALUE(monitor) != MAX_RESERVED &&
47 (MONITOR_MAX_VALUE(monitor) + MONITOR_VALUE_RESET(monitor) >
48 MONITOR_MAX_VALUE_START(monitor))) {
49 /* If the max value since reset (as specified
50 in MONITOR_MAX_VALUE) plus the reset value is
51 larger than MONITOR_MAX_VALUE_START, reset
52 MONITOR_MAX_VALUE_START to this new max value */
53 MONITOR_MAX_VALUE_START(monitor) =
54 MONITOR_MAX_VALUE(monitor) + MONITOR_VALUE_RESET(monitor);
55 }
56
57 return (MONITOR_MAX_VALUE_START(monitor));
58 }
59
60 /** This function is used to calculate the minimum counter value
61 since the start of monitor counter
62 @return min counter value since start. */
63 static inline mon_type_t srv_mon_calc_min_since_start(
64 monitor_id_t monitor) /*!< in: monitor id */
65 {
66 if (MONITOR_MIN_VALUE_START(monitor) == MIN_RESERVED) {
67 /* MONITOR_MIN_VALUE_START has not yet been
68 initialized, the min value since start is the
69 min count in MONITOR_MIN_VALUE */
70 MONITOR_MIN_VALUE_START(monitor) = MONITOR_MIN_VALUE(monitor);
71
72 } else if (MONITOR_MIN_VALUE(monitor) != MIN_RESERVED &&
73 (MONITOR_MIN_VALUE(monitor) + MONITOR_VALUE_RESET(monitor) <
74 MONITOR_MIN_VALUE_START(monitor))) {
75 /* If the min value since reset (as specified
76 in MONITOR_MIN_VALUE) plus the reset value is
77 less than MONITOR_MIN_VALUE_START, reset
78 MONITOR_MIN_VALUE_START to this new min value */
79 MONITOR_MIN_VALUE_START(monitor) =
80 MONITOR_MIN_VALUE(monitor) + MONITOR_VALUE_RESET(monitor);
81 }
82
83 return (MONITOR_MIN_VALUE_START(monitor));
84 }
85
86 /** This function resets all values of a monitor counter */
87 static inline void srv_mon_reset_all(
88 monitor_id_t monitor) /*!< in: monitor id */
89 {
90 /* Do not reset all counter values if monitor is still on. */
91 if (MONITOR_IS_ON(monitor)) {
92 fprintf(stderr,
93 "InnoDB: Cannot reset all values for"
94 " monitor counter %s while it is on. Please"
95 " turn it off and retry.\n",
96 srv_mon_get_name(monitor));
97 } else {
98 MONITOR_RESET_ALL(monitor);
99 }
100 }