net/SocketDescriptor: use method GetOption() internally

This commit is contained in:
Max Kellermann 2023-11-22 11:58:40 +01:00 committed by Max Kellermann
parent 60033f3eb4
commit 6dc708f53f
1 changed files with 2 additions and 5 deletions

View File

@ -191,12 +191,9 @@ SocketDescriptor::CreateSocketPairNonBlock(int domain, int type, int protocol,
int
SocketDescriptor::GetError() const noexcept
{
assert(IsDefined());
int s_err = 0;
socklen_t s_err_size = sizeof(s_err);
return getsockopt(fd, SOL_SOCKET, SO_ERROR,
(char *)&s_err, &s_err_size) == 0
return GetOption(SOL_SOCKET, SO_ERROR,
&s_err, sizeof(s_err)) == sizeof(s_err)
? s_err
: errno;
}