summaryrefslogtreecommitdiff
path: root/Libraries/LibIPC
AgeCommit message (Collapse)Author
2020-11-25LibIPC: Fix 'unused private member' error when building with clangLinus Groh
This was breaking the Lagom build when using clang, as m_sockfd's only use is behind an #ifdef __serenity__. (void) it elsewhere to fix that.
2020-11-23LibIPC: Support sending file descriptors :^)Sergey Bugaev
It is now possible to use the special IPC::File type in message arguments. In C++, the type is nothing more than a wrapper over a file descriptor. But when serializing/deserializing IPC::File arguments, LibIPC will use the sendfd/recvfd kernel APIs instead of sending the integer inline. This makes it quite convenient to pass files over IPC, and will allow us to significantly tighten sandboxes in the future :^) Closes https://github.com/SerenityOS/serenity/issues/3643
2020-11-23LibIPC: Prepend each message with its sizeSergey Bugaev
This makes it much simpler to determine when we've read a complete message, and will make it possible to integrate recvfd() in the future commit.
2020-11-08LibIPC: Add support for passing around ByteBuffers and HashMap<K, V>AnotherTest
It should be noted that using a shared buffer should still be preferred over passing a raw ByteBuffer over the wire.
2020-10-25LibIPC: Handle partial messagesAndreas Kling
Since we're using byte streamed Unix sockets for the IPC protocols, it's possible for the kernel to run out of socket buffer space with a partial message near the end of the buffer. Handle this situation in IPC::Connection by buffering the bytes of what may be a partial message, and prepending them to the incoming data next time we receive from the peer. This fixes WindowServer asserting when a peer is spamming it hard.
2020-10-04LibIPC: Make IPC::encode() and ::decode() fail at compiletime when usedAnotherTest
This would previously fail at runtime, and it would have zero indication of what exactly went wrong. Also adds `AK::DependentFalse<Ts...>', which is a...dependent false.
2020-10-01LibIPC: Silence a warning when compiling with gcc -O0Andreas Kling
2020-09-21LibIPC: Use InputMemoryStream instead of BufferStream.asynts
2020-09-17LibIPC: Check if socket is still open before using socket descriptorTom
Writing to the socket may trigger a close of the socket descriptor if a disconnect was detected. We need to check if it is still valid when waiting for a response after attempting to send a synchronous message. Fixes #3515
2020-09-16LibIPC: Disable Notifier before closing socketTom
Because we're closing a file descriptor, we need to disable any Notifier that is using it so that the EventLoop does not use invalid file descriptors. Fixes #3508
2020-09-12LibIPC: Remove unused DisconnectedEvent mechanismAndreas Kling
This was previously used to defer handling disconnections until the next event loop iteration. We now achieve the same with simple use of deferred_invoke(). :^)
2020-09-12LibIPC: Move notifier handling entirely to IPC::Connection base classAndreas Kling
2020-09-12LibIPC: Remove debug spam on disconnectionAndreas Kling
2020-09-12LibIPC: Share most of the code between {Client,Server}ConnectionAndreas Kling
This patch introduces IPC::Connection which becomes the new base class of ClientConnection and ServerConnection. Most of the functionality has been hoisted up to the base class since almost all of it is useful on both sides. This gives us the ability to send synchronous messages in both directions, which is needed for the WebContent server process. Unlike other servers, WebContent does not mind blocking on a response from its client.
2020-09-05Clipboard: Add a key-value map alongside the clipboard storageAndreas Kling
A clipping now consists of three things: - The raw clip data - A MIME type - A key-value map (String, String) for anything you like
2020-08-03LibIPC: Fix waiting for specific messageTom
When waiting for a specific message, only consider messages from the peer endpoint. Otherwise a message with the same id for the local endpoint may be misinterpreted. This fixes the Terminal sometimes hanging after bootup because a local endpoint message is mistaken for the CreateMenuResponse message.
2020-07-15LibIPC: Tweak a misleading perror()Andreas Kling
If we get an error from recv(), let's blame "recv" instead of "read".
2020-07-06LibIPC+Services: Make ClientConnection take socket as NonnullRefPtrAndreas Kling
This avoids getting into the awkward situation where the socket is still part-owned by main() in multi-instance service. Also it just reads nicer.
2020-07-03LibIPC: Don't assert on short writes in IPC::ClientConnectionAndreas Kling
This stops servers from crashing when a client's socket buffer becomes full and we can't post any more messages to it. Normally this means the client process is hanged/spinning, but I suppose this could also happen under severe system load. It's unclear to me what a better solution here would be. We can't keep buffering messages indefinitely if the client is just never going to receive them anyway. At some point we have to cut our losses, and it seems pretty reasonable to let the kernel socket buffer be the cutoff. It will be the responsibility of the individual server implementations to avoid sending messages to clients that may be unable to handle them.
2020-06-22LibIPC: Silence some debug spamAndreas Kling
2020-06-21LibIPC: Add setters for overriding the client/server PID if neededAndreas Kling
Since SO_PEERCRED can only tell us who originally accepted the socket on the other side, we'll sometimes need to negotiate PID info manually.
2020-06-13LibIPC: Only start responsiveness timer after sending client a messageAndreas Kling
Instead of always running the responsiveness timer for IPC clients, we now only start it after sending a message. This avoids waking up otherwise idle clients to do ping/pong busywork.
2020-06-12LibIPC: Use create_single_shot to construct timerKevin Meyer
2020-06-12LibIPC: Actually use the new Core::Timer::restart() I just addedAndreas Kling
Thanks @brynet for noticing. :^)
2020-06-11LibIPC+WindowServer+LibGUI: Detect and highlight unresponsive GUI appsAndreas Kling
IPC::ClientConnection now tracks the time since the last time we got a message from the client and calls a virtual function on itself after 3 seconds: may_have_become_unresponsive(). Subclasses of ClientConnection can then react to this if they like. We use this mechanism in WindowServer to send out a friendly Ping message to the client. If he doesn't Pong within 1 second, we mark the client as "unresponsive" and recompose all of his windows with a darkened appearance and amended title until he Pongs us. This is a little on the aggressive side and we should figure out a way to wake up less often. Perhaps this could only be done to windows the user is currently interacting with, for example. Anyways, this is pretty cool! :^)
2020-06-08LibIPC+LibGfx+IPCCompiler: Drop some unused includesSergey Bugaev
2020-06-07LibIPC+Services: Support URL as a native IPC typeAndreas Kling
2020-05-30LibIPC: Fix server crashes on client disconnectsSergey Bugaev
The server should always survive client communication errors.
2020-05-14Build: Switch to CMake :^)Sergey Bugaev
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-12LibIPC+IPCCompiler: Templatize encoding/decoding of Optional<T>Andreas Kling
This was the last one! IPCCompiler no longer has any type-specific encoding/decoding logic! :^)
2020-05-12LibIPC+LibGfx: Templatize IPC encoding as well as decodingAndreas Kling
Now most classes dictate how they are serialized and deserialized when transmitted across LibIPC sockets. This also makes the IPC compiler a bit simpler. :^)
2020-05-09Meta: Delete empty .cpp filesLinus Groh
2020-05-08LibIPC: Use NonnullOwnPtrVector<Message> in IPC::ServerConnectionAndreas Kling
We never want to store null messages, so make it impossible to do so.
2020-05-03LibIPC: Add a simple IPC::Dictionary type (String key -> String value)Andreas Kling
2020-05-02LibIPC: Abort on connection failureSergey Bugaev
...instead of looping for (effectively) ever. Fixes https://github.com/SerenityOS/serenity/issues/1869
2020-04-05AK: Stop allowing implicit downcast with OwnPtr and NonnullOwnPtrAndreas Kling
Same issue here as we had with RefPtr and NonnullRefPtr. Since we can't make copies of an owning pointer, we don't get quite the same static_ptr_cast<T> here. Instead I've only added a new templated version of OwnPtr::release_nonnull() in this patch, to solve the only issue that popped up. I'm not sure what the best solution here is, but this works for now.
2020-03-29LibIPC+LibGfx: Pass the IPC::Decoder to decoding helpersAndreas Kling
Instead of passing the BufferStream, pass the Decoder. I'd like to stop using BufferStream eventually anyway, so it's good to get it out of any API's where it's in currently.
2020-03-29LibIPC: Add forwarding header for LibIPCAndreas Kling
2020-03-01AK: Remove unnecessary casts to size_t, after Vector changesAndreas Kling
Now that Vector uses size_t, we can remove a whole bunch of redundant casts to size_t.
2020-02-25AK: Make Vector use size_t for its size and capacityAndreas Kling
2020-02-16LibGUI: Add forwarding headerAndreas Kling
This patch adds <LibGUI/Forward.h> and uses it a bunch. It also dragged various header dependency reduction changes into it.
2020-02-15LibIPC+IPCCompiler: Add IPC::Decoder, let classes decode themselvesAndreas Kling
This shaves ~5 seconds off of a full build, not too bad. Also it just seems nicer to push this logic out to classes. It could be better but it's a start. :^)
2020-02-15LibIPC: Move IPC::Encoder functions out of lineAndreas Kling
Compiling anything that includes generated IPC messages is painfully slow at the moment. This moves the encoding helpers out of line, which helps a bit. Doing the same for decoding will help more.
2020-02-15LibIPC+IPCCompiler: Remove some unused members from generated messagesAndreas Kling
2020-02-14LibCore: Add a forward declaration headerAndreas Kling
This patch adds <LibCore/Forward.h> and uses it in various places to shrink the header dependency graph.
2020-02-14AK: Add a forward declaration headerAndreas Kling
You can now #include <AK/Forward.h> to get most of the AK types as forward declarations. Header dependency explosion is one of the main contributors to compile times at the moment, so this is a step towards smaller include graphs.
2020-02-06LibCore: Merge the CSyscallUtils namespace into CoreAndreas Kling
2020-02-06LibCore: Remove leading C from filenamesAndreas Kling
2020-02-06LibIPC: Remove leading I from filenamesAndreas Kling
2020-02-05LibIPC: Remove IPC::Encoder overloads for size_tAndreas Kling
Clients of this code should use explicitly-sized types instead.