/src/trafficserver/include/tscore/TSSystemState.h
Line | Count | Source |
1 | | /** |
2 | | @file TSSystemState.h |
3 | | |
4 | | @section license License |
5 | | |
6 | | Licensed to the Apache Software Foundation (ASF) under one |
7 | | or more contributor license agreements. See the NOTICE file |
8 | | distributed with this work for additional information |
9 | | regarding copyright ownership. The ASF licenses this file |
10 | | to you under the Apache License, Version 2.0 (the |
11 | | "License"); you may not use this file except in compliance |
12 | | with the License. You may obtain a copy of the License at |
13 | | |
14 | | http://www.apache.org/licenses/LICENSE-2.0 |
15 | | |
16 | | Unless required by applicable law or agreed to in writing, software |
17 | | distributed under the License is distributed on an "AS IS" BASIS, |
18 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
19 | | See the License for the specific language governing permissions and |
20 | | limitations under the License. |
21 | | |
22 | | */ |
23 | | |
24 | | #pragma once |
25 | | |
26 | | #include <tscore/ink_assert.h> |
27 | | #include <tscore/ink_defs.h> |
28 | | |
29 | | // Global status information for trafficserver |
30 | | // |
31 | | class TSSystemState |
32 | | { |
33 | | private: |
34 | | struct Data { |
35 | | bool initializing = true; |
36 | | bool ssl_handshaking_stopped = false; |
37 | | bool event_system_shut_down = false; |
38 | | bool draining = false; |
39 | | }; |
40 | | |
41 | | public: |
42 | | static bool |
43 | | is_initializing() |
44 | 0 | { |
45 | 0 | return unlikely(_instance().initializing); |
46 | 0 | } |
47 | | |
48 | | static bool |
49 | | is_ssl_handshaking_stopped() |
50 | 0 | { |
51 | 0 | return unlikely(_instance().ssl_handshaking_stopped); |
52 | 0 | } |
53 | | |
54 | | static bool |
55 | | is_event_system_shut_down() |
56 | 1 | { |
57 | 1 | return unlikely(_instance().event_system_shut_down); |
58 | 1 | } |
59 | | |
60 | | // Keeps track if the server is in draining state, follows the proxy.process.proxy.draining metric. |
61 | | // |
62 | | static bool |
63 | | is_draining() |
64 | 0 | { |
65 | 0 | return unlikely(_instance().draining); |
66 | 0 | } |
67 | | |
68 | | static void |
69 | | initialization_done() |
70 | 0 | { |
71 | 0 | ink_assert(_instance().initializing); |
72 | 0 |
|
73 | 0 | _instance().initializing = false; |
74 | 0 | } |
75 | | |
76 | | static void |
77 | | stop_ssl_handshaking() |
78 | 0 | { |
79 | 0 | ink_assert(!_instance().ssl_handshaking_stopped); |
80 | 0 |
|
81 | 0 | _instance().ssl_handshaking_stopped = true; |
82 | 0 | } |
83 | | |
84 | | static void |
85 | | shut_down_event_system() |
86 | 0 | { |
87 | 0 | // For some reason this is triggered by the regression testing. |
88 | 0 | // ink_assert(_instance().ssl_handshaking_stopped && !_instance().event_system_shut_down); |
89 | 0 |
|
90 | 0 | _instance().event_system_shut_down = true; |
91 | 0 | } |
92 | | |
93 | | static void |
94 | | drain(bool enable) |
95 | 0 | { |
96 | 0 | _instance().draining = enable; |
97 | 0 | } |
98 | | |
99 | | private: |
100 | | static Data & |
101 | | _instance() |
102 | 1 | { |
103 | 1 | static Data d; |
104 | | |
105 | 1 | return d; |
106 | 1 | } |
107 | | }; |