Use PollSet in SocketReactor #2092 (linux)

This commit is contained in:
Alex Fabijanic
2018-04-26 19:17:49 -05:00
parent 6912384422
commit ea38cdb740
4 changed files with 51 additions and 41 deletions

View File

@@ -72,7 +72,8 @@ public:
{
Poco::FastMutex::ScopedLock lock(_mutex);
poco_socket_t fd = socket.impl()->sockfd();
SocketImpl* sockImpl = socket.impl();
poco_socket_t fd = sockImpl->sockfd();
struct epoll_event ev;
ev.events = 0;
if (mode & PollSet::POLL_READ)
@@ -83,9 +84,15 @@ public:
ev.events |= EPOLLERR;
ev.data.ptr = socket.impl();
int err = epoll_ctl(_epollfd, EPOLL_CTL_ADD, fd, &ev);
if (err) SocketImpl::error();
_socketMap[socket.impl()] = socket;
if (err)
{
if (errno == EEXIST) update(socket, mode);
else SocketImpl::error();
}
if (_socketMap.find(sockImpl) == _socketMap.end())
_socketMap[sockImpl] = socket;
}
void remove(const Socket& socket)