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 ssl_handshaking_stopped; 36 bool event_system_shut_down; 37 bool draining; 38 }; 39 40 public: 41 static bool is_ssl_handshaking_stopped()42 is_ssl_handshaking_stopped() 43 { 44 return unlikely(_instance().ssl_handshaking_stopped); 45 } 46 47 static bool is_event_system_shut_down()48 is_event_system_shut_down() 49 { 50 return unlikely(_instance().event_system_shut_down); 51 } 52 53 // Keeps track if the server is in draining state, follows the proxy.node.config.draining metric. 54 // 55 static bool is_draining()56 is_draining() 57 { 58 return unlikely(_instance().draining); 59 } 60 61 static void stop_ssl_handshaking()62 stop_ssl_handshaking() 63 { 64 ink_assert(!_instance().ssl_handshaking_stopped); 65 66 _instance().ssl_handshaking_stopped = true; 67 } 68 69 static void shut_down_event_system()70 shut_down_event_system() 71 { 72 // For some reason this is triggered by the regression testing. 73 // ink_assert(_instance().ssl_handshaking_stopped && !_instance().event_system_shut_down); 74 75 _instance().event_system_shut_down = true; 76 } 77 78 static void drain(bool enable)79 drain(bool enable) 80 { 81 _instance().draining = enable; 82 } 83 84 private: 85 static Data & _instance()86 _instance() 87 { 88 static Data d; 89 90 return d; 91 } 92 }; 93