diff --git a/src/gui/server/requestmanager.cpp b/src/gui/server/requestmanager.cpp index 436906d9fac4d2031977c841cab8c1d1475ce119..f789a84b68e26a6d23160d6dc360e9fa9d281ec8 100644 --- a/src/gui/server/requestmanager.cpp +++ b/src/gui/server/requestmanager.cpp @@ -76,6 +76,7 @@ RequestManager::exec() { // session mutex block _debug("Closing TCP Session... \n"); _sessionMutex.enterMutex(); + if (_sessionIO) _sessionIO->sendLast(); delete _sessionIO; _sessionIO = NULL; _sessionMutex.leaveMutex(); _debug("TCP Session has closed\n"); diff --git a/src/gui/server/sessionio.h b/src/gui/server/sessionio.h index 0edb9a149f3c4a3e16194a271240a8983c7562f3..4483f2d566a275367202d13ab1ad31f75a1f654f 100644 --- a/src/gui/server/sessionio.h +++ b/src/gui/server/sessionio.h @@ -32,6 +32,7 @@ public: virtual ~SessionIO(); virtual void send(const std::string& response) = 0; + virtual void sendLast() = 0; virtual bool receive(std::string& request) = 0; virtual bool good() = 0; virtual void init() = 0; diff --git a/src/gui/server/tcpsessionio.cpp b/src/gui/server/tcpsessionio.cpp index eae54d1bbb877018cd9fb76a2ae9d66ee076e3a4..8d7559e9cf67833c2d8bf7dd94226b547617e505 100644 --- a/src/gui/server/tcpsessionio.cpp +++ b/src/gui/server/tcpsessionio.cpp @@ -61,6 +61,13 @@ TCPSessionIO::send(const std::string& response) _clientStream->send(response); } } +void +TCPSessionIO::sendLast() +{ + if (_clientStream) { + _clientStream->sendLast(); + } +} bool TCPSessionIO::receive(std::string& request) diff --git a/src/gui/server/tcpsessionio.h b/src/gui/server/tcpsessionio.h index 1a2772592ca973922c589662e2d944fe8a117145..17a7ace689d9d657cef20e1d452ef5390883d082 100644 --- a/src/gui/server/tcpsessionio.h +++ b/src/gui/server/tcpsessionio.h @@ -33,6 +33,7 @@ public: ~TCPSessionIO(); void send(const std::string& response); + void sendLast(); bool receive(std::string& request); bool good(); void init(); diff --git a/src/gui/server/tcpstreampool.cpp b/src/gui/server/tcpstreampool.cpp index b3fd59546817d191567d6e0520a64008300fd437..89670835f34338ecdfe6de0d858fa0d60b8afeea 100644 --- a/src/gui/server/tcpstreampool.cpp +++ b/src/gui/server/tcpstreampool.cpp @@ -26,15 +26,8 @@ TCPStreamPool::~TCPStreamPool() _debug("TCPStreamPool terminate\n"); terminate(); _debug("terminate done\n"); - - - std::string output; - while (_outputPool.pop(output, WAITING_TIME)) { - _debug("TCPStreamPool send %s\n", output.c_str()); - //_debug("sending last message...\n"); - *this << output << std::endl; - } } + void TCPStreamPool::run() { std::string output; @@ -45,15 +38,15 @@ TCPStreamPool::run() { while(!testCancel() && good()) { while (isPending(ost::TCPSocket::pendingInput, WAITING_TIME)) { std::getline(*this, input); - _debug("TCPStreamPool getline %s\n", input.c_str()); + //_debug("TCPStreamPool getline %s\n", input.c_str()); if (input != null && input[0]!=cr13) { _inputPool.push(input); } // security check, since we are inside a loop if (testCancel() || !good()) {break;} } - if (good() && _outputPool.pop(output, WAITING_TIME)) { - _debug("TCPStreamPool send %s\n", output.c_str()); + if (_outputPool.pop(output, WAITING_TIME)) { + //_debug("TCPStreamPool send %s\n", output.c_str()); *this << output << std::endl; } } @@ -62,9 +55,16 @@ TCPStreamPool::run() { void TCPStreamPool::send(const std::string& response) { - if (!testCancel()) { - _outputPool.push(response); - } + _outputPool.push(response); +} +void +TCPStreamPool::sendLast() { + std::string output; + while (good() && _outputPool.pop(output, WAITING_TIME)) { + _debug("TCPStreamPool send last %s\n", output.c_str()); + //_debug("sending last message...\n"); + *this << output << std::endl; + } } bool diff --git a/src/gui/server/tcpstreampool.h b/src/gui/server/tcpstreampool.h index 3c7420ee0f8b008988b117fd5b3b701991d0b8c8..4a94b882a74a80b73ec0049e85454824d5d7e23b 100644 --- a/src/gui/server/tcpstreampool.h +++ b/src/gui/server/tcpstreampool.h @@ -47,6 +47,7 @@ public: void run(); void send(const std::string& response); + void sendLast(); bool receive(std::string& request); private: