mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
Try a new method to handle last message, should test at job..
This commit is contained in:
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
~TCPSessionIO();
|
||||
|
||||
void send(const std::string& response);
|
||||
void sendLast();
|
||||
bool receive(std::string& request);
|
||||
bool good();
|
||||
void init();
|
||||
|
@ -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
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
|
||||
void run();
|
||||
void send(const std::string& response);
|
||||
void sendLast();
|
||||
bool receive(std::string& request);
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user