summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibIPC
AgeCommit message (Collapse)Author
2023-04-25LibCore: Big first step towards pluggable Core::EventLoopAndreas Kling
The EventLoop is now a wrapper around an EventLoopImplementation. Our old EventLoop code has moved into EventLoopImplementationUnix and continues to work as before. The main difference is that all the separate thread_local variables have been collected into a file-local ThreadData data structure. The goal here is to allow running Core::EventLoop with a totally different backend, such as Qt for Ladybird.
2023-04-25LibCore: Remove some unnecessary includes from EventLoop.hAndreas Kling
2023-03-13AK: Rename Stream::read_entire_buffer to Stream::read_until_filledTim Schumacher
No functional changes.
2023-03-13AK: Rename Stream::{read,write} to Stream::{read_some,write_some}Tim Schumacher
Similar to POSIX read, the basic read and write functions of AK::Stream do not have a lower limit of how much data they read or write (apart from "none at all"). Rename the functions to "read some [data]" and "write some [data]" (with "data" being omitted, since everything here is reading and writing data) to make them sufficiently distinct from the functions that ensure to use the entire buffer (which should be the go-to function for most usages). No functional changes, just a lot of new FIXMEs.
2023-03-06Everywhere: Remove NonnullOwnPtr.h includesAndreas Kling
2023-03-06Everywhere: Stop using NonnullOwnPtrVectorAndreas Kling
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-06Everywhere: Stop using NonnullRefPtrVectorAndreas Kling
This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
2023-03-05LibIPC: Support transferring String over IPCTimothy Flynn
Note that unlike the StringView encoder, we do not handle any "null" state, as the new String cannot be null.
2023-02-24LibIPC: Add a built-in encoder/decoder for AK::TimeTimothy Flynn
2023-02-13Everywhere: Remove the `AK::` qualifier from Stream usagesTim Schumacher
2023-02-13LibCore: Remove `Stream.h`Tim Schumacher
2023-02-13LibCore: Move Stream-based file into the `Core` namespaceTim Schumacher
2023-02-13LibCore: Move Stream-based sockets into the `Core` namespaceTim Schumacher
2023-01-29AK: Move `Stream` and `SeekableStream` from `LibCore`Tim Schumacher
`Stream` will be qualified as `AK::Stream` until we remove the `Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is defined by `SeekableStream`, since defining its own would require us to qualify it with `AK::SeekMode` everywhere.
2023-01-29AK: Deprecate the old `AK::Stream`Tim Schumacher
This also removes a few cases where the respective header wasn't actually required to be included.
2023-01-28LibCore: Remove `try_` prefix from fallible SharedCircularQueue methodsLinus Groh
2023-01-15LibIPC: Decode messages using Core::Stream internallyTim Schumacher
2023-01-12LibCore+Userland: Make Core::Timer::create_single_shot() return ErrorOrSam Atkins
clang-format sure has some interesting opinions about where to put a method call that comes after a lambda. :thonk:
2023-01-06LibIPC: Add `File(Core::Stream::File& file, ...)`Lucas CHOLLET
2023-01-04LibIPC: Remove declarations of unimplemented IPC::Encoder methodsTimothy Flynn
Should have been removed in af2ae7fda19bff8787f7add630292332b61afbcd.
2023-01-04LibIPC: Move most of DeprecatedString's encoder to StringView's encoderTimothy Flynn
This was a footgun waiting to happen. The StringView encoder is only used internally within IPC::Encoder to encode DeprecatedString. It does not encode its null state nor its length. If someone were to innocently use the StringView encoder as it is, and then decode a DeprecatedString on the remote end, the decoding would be corrupt. This changes the StringView encoder to do the work the DeprecatedString encoder is currently doing, and the latter now just forwards to it.
2023-01-04LibIPC+LibC: Add and use a helper to encode/decoder container sizesTimothy Flynn
While refactoring the IPC encoders and decoders for fallibility, the inconsistency in which we transfer container sizes was a frequent thing to trip over. We currently transfer sizes as any of i32, u32, and u64. This adds a helper to transfer sizes in one consistent way. Two special cases here are DeprecatedString and Vector, whose encoding is depended upon by netdb, so that is also updated here.
2023-01-04LibIPC: Remove now-unused stream operator from IPC::EncoderTimothy Flynn
The fallible encoders are now the only option to encode values.
2023-01-04IPCCompiler+LibIPC: Propagate IPC encoder errorsTimothy Flynn
This propagates errors from user-defined encoders up to IPC::Connection. There, we currently just log the error, as we aren't in a position to propagate it further (i.e. we are inside a deferred invocation).
2023-01-04LibIPC+Everywhere: Change IPC::encode's return type to ErrorOrTimothy Flynn
In doing so, this removes all uses of the Encoder's stream operator, except for where it is currently still used in the generated IPC code. So the stream operator currently discards any errors, which is the existing behavior. A subsequent commit will propagate the errors.
2023-01-04LibIPC: Add a Dictionary for-each method for fallible callbacksTimothy Flynn
Similar to a similar change to JsonObject (13b18a1).
2023-01-04LibIPC: Replace Encoder::encode methods with IPC::encode specializationsTimothy Flynn
Currently, the stream operator overload hides most encoding errors. In an effort to make IPC encoding fallible, this first replaces the Encoder overloads with IPC::encode specializations. The return type is still a boolean, a future commit will change it to ErrorOr. Note that just like in the analogous decoder commit (9b48362), these specializations must be defined at the namespace scope. Further, all arithmetic specializations are now in one method.
2023-01-02Everywhere: Remove unused includes of LibC/stdlib.hBen Wiederhake
These instances were detected by searching for files that include stdlib.h, but don't match the regex: \\b(_abort|abort|abs|aligned_alloc|arc4random|arc4random_buf|arc4random_ uniform|atexit|atof|atoi|atol|atoll|bsearch|calloc|clearenv|div|div_t|ex it|_Exit|EXIT_FAILURE|EXIT_SUCCESS|free|getenv|getprogname|grantpt|labs| ldiv|ldiv_t|llabs|lldiv|lldiv_t|malloc|malloc_good_size|malloc_size|mble n|mbstowcs|mbtowc|mkdtemp|mkstemp|mkstemps|mktemp|posix_memalign|posix_o penpt|ptsname|ptsname_r|putenv|qsort|qsort_r|rand|RAND_MAX|random|reallo c|realpath|secure_getenv|serenity_dump_malloc_stats|serenity_setenv|sete nv|setprogname|srand|srandom|strtod|strtof|strtol|strtold|strtoll|strtou l|strtoull|system|unlockpt|unsetenv|wcstombs|wctomb)\\b (Without the linebreaks.) This regex is pessimistic, so there might be more files that don't actually use anything from the stdlib. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2022-12-26LibIPC: Remove requirement that Variant types must begin with EmptyTimothy Flynn
This is no longer required by the decoder.
2022-12-26LibIPC+Everywhere: Change IPC decoders to construct values in-placeTimothy Flynn
Currently, the generated IPC decoders will default-construct the type to be decoded, then pass that value by reference to the concrete decoder. This, of course, requires that the type is default-constructible. This was an issue for decoding Variants, which had to require the first type in the Variant list is Empty, to ensure it is default constructible. Further, this made it possible for values to become uninitialized in user-defined decoders. This patch makes the decoder interface such that the concrete decoders themselves contruct the decoded type upon return from the decoder. To do so, the default decoders in IPC::Decoder had to be moved to the IPC namespace scope, as these decoders are now specializations instead of overloaded methods (C++ requires specializations to be in a namespace scope).
2022-12-26IPCCompiler+LibIPC: Generate message decoders with better TRY semanticsTimothy Flynn
Instead of a bunch of manual error checking and returning a null OwnPtr, we can propagate the errors up and return NonnullOwnPtr on success.
2022-12-15LibIPC: Only run responsiveness timer when there is an event loopkleines Filmröllchen
This disables responsiveness detection when an event loop is absent. There are no users which both need this feature but don't have an event loop.
2022-12-15LibIPC: Add deferred invoker getterkleines Filmröllchen
2022-12-13LibIPC: Support sending Variants over IPCkleines Filmröllchen
The format is quite simply the type index followed by the type in its own native encoding; just implementing the receive side with static typing is a bit convoluted. The only limitation of this implementation is that the variant type has to contain an Empty somewhere as it is not default constructible otherwise. Co-authored-by: Ali Mohammad Pur <mpfard@serenityos.org>
2022-12-11LibIPC: Add a hook to MultiServer to inform owners of new clientsTimothy Flynn
This will allow the owner of the server to mutate the client after it has been accepted.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-11-24LibIPC: Handle `ECONNRESET` when reading from the IPC socketDaniel Bertalan
Reading from a socket with a dead peer returns the `ECONNRESET` error code in some cases on Linux. This commit changes LibIPC to gracefully shut down the socket if that happens, fixing an occasional crash in Ladybird. Fixes SerenityOS/ladybird#116
2022-11-19Everywhere: Remove unnecessary mutable attributes from lambdasMacDue
These lambdas were marked mutable as they captured a Ptr wrapper class by value, which then only returned const-qualified references to the value they point from the previous const pointer operators. Nothing is actually mutating in the lambdas state here, and now that the Ptr operators don't add extra const qualifiers these can be removed.
2022-11-15Userland: Properly define IPC::encode and IPC::decode specializationsTimothy Flynn
In order to avoid the base encode/decode methods from being used (and failing a static assertion), we must be sure to declare/define the custom type implementations as template specializations. After this, LibIPC is no longer sensitive to include order.
2022-11-15LibIPC: Forward declare the encode() and decode() template functionsTimothy Flynn
For the most part, we try to provide specializations of these functions in various headers by including "LibIPC/Forward.h" and then declaring encode() and decode() specializations. However, without any forward declaration of these types, we aren't actually specializing anything. Rather, we are just declaring overloads, which trips up the base encode and decode template definitions. The result is that LibIPC is very sensitive to include order, and the DependentFalse<> static assertion would fail if the includes weren't perfectly ordered. By properly forward declaring these templates, we can make sure the specializations receive precedence over the base templates.
2022-11-08AK+LibIPC: Add a convenience encoder/decoder for JsonValueTimothy Flynn
This requires that JsonValue is implicitly default-constructible.
2022-11-01Everywhere: Mark dependencies of most targets as PRIVATETim Schumacher
Otherwise, we end up propagating those dependencies into targets that link against that library, which creates unnecessary link-time dependencies. Also included are changes to readd now missing dependencies to tools that actually need them.
2022-11-01Everywhere: Explicitly link all binaries against the LibC targetTim Schumacher
Even though the toolchain implicitly links against -lc, it does not know where it should get LibC from except for the sysroot. In the case of Clang this causes it to pick up the LibC stub instead, which might be slightly outdated and feature missing symbols. This is currently not an issue that manifests because we pass through the dependency on LibC and other libraries by accident, which causes CMake to link against the LibC target (instead of just the library), and thus points the linker at the build output directory. Since we are looking to fix that in the upcoming commits, let's make sure that everything will still be able to find the proper LibC first.
2022-10-06LibIPC: Allow overriding the use of deferred_invoke()Andreas Kling
This will allow Ladybird to use IPC::Connection without having an actively running Core::EventLoop. The abstraction here is not great, and we should think of something nicer, but we have to start somewhere.
2022-10-06LibIPC: Remove platform-specific #ifdefs around FD passing in ConnectionAndreas Kling
Let the LocalSocket class decide if FD passing is supported or not.
2022-10-06LibIPC: Allow giving Connection a separate socket for FD passingAndreas Kling
Our IPC protocol currently relies on the behavior of recvfd() and sendfd() on SerenityOS, which provide an out-of-band queue that can be accessed independently of the in-band data stream. To make LibIPC usable on other platforms, this patch adds a mechanism where IPC::Connection can be given a dedicated socket for FD passing. This gives us the same behavior as the syscalls on SerenityOS, without having to change the protocol implementation.
2022-10-03SystemServer+LoginServer+Userland: Switch to sid-based socketsPeter Elliott
This commit does three things atomically: - switch over Core::Account+SystemServer+LoginServer to sid based socket names. - change socket names with %uid to %sid. - add/update necessary pledges and unveils. Userland: Switch over servers to sid based sockets Userland: Properly pledge and unveil for sid based sockets
2022-09-18Libraries: Add missing includes, add namespace qualifiersBen Wiederhake
This remained undetected for a long time as HeaderCheck is disabled by default. This commit makes the following file compile again: // file: compile_me.cpp #include <LibDNS/Question.h> // That's it, this was enough to cause a compilation error. Likewise for most other files touched by this commit.
2022-08-14LibCore+LibIPC: Recognise %uid in pathLucas CHOLLET
This patch allows to insert "%uid" in `IPC_CLIENT_CONNECTION` declaration and in SystemServer's ini files. This pattern is replaced then replaced by the UID of the owner of the service. It opens a path for seamlessly managed, per-user portal.