Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/i2p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ bool Session::Accept(Connection& conn)

while (!*m_interrupt) {
Sock::Event occurred;
if (!conn.sock->Wait(MAX_WAIT_FOR_IO, Sock::RECV, &occurred)) {
if (!conn.sock->Wait(MAX_WAIT_FOR_IO, Sock::RECV, SocketEventsParams{::g_socket_events_mode}, &occurred)) {
errmsg = "wait on socket failed";
break;
}
Expand Down
29 changes: 7 additions & 22 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,21 +480,6 @@ static void OnRPCStopped()
LogPrint(BCLog::RPC, "RPC stopped.\n");
}

std::string GetSupportedSocketEventsStr()
{
std::string strSupportedModes = "'select'";
#ifdef USE_POLL
strSupportedModes += ", 'poll'";
#endif
#ifdef USE_EPOLL
strSupportedModes += ", 'epoll'";
#endif
#ifdef USE_KQUEUE
strSupportedModes += ", 'kqueue'";
#endif
return strSupportedModes;
}

void SetupServerArgs(ArgsManager& argsman)
{
SetupHelpOptions(argsman);
Expand Down Expand Up @@ -1642,6 +1627,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
}
}

std::string sem_str = args.GetArg("-socketevents", DEFAULT_SOCKETEVENTS);
::g_socket_events_mode = SEMFromString(sem_str);
if (::g_socket_events_mode == SocketEventsMode::Unknown) {
return InitError(strprintf(_("Invalid -socketevents ('%s') specified. Only these modes are supported: %s"), sem_str, GetSupportedSocketEventsStr()));
}

assert(!node.banman);
node.banman = std::make_unique<BanMan>(gArgs.GetDataDirNet() / "banlist", &uiInterface, args.GetIntArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
assert(!node.connman);
Expand Down Expand Up @@ -2420,6 +2411,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
connOptions.m_added_nodes = args.GetArgs("-addnode");
connOptions.nMaxOutboundLimit = *opt_max_upload;
connOptions.m_peer_connect_timeout = peer_connect_timeout;
connOptions.socketEventsMode = ::g_socket_events_mode;

// Port to bind to if `-bind=addr` is provided without a `:port` suffix.
const uint16_t default_bind_port =
Expand Down Expand Up @@ -2527,13 +2519,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
}
}

std::string sem_str = args.GetArg("-socketevents", DEFAULT_SOCKETEVENTS);
const auto sem = SEMFromString(sem_str);
if (sem == SocketEventsMode::Unknown) {
return InitError(strprintf(_("Invalid -socketevents ('%s') specified. Only these modes are supported: %s"), sem_str, GetSupportedSocketEventsStr()));
}
connOptions.socketEventsMode = sem;

const std::string& i2psam_arg = args.GetArg("-i2psam", "");
if (!i2psam_arg.empty()) {
const std::optional<CService> addr{Lookup(i2psam_arg, 7656, fNameLookup)};
Expand Down
2 changes: 1 addition & 1 deletion src/masternode/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void CActiveMasternodeManager::InitInternal(const CBlockIndex* pindex)
// Check socket connectivity
LogPrintf("CActiveMasternodeManager::Init -- Checking inbound connection to '%s'\n", m_info.service.ToStringAddrPort());
std::unique_ptr<Sock> sock{ConnectDirectly(m_info.service, /*manual_connection=*/true)};
bool fConnected{sock && sock->IsSelectable()};
bool fConnected{sock && sock->IsSelectable(/*is_select=*/::g_socket_events_mode == SocketEventsMode::Select)};
sock = std::make_unique<Sock>(INVALID_SOCKET);
if (!fConnected && Params().RequireRoutableExternalIP()) {
m_state = MasternodeState::SOME_ERROR;
Expand Down
Loading
Loading