summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibIPC
AgeCommit message (Collapse)Author
2022-04-03LibIPC: Add encoder and decoder for AK::OrderedHashMapValtteri Koskivuori
Seems like a useful thing to have.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-28LibIPC: Add IPCErrorOr Type aliasHendiadyoin1
2022-03-13Libraries: Use default constructors/destructors in LibIPCLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-02-25Userland: Rename IPC::ServerConnection=>IPC::ConnectionToServerItamar
This was done with CLion's automatic rename feature.
2022-02-25Userland: Rename IPC ClientConnection => ConnectionFromClientItamar
This was done with CLion's automatic rename feature and with: find . -name ClientConnection.h | rename 's/ClientConnection\.h/ConnectionFromClient.h/' find . -name ClientConnection.cpp | rename 's/ClientConnection\.cpp/ConnectionFromClient.cpp/'
2022-02-15LibIPC: Always shutdown() the Connection if reached EOFVitaly Dyachkov
2022-02-06LibCore+LibIPC: Move SystemServerTakeover.{h,cpp} to LibCoresin-ack
This functionality is required by Core::LocalServer and LibIPC depends on LibCore. take_over_accepted_socket_from_system_server has also been renamed to take_over_socket_from_system_server as the socket need not be accepted before taking it over. :^)
2022-01-24Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOrSam Atkins
Apologies for the enormous commit, but I don't see a way to split this up nicely. In the vast majority of cases it's a simple change. A few extra places can use TRY instead of manual error checking though. :^)
2022-01-15LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServersin-ack
This change unfortunately cannot be atomically made without a single commit changing everything. Most of the important changes are in LibIPC/Connection.cpp, LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp. The notable changes are: - IPCCompiler now generates the decode and decode_message functions such that they take a Core::Stream::LocalSocket instead of the socket fd. - IPC::Decoder now uses the receive_fd method of LocalSocket instead of doing system calls directly on the fd. - IPC::ConnectionBase and related classes now use the Stream API functions. - IPC::ServerConnection no longer constructs the socket itself; instead, a convenience macro, IPC_CLIENT_CONNECTION, is used in place of C_OBJECT and will generate a static try_create factory function for the ServerConnection subclass. The subclass is now responsible for passing the socket constructed in this function to its ServerConnection base; the socket is passed as the first argument to the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before any other arguments. - The functionality regarding taking over sockets from SystemServer has been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket implementation of this functionality hasn't been deleted due to my intention of removing this class in the near future and to reduce noise on this (already quite noisy) PR.
2022-01-14Everywhere: Use my new serenityos.org e-mail :^)kleines Filmröllchen
2021-12-06LibIPC: Add IPC::take_over_accepted_client_from_system_server<Client>()Andreas Kling
This is an encapsulation of the common work done by all of our single-client IPC servers on startup: 1. Create a Core::LocalSocket, taking over an accepted fd. 2. Create an application-specific ClientConnection object, wrapping the socket. It's not a huge change in terms of lines saved, but I do feel that it improves expressiveness. :^)
2021-12-06LibIPC: Add IPC::MultiServer convenience classAndreas Kling
This encapsulates what our multi-client IPC servers typically do on startup: 1. Create a Core::LocalServer 2. Take over a listening socket file descriptor from SystemServer 3. Set up an accept handler for incoming connections IPC::MultiServer does all this for you! All you have to do is provide the relevant client connection type as a template argument.
2021-11-30LibIPC: Mark ClientConnection::die() as an overrideAndreas Kling
2021-11-29LibIPC: Mark m_sockfd as maybe_unused on non Serenity platformsdavidot
2021-11-29LibIPC: Replace u32/u64 value coders with u/ul/ull value codersAndreas Kling
We can and should do more cleanups of this kind, but this is a quick fix to unbreak the 32-bit HackStudio build.
2021-11-28LibIPC+IPCCompiler+AK: Make IPC value decoders return ErrorOr<void>Andreas Kling
This allows us to use TRY() in decoding helpers, leading to a nice reduction in line count.
2021-11-28LibIPC: Make IPC::Connection::post_message() return ErrorOrAndreas Kling
2021-11-28LibIPC: Give MessageBuffer::fds some inline capacity (1)Andreas Kling
This dodges a heap allocation when sending 0 or 1 fd across the IPC boundary (which covers every message.)
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-08LibIPC: Replace Result<T, E> use with ErrorOr<T>Andreas Kling
2021-11-08LibIPC: Add ClientConnection::shutdown_with_error()Andreas Kling
Before this, we only had ClientConnection::did_misbehave() to report an error and shut the connection down. But it's not fair to say that *all* errors are the client misbehaving! A typical non-misbehavior is resource allocation failure on the server side.
2021-11-08LibCore: Use ErrorOr<T> in Core::AnonymousBufferAndreas Kling
2021-11-03Revert "LibIPC: Use a zero-delay timer for message processing"Andreas Kling
This reverts commit 3bed7d5a5ee5870de4805dd2bf47e0523e387e76. As discovered by tomuta, this caused a large increase in WindowServer CPU usage.
2021-10-24LibIPC: Use a zero-delay timer for message processingAndreas Kling
This lets us avoid using Core::deferred_invoke() which is not usable during application teardown (as there is no event loop to push the deferred invocation onto.) (Not that there is an event loop to fire the processing timer during teardown *either*, but at least we can exit gracefully with pending timers, unlike deferred invocations, which hang the process. This is an area where more improvements are definitely needed!)
2021-10-24LibIPC: Store local endpoint magic in a ConnectionBase memberAndreas Kling
This simplifies some of the code, since it's no longer necessary for the templated code to pass LocalEndpoint::static_magic() everywhere.
2021-10-24LibIPC: Move waiting for synchronous responses to ConnectionBaseAndreas Kling
2021-10-24LibIPC: Move more of IPC::Connection to ConnectionBaseAndreas Kling
This patch moves the templated message parsing code to a virtual try_parse_messages() helper. By doing that, we can move the rest of the socket draining code up to ConnectionBase and keep it out of line.
2021-10-24LibIPC: Move non-templated parts of IPC::Connection out of lineAndreas Kling
This patch splits IPC::Connection into Connection and ConnectionBase. ConnectionBase moves into Connection.cpp so we don't have to inline it for every single templated subclass.
2021-10-24LibIPC: Add IPC::Stub to forwarding headerAndreas Kling
2021-09-16LibIPC: Use default instead of an empty constructor/destructorBrian Gianforcaro
Default implementations allow for more optimizations. See: https://pvs-studio.com/en/docs/warnings/v832/
2021-09-12LibIPC: Add support for transferring doubles over IPC messageskleines Filmröllchen
I'm still wondering why nobody did this yet :^) Also changes the use of unions for the more cleaner / less undefined AK::bit_cast.
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur
2021-09-03LibIPC: Convert Encoder class to east-const styleAndreas Kling
2021-09-02Userland: Migrate to argument-less deferred_invokesin-ack
Only one place used this argument and it was to hold on to a strong ref for the object. Since we already do that now, there's no need to keep this argument around since this can be easily captured. This commit contains no changes.
2021-08-11LibIPC: Pass only message size to decoderFederico Guerinoni
Fixes #9015.
2021-08-01Libraries: Remove unused header includesBrian Gianforcaro
2021-07-21LibIPC: Fix losing messages when connection is closedTom
This fixes not processing any messages read up until a connection close is detected. We were returning from the function despite having read some messages.
2021-07-18LibIPC: Close the socket and die when the peer is closedGunnar Beutner
This will close the socket when the recv() returns 0 indicating that the peer has shutdown, and when there are no pending bytes to be processed.
2021-07-18LibIPC: Add Connection::is_open()Gunnar Beutner
This will allow clients to see if the IPC socket is still open.
2021-07-08LibIPC: Remove unnecessary `template<>`Daniel Bertalan
This fixes a Clang warning.
2021-07-08Everywhere: Forward declare structs as structsDaniel Bertalan
While structs being forward declared as classes is not strictly an issue, Clang complains as this is not portable code, since some ABIs treat classes declared as `class` and `struct` differently. It's easier to fix these than to reason about explicitly disabling another warning.
2021-07-04AK+LibIPC: Make all enums codableTimothy
If an enum has a supported underlying type we can provide encoding and decoding for the enum as well.
2021-06-24Userland: Disambiguate dependent typesDaniel Bertalan
Clang produced an error on these pieces of code without the `typename` keyword.
2021-05-24LibIPC: Fix unaligned u32 access in drain_messages_from_peer()Andreas Kling
Caught by userspace UBSAN. :^)
2021-05-23LibIPC: Remove unnecessary IPC::ServerConnection::handshake()Andreas Kling
This is no longer used by any of our IPC pairs.
2021-05-19Everywhere: Add missing includes for <AK/OwnPtr.h>Gunnar Beutner
Previously <AK/Function.h> also included <AK/OwnPtr.h>. That's about to change though. This patch fixes a few build problems that will occur when that change happens.
2021-05-14LibC: Do not include errno.h inside unistd.hJean-Baptiste Boric
POSIX does not mandate this, therefore let's not do it.
2021-05-03Userland: Add try_* IPC handlersGunnar Beutner
This enables calling auto-generated IPC methods in a way that doesn't crash the client if the peer disconnects.
2021-05-03Userland: Update IPC calls to use proxiesGunnar Beutner
This updates all existing code to use the auto-generated client methods instead of post_message/send_sync.