void ServiceIPCEventHandler::ChannelClosed(ChannelHandlerContext& ctx, ChannelStateEvent& e) { Channel* ch = ctx.GetChannel(); Address* addr = const_cast<Address*>(ch->GetRemoteAddress()); Address* localaddr = const_cast<Address*>(ch->GetLocalAddress()); if (NULL != addr && InstanceOf<SocketUnixAddress>(addr).OK) { SocketUnixAddress* un = (SocketUnixAddress*) addr; SocketUnixAddress* un1 = (SocketUnixAddress*) localaddr; DEBUG_LOG( "Local %s Closed %s", un1->GetPath().c_str(), un->GetPath().c_str()); if (m_service->GetManagerProcess()->IsManagerIPCUnixSocketServer( un->GetPath())) { m_service->SetIPCUnixSocket(NULL); } else if (m_service->GetManagerProcess()->IsManagerCtrlUnixSocketServer( un->GetPath())) { m_service->SetCtrlChannel(NULL); } else { GetServiceProcess()->AddClosedDispatcherIPCChannel(ch); VirtualChannelHelper::ClearTable(ch); } } }
void ServiceIPCEventHandler::ChannelConnected(ChannelHandlerContext& ctx, ChannelStateEvent& e) { Channel* ch = ctx.GetChannel(); Address* addr = const_cast<Address*>(ch->GetRemoteAddress()); Address* localaddr = const_cast<Address*>(ch->GetLocalAddress()); if (NULL != addr && InstanceOf<SocketUnixAddress>(addr).OK) { SocketUnixAddress* un = (SocketUnixAddress*) addr; SocketUnixAddress* un1 = (SocketUnixAddress*) localaddr; DEBUG_LOG( "Local %s Connected %s", un1->GetPath().c_str(), un->GetPath().c_str()); if (m_service->GetManagerProcess()->IsManagerCtrlUnixSocketServer( un->GetPath())) { ch->DetachFD(); ch->SetIOEventCallback( VirtualChannelHelper::CtrlChannelIOEventCallback, AE_READABLE, ch); // make_fd_blocking(ch->GetReadFD()); } } }