net: convert standalone SetSocketNonBlocking() to Sock::SetNonBlocking()

This further encapsulates syscalls inside the `Sock` class.

Co-authored-by: practicalswift <practicalswift@users.noreply.github.com>
This commit is contained in:
Vasil Dimov
2021-04-19 11:35:09 +02:00
parent 29f66f7682
commit b527b54950
6 changed files with 37 additions and 14 deletions

View File

@@ -254,6 +254,19 @@ int FuzzedSock::GetSockName(sockaddr* name, socklen_t* name_len) const
return 0;
}
bool FuzzedSock::SetNonBlocking() const
{
constexpr std::array setnonblocking_errnos{
EBADF,
EPERM,
};
if (m_fuzzed_data_provider.ConsumeBool()) {
SetFuzzedErrNo(m_fuzzed_data_provider, setnonblocking_errnos);
return false;
}
return true;
}
bool FuzzedSock::IsSelectable() const
{
return m_selectable;

View File

@@ -80,6 +80,8 @@ public:
int GetSockName(sockaddr* name, socklen_t* name_len) const override;
bool SetNonBlocking() const override;
bool IsSelectable() const override;
bool Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred = nullptr) const override;

View File

@@ -166,6 +166,8 @@ public:
return 0;
}
bool SetNonBlocking() const override { return true; }
bool IsSelectable() const override { return true; }
bool Wait(std::chrono::milliseconds timeout,