Skip to content

Commit

Permalink
trivial: cleanup unused CConnman::SocketEvents variants
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed May 29, 2024
1 parent 7185762 commit b6002ce
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 94 deletions.
81 changes: 0 additions & 81 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@
#include <ifaddrs.h>
#endif

#ifdef USE_EPOLL
#include <sys/epoll.h>
#endif

#ifdef USE_KQUEUE
#include <sys/event.h>
#endif

#include <algorithm>
#include <array>
#include <cstdint>
Expand Down Expand Up @@ -1690,79 +1682,6 @@ Sock::EventsPerSock CConnman::GenerateWaitSockets(Span<CNode* const> nodes)
return events_per_sock;
}

#ifdef USE_KQUEUE
void CConnman::SocketEventsKqueue(std::set<SOCKET>& recv_set,
std::set<SOCKET>& send_set,
std::set<SOCKET>& error_set,
bool only_poll)
{
std::array<struct kevent, MAX_EVENTS> events;
struct timespec timeout = MillisToTimespec(only_poll ? 0 : SELECT_TIMEOUT_MILLISECONDS);

int n{-1};
ToggleWakeupPipe([&](){
n = kevent(Assert(m_edge_trig_events)->GetFileDescriptor(), nullptr, 0, events.data(), events.size(), &timeout);
});
if (n == -1) {
LogPrintf("kevent wait error\n");
return;
}

for (int i = 0; i < n; i++) {
auto& event = events[i];
if ((event.flags & EV_ERROR) || (event.flags & EV_EOF)) {
error_set.insert((SOCKET)event.ident);
continue;
}

if (event.filter == EVFILT_READ) {
recv_set.insert((SOCKET)event.ident);
}

if (event.filter == EVFILT_WRITE) {
send_set.insert((SOCKET)event.ident);
}
}
}
#endif

#ifdef USE_EPOLL
void CConnman::SocketEventsEpoll(std::set<SOCKET>& recv_set,
std::set<SOCKET>& send_set,
std::set<SOCKET>& error_set,
bool only_poll)
{
std::array<epoll_event, MAX_EVENTS> events;

int n{-1};
ToggleWakeupPipe([&](){
n = epoll_wait(Assert(m_edge_trig_events)->GetFileDescriptor(), events.data(), events.size(),
only_poll ? 0 : SELECT_TIMEOUT_MILLISECONDS);
});

if (n == -1) {
LogPrintf("epoll_wait error\n");
return;
}

for (int i = 0; i < n; i++) {
auto& e = events[i];
if((e.events & EPOLLERR) || (e.events & EPOLLHUP)) {
error_set.insert((SOCKET)e.data.fd);
continue;
}

if (e.events & EPOLLIN) {
recv_set.insert((SOCKET)e.data.fd);
}

if (e.events & EPOLLOUT) {
send_set.insert((SOCKET)e.data.fd);
}
}
}
#endif

void CConnman::SocketHandler(CMasternodeSync& mn_sync)
{
AssertLockNotHeld(m_total_bytes_sent_mutex);
Expand Down
13 changes: 0 additions & 13 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -1285,19 +1285,6 @@ friend class CNode;
*/
Sock::EventsPerSock GenerateWaitSockets(Span<CNode* const> nodes);

#ifdef USE_KQUEUE
void SocketEventsKqueue(std::set<SOCKET>& recv_set,
std::set<SOCKET>& send_set,
std::set<SOCKET>& error_set,
bool only_poll);
#endif
#ifdef USE_EPOLL
void SocketEventsEpoll(std::set<SOCKET>& recv_set,
std::set<SOCKET>& send_set,
std::set<SOCKET>& error_set,
bool only_poll);
#endif

/**
* Check connected and listening sockets for IO readiness and process them accordingly.
*/
Expand Down

0 comments on commit b6002ce

Please sign in to comment.