mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
Kernel/Net: Add a special SOCKET_TRY() and use it in socket code
Sockets remember their last error code in the SO_ERROR field, so we need to take special care to remember this when returning an error. This patch adds a SOCKET_TRY() that works like TRY() but also calls set_so_error() on the failure path. There's probably a lot more code that should be using this, but that's outside the scope of this patch.
This commit is contained in:
parent
3c44e381d4
commit
308773ffda
5 changed files with 29 additions and 46 deletions
|
@ -209,4 +209,13 @@ private:
|
|||
RefPtr<SocketType> m_socket;
|
||||
};
|
||||
|
||||
// This is a special variant of TRY() that also updates the socket's SO_ERROR field on error.
|
||||
#define SOCKET_TRY(expression) \
|
||||
({ \
|
||||
auto result = (expression); \
|
||||
if (result.is_error()) \
|
||||
return set_so_error(result.release_error()); \
|
||||
result.release_value(); \
|
||||
})
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue