mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibIPC: Make TransportSocketWindows responsible for reading entire
messages. Port of a371f84
to Windows.
This commit is contained in:
parent
ccf303eefc
commit
8af2a49b5c
Notes:
github-actions[bot]
2025-06-17 21:38:09 +00:00
Author: https://github.com/stasoid
Commit: 8af2a49b5c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5010
Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 58 additions and 22 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Queue.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <LibIPC/File.h>
|
||||
|
||||
|
@ -26,13 +27,17 @@ public:
|
|||
|
||||
void wait_until_readable();
|
||||
|
||||
ErrorOr<void> transfer(Bytes, Vector<size_t> const& handle_offsets);
|
||||
ErrorOr<void> transfer_message(ReadonlyBytes, Vector<size_t> const& handle_offsets);
|
||||
|
||||
struct [[nodiscard]] ReadResult {
|
||||
Vector<u8> bytes;
|
||||
Vector<int> fds; // always empty, present to avoid OS #ifdefs in Connection.cpp
|
||||
enum class ShouldShutdown {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
ReadResult read_as_much_as_possible_without_blocking(Function<void()> schedule_shutdown);
|
||||
struct Message {
|
||||
Vector<u8> bytes;
|
||||
Queue<File> fds; // always empty, present to avoid OS #ifdefs in Connection.cpp
|
||||
};
|
||||
ShouldShutdown read_as_many_messages_as_possible_without_blocking(Function<void(Message&&)>&&);
|
||||
|
||||
// Obnoxious name to make it clear that this is a dangerous operation.
|
||||
ErrorOr<int> release_underlying_transport_for_transfer();
|
||||
|
@ -41,9 +46,11 @@ public:
|
|||
|
||||
private:
|
||||
ErrorOr<void> duplicate_handles(Bytes, Vector<size_t> const& handle_offsets);
|
||||
ErrorOr<void> transfer(ReadonlyBytes);
|
||||
|
||||
private:
|
||||
NonnullOwnPtr<Core::LocalSocket> m_socket;
|
||||
ByteBuffer m_unprocessed_bytes;
|
||||
int m_peer_pid = -1;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue