mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 10:18:15 +09:00
LibIPC+Userland: Make IPC::File always own its file descriptor
Add factory functions to distinguish between when the owner of the File wants to transfer ownership to the new IPC object (adopt) or to send a copy of the same fd to the IPC peer (clone). This behavior is more intuitive than the previous behavior. Previously, an IPC::File would default to a shallow clone of the file descriptor, only *actually* calling dup(2) for the fd when encoding or it into an IPC MessageBuffer. Now the dup(2) for the fd is explicit in the clone_fd factory function.
This commit is contained in:
parent
26ce8ad40f
commit
6d4ba21832
Notes:
sideshowbarker
2024-07-17 02:57:43 +09:00
Author: https://github.com/ADKaster
Commit: 6d4ba21832
Pull-request: https://github.com/SerenityOS/serenity/pull/23989
Reviewed-by: https://github.com/trflynn89
17 changed files with 44 additions and 50 deletions
|
@ -20,7 +20,7 @@ ErrorOr<SelectedFile> SelectedFile::from_file_path(ByteString const& file_path)
|
|||
auto name = LexicalPath::basename(file_path);
|
||||
|
||||
auto file = TRY(Core::File::open(file_path, Core::File::OpenMode::Read));
|
||||
return SelectedFile { move(name), IPC::File { *file } };
|
||||
return SelectedFile { move(name), IPC::File::adopt_file(move(file)) };
|
||||
}
|
||||
|
||||
SelectedFile::SelectedFile(ByteString name, ByteBuffer contents)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue