Continued improvements to shutdown.
This commit is contained in:
1 parent
b4ab5fb86a
commit
28292e924a
55 files changed
+459
-367
No files matched your search
+14
-13
@@ -138,30 +138,26 @@ namespace core {
|
||||
}
|
||||
}
|
||||
|
||||
void Socket::writeSocket() {
|
||||
if(shutDown)
|
||||
return;
|
||||
|
||||
void Socket::writeSocket() {
|
||||
if(fifo.size() > 0) {
|
||||
outlock.lock();
|
||||
coreutils::Log(coreutils::LOG_DEBUG_3) << "Writing data to socket " << getDescriptor() << " [" << fifo.front() << "].";
|
||||
::write(descriptor, fifo.front().c_str(), fifo.front().length());
|
||||
fifo.pop();
|
||||
coreutils::Log(coreutils::LOG_DEBUG_4) << "resetSocket from writeSocket.";
|
||||
if(active)
|
||||
ePoll.resetSocket(this);
|
||||
ePoll.resetSocket(this);
|
||||
if(shutDown && !needsToWrite())
|
||||
delete this;
|
||||
outlock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
int Socket::write(std::string data) {
|
||||
if(!active)
|
||||
return -1;
|
||||
|
||||
coreutils::Log(coreutils::LOG_DEBUG_3) << "Writing data to socket " << getDescriptor() << " buffer [" << data << "].";
|
||||
outlock.lock();
|
||||
fifo.emplace(data);
|
||||
coreutils::Log(coreutils::LOG_DEBUG_4) << "resetSocket from write. active is " << active;
|
||||
if(active)
|
||||
ePoll.resetSocket(this);
|
||||
coreutils::Log(coreutils::LOG_DEBUG_4) << "Enabling write on socket " << getDescriptor() << " with " << fifo.size() << " entries to write.";
|
||||
ePoll.resetSocket(this);
|
||||
outlock.unlock();
|
||||
return 1;
|
||||
}
|
||||
@@ -171,6 +167,7 @@ namespace core {
|
||||
}
|
||||
|
||||
bool Socket::needsToWrite() {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_4) << "Socket " << getDescriptor() << " needs to write is " << (fifo.size() > 0) << ".";
|
||||
return fifo.size() > 0;
|
||||
}
|
||||
|
||||
@@ -178,7 +175,11 @@ namespace core {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "Shutdown requested on socket " << descriptor << " with reason " << text << ".";
|
||||
shutDown = true;
|
||||
active = false;
|
||||
delete this;
|
||||
if(!needsToWrite()) {
|
||||
active = false;
|
||||
delete this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user