Skip to content

Commit

Permalink
fix(Socket): Socket::select EPOLL implementation returns socket in ex…
Browse files Browse the repository at this point in the history
…ceptList when empty list is given #3655; mark select as deprecated #1459
  • Loading branch information
aleks-f committed Jul 4, 2022
1 parent 672d64b commit 93e58b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Net/include/Poco/Net/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class Net_API Socket
void close();
/// Closes the socket.

//@deprecated
static int select(SocketList& readList, SocketList& writeList, SocketList& exceptList, const Poco::Timespan& timeout);
/// Determines the status of one or more sockets,
/// using a call to select().
Expand Down Expand Up @@ -159,6 +160,9 @@ class Net_API Socket
/// the closed socket will not be included in any list.
/// In this case, the return value may be greater than the sum
/// of all sockets in all list.
///
/// This function is deprecated and may be removed in the future releases,
/// please use PollSet class instead.

bool poll(const Poco::Timespan& timeout, int mode) const;
/// Determines the status of the socket, using a
Expand Down
10 changes: 6 additions & 4 deletions Net/src/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,14 @@ int Socket::select(SocketList& readList, SocketList& writeList, SocketList& exce
SocketList readyExceptList;
for (int n = 0; n < rc; ++n)
{
if (eventsOut[n].events & EPOLLERR)
readyExceptList.push_back(*reinterpret_cast<Socket*>(eventsOut[n].data.ptr));
Socket sock = *reinterpret_cast<Socket*>(eventsOut[n].data.ptr);
if ((eventsOut[n].events & EPOLLERR) &&
(std::end(exceptList) != std::find(exceptList.begin(), exceptList.end(), sock)))
readyExceptList.push_back(sock);
if (eventsOut[n].events & EPOLLIN)
readyReadList.push_back(*reinterpret_cast<Socket*>(eventsOut[n].data.ptr));
readyReadList.push_back(sock);
if (eventsOut[n].events & EPOLLOUT)
readyWriteList.push_back(*reinterpret_cast<Socket*>(eventsOut[n].data.ptr));
readyWriteList.push_back(sock);
}
std::swap(readList, readyReadList);
std::swap(writeList, readyWriteList);
Expand Down

0 comments on commit 93e58b4

Please sign in to comment.