Fixed cross socket writing issue with epoll scheduler.

This commit is contained in:
Brad Arant 2022-03-15 23:53:22 +00:00
parent c918e42290
commit 08561f6dc3
2 changed files with 5 additions and 1 deletions

View File

@ -61,6 +61,7 @@ namespace core {
void Socket::onUnregistered() {} void Socket::onUnregistered() {}
bool Socket::eventReceived(struct epoll_event event) { bool Socket::eventReceived(struct epoll_event event) {
inHandler = true;
if(event.events & EPOLLRDHUP) { if(event.events & EPOLLRDHUP) {
readHangup = true; readHangup = true;
shutdown("hangup received"); shutdown("hangup received");
@ -75,6 +76,7 @@ namespace core {
else if(event.events & EPOLLHUP) { else if(event.events & EPOLLHUP) {
shutdown(); shutdown();
} }
inHandler = false;
return !shutDown; return !shutDown;
} }
@ -137,6 +139,8 @@ namespace core {
outlock.lock(); outlock.lock();
fifo.emplace(data); fifo.emplace(data);
outlock.unlock(); outlock.unlock();
if(!inHandler)
ePoll.resetSocket(this);
return 1; return 1;
} }

View File

@ -170,7 +170,7 @@ namespace core {
// std::mutex lock; // std::mutex lock;
std::mutex outlock; std::mutex outlock;
bool readHangup = false; bool readHangup = false;
bool inHandler = false;
// struct epoll_event event; // Event selection construction structure. // struct epoll_event event; // Event selection construction structure.
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------