X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin4_src%2FServer%2FCIPCChannel_AcessIPCPipe.cpp;h=0d894e3d25c9ccab0386e28780cb6097a9bee2b6;hb=8b72370eae1a3cfa8916136fd8ffc1460e9291ba;hp=183253b86de4649fa76663e6fa67f8e724800e51;hpb=8ae0b1147e613573a45fcd8e6f2f6af2aeff54ac;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin4_src/Server/CIPCChannel_AcessIPCPipe.cpp b/Usermode/Applications/axwin4_src/Server/CIPCChannel_AcessIPCPipe.cpp index 183253b8..0d894e3d 100644 --- a/Usermode/Applications/axwin4_src/Server/CIPCChannel_AcessIPCPipe.cpp +++ b/Usermode/Applications/axwin4_src/Server/CIPCChannel_AcessIPCPipe.cpp @@ -30,13 +30,11 @@ CIPCChannel_AcessIPCPipe::~CIPCChannel_AcessIPCPipe() int CIPCChannel_AcessIPCPipe::FillSelect(fd_set& rfds) { - _SysDebug("CIPCChannel_AcessIPCPipe::FillSelect"); int maxfd = m_fd; FD_SET(m_fd, &rfds); for( auto& clientref : m_clients ) { - _SysDebug("CIPCChannel_AcessIPCPipe::FillSelect - FD%i", clientref.m_fd); maxfd = ::std::max(maxfd, clientref.m_fd); FD_SET(clientref.m_fd, &rfds); } @@ -46,22 +44,25 @@ int CIPCChannel_AcessIPCPipe::FillSelect(fd_set& rfds) void CIPCChannel_AcessIPCPipe::HandleSelect(const fd_set& rfds) { - _SysDebug("CIPCChannel_AcessIPCPipe::HandleSelect"); if( FD_ISSET(m_fd, &rfds) ) { - _SysDebug("CIPCChannel_AcessIPCPipe::HandleSelect - New client on FD %i", m_fd); int newfd = _SysOpenChild(m_fd, "newclient", OPENFLAG_READ|OPENFLAG_WRITE); - _SysDebug("newfd = %i", newfd); - - // emplace creates a new object within the list - m_clients.emplace( m_clients.end(), *this, newfd ); - IPC::RegisterClient( m_clients.back() ); + if( newfd == -1 ) { + _SysDebug("ERROR - Failure to open new client on FD%i", m_fd); + } + else { + _SysDebug("CIPCChannel_AcessIPCPipe::HandleSelect - New client on FD %i with FD%i", + m_fd, newfd); + + // emplace creates a new object within the list + m_clients.emplace( m_clients.end(), *this, newfd ); + IPC::RegisterClient( m_clients.back() ); + } } for( auto it = m_clients.begin(); it != m_clients.end(); ) { CClient_AcessIPCPipe& clientref = *it; - _SysDebug("CIPCChannel_AcessIPCPipe::HandleSelect - Trying FD%i", clientref.m_fd); ++ it; if( FD_ISSET(clientref.m_fd, &rfds) ) @@ -70,21 +71,19 @@ void CIPCChannel_AcessIPCPipe::HandleSelect(const fd_set& rfds) clientref.HandleReceive(); } catch( const ::std::exception& e ) { - _SysDebug("ERROR - Exception processing IPCPipe FD%i: %s", + _SysDebug("ERROR - Exception processing IPCPipe FD%i: '%s', removing", clientref.m_fd, e.what() ); it = m_clients.erase(--it); } } } - _SysDebug("CIPCChannel_AcessIPCPipe::HandleSelect - END"); } CClient_AcessIPCPipe::CClient_AcessIPCPipe(::AxWin::IIPCChannel& channel, int fd): CClient(channel), - m_fd(fd), - m_rxbuf(0x1000) + m_fd(fd) { } @@ -99,17 +98,22 @@ void CClient_AcessIPCPipe::SendMessage(CSerialiser& message) const ::std::vector& data = message.Compact(); _SysDebug("CClient_AcessIPCPipe::SendMessage - %i bytes to %i", data.size(), m_fd); + //_SysDebugHex("CClient_AcessIPCPipe::SendMessage", data.data(), data.size()); _SysWrite(m_fd, data.data(), data.size()); } void CClient_AcessIPCPipe::HandleReceive() { - size_t len = _SysRead(m_fd, &m_rxbuf[0], m_rxbuf.capacity()); + ::std::vector rxbuf(0x1000); + size_t len = _SysRead(m_fd, rxbuf.data(), rxbuf.capacity()); if( len == (size_t)-1 ) throw ::std::system_error(errno, ::std::system_category()); + _SysDebug("CClient_AcessIPCPipe::HandleReceive - Rx %i/%i bytes", len, rxbuf.capacity()); + //_SysDebugHex("CClient_AcessIPCPipe::HandleReceive", rxbuf.data(), len); + rxbuf.resize(len); - CDeserialiser message(len, &m_rxbuf[0]); - CClient::HandleMessage(message); + CDeserialiser msg( ::std::move(rxbuf) ); + CClient::HandleMessage( msg ); } };