1 /* Copyright (c) 2016, 2021, Oracle and/or its affiliates. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software Foundation, 21 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 22 23 #ifndef DELAYED_PLUGIN_INITIALIZATION_INCLUDE 24 #define DELAYED_PLUGIN_INITIALIZATION_INCLUDE 25 26 #include "read_mode_handler.h" 27 28 class Delayed_initialization_thread 29 { 30 31 public: 32 33 Delayed_initialization_thread(); 34 35 /** 36 The class destructor 37 */ 38 ~Delayed_initialization_thread(); 39 40 /** 41 The thread handler. 42 43 @return 44 @retval 0 OK 45 @retval !=0 Error 46 */ 47 int initialization_thread_handler(); 48 49 /** 50 Initialize a thread where the plugin services will be initialized 51 52 @return the operation status 53 @retval 0 OK 54 @retval !=0 Error 55 */ 56 int launch_initialization_thread(); 57 58 /** 59 Signals the plugin initialization thread that the server is ready. 60 */ 61 void signal_thread_ready(); 62 63 /** 64 Wait for the initialization thread to do its job. 65 */ 66 void wait_for_thread_end(); 67 68 /** 69 Signal that the read mode is set on the server. 70 */ 71 void signal_read_mode_ready(); 72 73 /** 74 Wait for the read mode to be set by the thread process. 75 */ 76 void wait_for_read_mode(); 77 78 private: 79 80 //Delayed_initialization_thread variables 81 82 /* Is the thread running */ 83 bool thread_running; 84 85 /* Is the server ready*/ 86 bool is_server_ready; 87 88 /* Is the read mode already set*/ 89 bool is_super_read_only_set; 90 91 /* Thread related structures */ 92 93 my_thread_handle delayed_init_pthd; 94 //run conditions and locks 95 mysql_mutex_t run_lock; 96 mysql_cond_t run_cond; 97 mysql_mutex_t server_ready_lock; 98 mysql_cond_t server_ready_cond; 99 }; 100 101 #endif /* DELAYED_PLUGIN_INITIALIZATION_INCLUDE */ 102