mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 18:15:07 +00:00
Kernel: Store socket errors as errno codes rather than ErrorOr values
This commit is contained in:
parent
d32961777b
commit
bd4bddf31b
2 changed files with 11 additions and 11 deletions
|
@ -169,11 +169,9 @@ ErrorOr<void> Socket::getsockopt(OpenFileDescription&, int level, int option, Us
|
|||
case SO_ERROR: {
|
||||
if (size < sizeof(int))
|
||||
return EINVAL;
|
||||
int errno;
|
||||
if (so_error().is_error())
|
||||
errno = so_error().error().code();
|
||||
else
|
||||
errno = 0;
|
||||
int errno = 0;
|
||||
if (auto const& error = so_error(); error.has_value())
|
||||
errno = error.value();
|
||||
TRY(copy_to_user(static_ptr_cast<int*>(value), &errno));
|
||||
size = sizeof(int);
|
||||
TRY(copy_to_user(value_size, &size));
|
||||
|
|
|
@ -124,7 +124,7 @@ protected:
|
|||
|
||||
Role m_role { Role::None };
|
||||
|
||||
ErrorOr<void> so_error() const
|
||||
Optional<ErrnoCode> const& so_error() const
|
||||
{
|
||||
VERIFY(m_mutex.is_exclusively_locked_by_current_thread());
|
||||
return m_so_error;
|
||||
|
@ -133,14 +133,16 @@ protected:
|
|||
Error set_so_error(ErrnoCode error_code)
|
||||
{
|
||||
MutexLocker locker(mutex());
|
||||
auto error = Error::from_errno(error_code);
|
||||
m_so_error = error;
|
||||
return error;
|
||||
m_so_error = error_code;
|
||||
|
||||
return Error::from_errno(error_code);
|
||||
}
|
||||
|
||||
Error set_so_error(Error error)
|
||||
{
|
||||
MutexLocker locker(mutex());
|
||||
m_so_error = error;
|
||||
m_so_error = static_cast<ErrnoCode>(error.code());
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -178,7 +180,7 @@ private:
|
|||
Time m_send_timeout {};
|
||||
int m_timestamp { 0 };
|
||||
|
||||
ErrorOr<void> m_so_error;
|
||||
Optional<ErrnoCode> m_so_error;
|
||||
|
||||
NonnullLockRefPtrVector<Socket> m_pending;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue