Fix race condition in monitor_connect_thread

Add wait loop for GloMTH initialization before accessing variables.
Other monitor threads (MonitorPing, MonitorReadOnly, etc.) already had
this pattern, but monitor_connect_thread was missing it.

This fixes Valgrind errors about uninitialized values in
get_variable_uint16() when strcasecmp reads from memory that hasn't
been fully initialized yet.
v3.0-test0213
Rene Cannao 6 days ago
parent 09d0dcb808
commit f4cd34be5c

@ -1339,6 +1339,11 @@ void * monitor_connect_thread(const std::vector<MySQL_Monitor_State_Data*>& mmsd
assert(!mmsds.empty());
mysql_close(mysql_init(NULL));
MySQL_Monitor_State_Data *mmsd = mmsds.front();
// Wait for GloMTH to be initialized
while (GloMTH==NULL) {
usleep(50000);
}
usleep(100000);
if (!GloMTH) return NULL; // quick exit during shutdown/restart
MySQL_Thread * mysql_thr = new MySQL_Thread();
mysql_thr->curtime=monotonic_time();

Loading…
Cancel
Save