Skip to content

Commit

Permalink
Fix data race (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyWoo authored Oct 20, 2023
1 parent 58c3ff9 commit d171eab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Common/NIO/PollSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ class PollSetImpl
{
struct epoll_event ev;
ev.events = 0;
if (mode & PollSet::POLL_READ)
ev.events |= EPOLLIN;
if (mode & PollSet::POLL_WRITE)
ev.events |= EPOLLOUT;
if (mode & PollSet::POLL_ERROR)
ev.events |= EPOLLERR;
if (mode & PollSet::POLL_READ)
ev.events |= EPOLLIN;
ev.data.ptr = ptr;
return epoll_ctl(_epollfd, EPOLL_CTL_ADD, fd, &ev);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Common/NIO/SocketReactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,16 @@ void SocketReactor::addEventHandlers(const Socket& socket, const std::vector<Poc
{
NotifierPtr pNotifier = getNotifier(socket, true);

int mode = 0;
for (auto * observer : observers)
{
if (!pNotifier->hasObserver(*observer)) pNotifier->addObserver(this, *observer);

int mode = 0;
if (pNotifier->accepts(_pReadableNotification)) mode |= PollSet::POLL_READ;
if (pNotifier->accepts(_pWritableNotification)) mode |= PollSet::POLL_WRITE;
if (pNotifier->accepts(_pErrorNotification)) mode |= PollSet::POLL_ERROR;
if (mode) _pollSet.add(socket, mode);
}
if (mode) _pollSet.add(socket, mode);
}


Expand Down

0 comments on commit d171eab

Please sign in to comment.