fixed: ipc client connected event was being wiped out

daemon now communicates graceful shutdown message through new ipc system.
This commit is contained in:
Nick Bolton
2012-07-05 19:10:04 +00:00
parent 3d6551f708
commit ddb2d7feeb
10 changed files with 44 additions and 38 deletions

View File

@@ -121,6 +121,14 @@ CEventQueue::adoptBuffer(IEventQueueBuffer* buffer)
{
CArchMutexLock lock(m_mutex);
LOG((CLOG_DEBUG "adopting new buffer"));
if (m_events.size() != 0) {
// this can come as a nasty surprise to programmers expecting
// their events to be raised, only to have them deleted.
LOG((CLOG_WARN "discarding %d event(s), sorry", m_events.size()));
}
// discard old buffer and old events
delete m_buffer;
for (CEventTable::iterator i = m_events.begin(); i != m_events.end(); ++i) {

View File

@@ -30,7 +30,7 @@ m_server(nullptr)
m_serverAddress.resolve();
EVENTQUEUE->adoptHandler(
m_socket.getConnectedEvent(), &m_socket,
m_socket.getConnectedEvent(), m_socket.getEventTarget(),
new TMethodEventJob<CIpcClient>(
this, &CIpcClient::handleConnected));
}

View File

@@ -45,6 +45,7 @@ CIpcServer::~CIpcServer()
for (it = m_clients.begin(); it != m_clients.end(); it++) {
delete *it;
}
m_clients.empty();
EVENTQUEUE->removeHandler(m_socket.getConnectingEvent(), &m_socket);
}

View File

@@ -437,7 +437,8 @@ CMSWindowsRelauncher::shutdownProcess(const PROCESS_INFORMATION& pi, int timeout
{
GetExitCodeProcess(pi.hProcess, &exitCode);
if (exitCode != STILL_ACTIVE) {
LOG((CLOG_INFO "process %d was shutdown successfully", pi.dwProcessId));
// yay, we got a graceful shutdown. there should be no hook in use errors!
LOG((CLOG_INFO "process %d was shutdown gracefully", pi.dwProcessId));
break;
}
else {

View File

@@ -221,6 +221,8 @@ CDaemonApp::mainLoop(bool logToFile)
eventQueue.removeHandler(
CIpcServer::getClientConnectedEvent(), m_ipcServer);
CLOG->remove(m_ipcLogOutputter);
delete m_ipcLogOutputter;
delete m_ipcServer;
DAEMON_RUNNING(false);
@@ -278,8 +280,6 @@ void
CDaemonApp::handleIpcMessage(const CEvent& e, void*)
{
CIpcMessage& m = *static_cast<CIpcMessage*>(e.getData());
LOG((CLOG_DEBUG "ipc message, type=%d", m.m_type));
switch (m.m_type) {
case kIpcCommand: {
CString& command = *static_cast<CString*>(m.m_data);
@@ -300,9 +300,5 @@ CDaemonApp::handleIpcMessage(const CEvent& e, void*)
m_relauncher->command(command);
}
break;
default:
LOG((CLOG_ERR "ipc message not supported, type=%d", m.m_type));
break;
}
}

View File

@@ -760,15 +760,6 @@ CServerApp::mainLoop()
// create the event queue
CEventQueue eventQueue;
/*
bool a = true;
while (a) {
ARCH->sleep(1);
}*/
if (argsBase().m_enableIpc) {
initIpcClient();
}
// if configuration has no screens then add this system
// as the default
@@ -795,6 +786,12 @@ CServerApp::mainLoop()
// start server, etc
appUtil().startNode();
// init ipc client after node start, since create a new screen wipes out
// the event queue (the screen ctors call adoptBuffer).
if (argsBase().m_enableIpc) {
initIpcClient();
}
// load all available plugins.
ARCH->plugin().init(s_serverScreen->getEventTarget());