Commit ca4d47dc authored by unknown's avatar unknown

fixed event thread for better error handling

parent be19c6f7
...@@ -465,6 +465,7 @@ event_thread_run(void* m) ...@@ -465,6 +465,7 @@ event_thread_run(void* m)
int fd = ndb_mgm_listen_event(handle, filter); int fd = ndb_mgm_listen_event(handle, filter);
if (fd > 0) if (fd > 0)
{ {
do_event_thread= 1;
char *tmp= 0; char *tmp= 0;
char buf[1024]; char buf[1024];
SocketInputStream in(fd,10); SocketInputStream in(fd,10);
...@@ -474,6 +475,10 @@ event_thread_run(void* m) ...@@ -474,6 +475,10 @@ event_thread_run(void* m)
ndbout << tmp; ndbout << tmp;
} while(do_event_thread); } while(do_event_thread);
} }
else
{
do_event_thread= -1;
}
my_thread_end(); my_thread_end();
NdbThread_Exit(0); NdbThread_Exit(0);
...@@ -494,24 +499,38 @@ CommandInterpreter::connect() ...@@ -494,24 +499,38 @@ CommandInterpreter::connect()
&& &&
!ndb_mgm_connect(m_mgmsrv2, try_reconnect-1, 5, 1)) !ndb_mgm_connect(m_mgmsrv2, try_reconnect-1, 5, 1))
{ {
m_connected= true; assert(m_event_thread == 0);
if (m_verbose) assert(do_event_thread == 0);
{ do_event_thread= 0;
printf("Connected to Management Server at: %s:%d\n",
host, port);
}
{
do_event_thread= 1;
m_event_thread = NdbThread_Create(event_thread_run, m_event_thread = NdbThread_Create(event_thread_run,
(void**)&m_mgmsrv2, (void**)&m_mgmsrv2,
32768, 32768,
"CommandInterpreted_event_thread", "CommandInterpreted_event_thread",
NDB_THREAD_PRIO_LOW); NDB_THREAD_PRIO_LOW);
if (m_event_thread != 0)
{
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)
{
printf("Warning, event thread startup failed, degraded printouts as result\n");
do_event_thread= 0;
} }
} }
else 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);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment