diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2004-12-13 13:43:28 +0100 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2004-12-13 13:43:28 +0100 |
commit | ca4d47dc086902c109259cc6e870a63616ed5c59 (patch) | |
tree | 7df4cf63d252799d556aaae55c4a728b1533003e /ndb/src | |
parent | be19c6f72109d8ffd3adbee84a1289ad05bcf14f (diff) | |
download | mariadb-git-ca4d47dc086902c109259cc6e870a63616ed5c59.tar.gz |
fixed event thread for better error handling
Diffstat (limited to 'ndb/src')
-rw-r--r-- | ndb/src/mgmclient/CommandInterpreter.cpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index a169d21f97c..0c7fe642e54 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -465,6 +465,7 @@ event_thread_run(void* m) int fd = ndb_mgm_listen_event(handle, filter); if (fd > 0) { + do_event_thread= 1; char *tmp= 0; char buf[1024]; SocketInputStream in(fd,10); @@ -474,6 +475,10 @@ event_thread_run(void* m) ndbout << tmp; } while(do_event_thread); } + else + { + do_event_thread= -1; + } my_thread_end(); NdbThread_Exit(0); @@ -494,24 +499,38 @@ CommandInterpreter::connect() && !ndb_mgm_connect(m_mgmsrv2, try_reconnect-1, 5, 1)) { - m_connected= true; - if (m_verbose) + assert(m_event_thread == 0); + assert(do_event_thread == 0); + do_event_thread= 0; + m_event_thread = NdbThread_Create(event_thread_run, + (void**)&m_mgmsrv2, + 32768, + "CommandInterpreted_event_thread", + NDB_THREAD_PRIO_LOW); + if (m_event_thread != 0) { - printf("Connected to Management Server at: %s:%d\n", - host, port); + int iter= 1000; // try for 30 seconds + while(do_event_thread == 0 && + iter-- > 0) + NdbSleep_MilliSleep(30); } + if (m_event_thread == 0 || + do_event_thread == 0 || + do_event_thread == -1) { - do_event_thread= 1; - m_event_thread = NdbThread_Create(event_thread_run, - (void**)&m_mgmsrv2, - 32768, - "CommandInterpreted_event_thread", - NDB_THREAD_PRIO_LOW); + printf("Warning, event thread startup failed, degraded printouts as result\n"); + do_event_thread= 0; } } else { - ndb_mgm_disconnect(m_mgmsrv); + printf("Warning, event connect failed, degraded printouts as result\n"); + } + m_connected= true; + if (m_verbose) + { + printf("Connected to Management Server at: %s:%d\n", + host, port); } } } |