summaryrefslogtreecommitdiff
path: root/Libraries/LibCore
AgeCommit message (Collapse)Author
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-17LibCore: Make CIODevice::read_all() actually read all dataSergey Bugaev
It used to only read the data it could get without blocking. Andreas says this was intentional, but it's counterintuitive and no code that uses read_all() actually expects it to return only a part of the data. So change it to always read data until an EOF (or an error) is received.
2020-01-13LibCore: Fix segfault in CArgsParser (#1072)DrewStratford
CArgsParser::parse_next_param did not properly ensure that, when a param required a following argument, there were enough parameters left to complete the parse. This meant that params_left could become negative, avoiding parse_next_param's termination condition, and cause a segfault when reading from argv with an out of bounds index. This fixes the check to ensure that we do in fact have the right amount of parameters and also adds an assertion to ensure that params_left does not become negative.
2020-01-11SystemMonitor+LibCore: Show process pledges in SystemMonitor :^)Andreas Kling
2020-01-07LibCore: Fix a typo in CConfigFile.hConrad Pankoff
2020-01-05LibCore: Oops, we were forgetting to destroy disconnected RPC clientsAndreas Kling
2020-01-05AK+LibCore: Add an IDAllocator and use to allocate timer idsShannon Booth
2020-01-03LibCore: Fix crash on RPC client disconnectAndreas Kling
The RPC client management was not updated for the changes that made CObject reference-counted it seems. :^)
2020-01-03LibCore: Stop making the RPC sockets go=rwAndreas Kling
Now that we can fchmod() on a pre-bind() socket, use that to lock down the RPC sockets we publish in all CEventLoop-driven programs.
2020-01-02LibCore: CSocketAddress: pull in netinet/in.hjoshua stein
2019-12-30Kernel: Refactor scheduler to use dynamic thread prioritiesAndreas Kling
Threads now have numeric priorities with a base priority in the 1-99 range. Whenever a runnable thread is *not* scheduled, its effective priority is incremented by 1. This is tracked in Thread::m_extra_priority. The effective priority of a thread is m_priority + m_extra_priority. When a runnable thread *is* scheduled, its m_extra_priority is reset to zero and the effective priority returns to base. This means that lower-priority threads will always eventually get scheduled to run, once its effective priority becomes high enough to exceed the base priority of threads "above" it. The previous values for ThreadPriority (Low, Normal and High) are now replaced as follows: Low -> 10 Normal -> 30 High -> 50 In other words, it will take 20 ticks for a "Low" priority thread to get to "Normal" effective priority, and another 20 to reach "High". This is not perfect, and I've used some quite naive data structures, but I think the mechanism will allow us to build various new and interesting optimizations, and we can figure out better data structures later on. :^)
2019-12-30LibCore: Use JsonObject::get_ptr() in CProcessStatisticsReaderAndreas Kling
This removes a bunch of JsonValue copying from the hot path in thread statistics fetching. Also pre-size the thread statistics vector since we know the final size up front. :^)
2019-12-29LibCore+LibGUI: Don't fire timers in non-visible windows by defaultAndreas Kling
LibCore timers now have a TimerShouldFireWhenNotVisible flag which is set to "No" by default. If "No", the timer will not be fired by the event loop if it's within a CObject tree whose nearest GWindow ancestor is currently not visible for timer purposes. (Specificially, this means that the window is either minimized or fully occluded, and so does not want to fire timers just to update the UI.) This is another nice step towards a calm and serene operating system.
2019-12-29Kernel+SystemMonitor: Expose amount of per-process clean inode memoryAndreas Kling
This is memory that's loaded from an inode (file) but not modified in memory, so still identical to what's on disk. This kind of memory can be freed and reloaded transparently from disk if needed.
2019-12-29Kernel+SystemMonitor: Expose amount of per-process dirty private memoryAndreas Kling
Dirty private memory is all memory in non-inode-backed mappings that's process-private, meaning it's not shared with any other process. This patch exposes that number via SystemMonitor, giving us an idea of how much memory each process is responsible for all on its own.
2019-12-27LibCore: Allow LibCore to be compiled on macOS hostStefano Cristiano
Compiling LibCore on macOS is needed if one wants to compile host tools
(like IPCCompiler) on a non Linux host.
These changes could be possibly reverted once "event loop" functionality
and "base library" (Vector, String etc.) will be split in two separate libraries, updating all relevant projects.
2019-12-27LibCore: Fix errors when compiling LibCore using clang instead of gccStefano Cristiano
2019-12-25LibCore: compile puff.c as a separate objectjoshua stein
2019-12-23WindowServer+LibGUI: Implement basic color themingAndreas Kling
Color themes are loaded from .ini files in /res/themes/ The theme can be switched from the "Themes" section in the system menu. The basic mechanism is that WindowServer broadcasts a SharedBuffer with all of the color values of the current theme. Clients receive this with the response to their initial WindowServer::Greet handshake. When the theme is changed, WindowServer tells everyone by sending out an UpdateSystemTheme message with a new SharedBuffer to use. This does feel somewhat bloated somehow, but I'm sure we can iterate on it over time and improve things. To get one of the theme colors, use the Color(SystemColor) constructor: painter.fill_rect(rect, SystemColor::HoverHighlight); Some things don't work 100% right without a reboot. Specifically, when constructing a GWidget, it will set its own background and foreground colors based on the current SystemColor::Window and SystemColor::Text. The widget is then stuck with these values, and they don't update on system theme change, only on app restart. All in all though, this is pretty cool. Merry Christmas! :^)
2019-12-20Build: clean up build system, use one shared Makefilejoshua stein
Allow everything to be built from the top level directory with just 'make', cleaned with 'make clean', and installed with 'make install'. Also support these in any particular subdirectory. Specifying 'make VERBOSE=1' will print each ld/g++/etc. command as it runs. Kernel and early host tools (IPCCompiler, etc.) are built as object.host.o so that they don't conflict with other things built with the cross-compiler.
2019-12-14LibCore: Silence some aggressive CSocket and CHttpJob debug spamAndreas Kling
2019-12-14LibCore: Bump the CHttpJob receive buffer size from 4KB to 64KBAndreas Kling
4KB gets pretty mmap/munmap heavy when downloading larger files, so bump this a bit to reduce time spent in memory allocation. This can be improved in various ways, but I'm not sure what the best way forward is at the moment.
2019-12-10LibCore: Make CHttpJob::response() return a CHttpResponse*Andreas Kling
We know that the CNetworkResponse inside a CHttpJob is always going to be a CHttpResponse, so we can return a casted pointer to be nice. :^)
2019-12-09SystemMonitor: Show information about purgeable memoryAndreas Kling
This patch exposes some fields about purgeable memory regions. We now also show total purgeable volatile and non-volatile memory in the big process table.
2019-12-09AK: Use size_t for the length of stringsAndreas Kling
Using int was a mistake. This patch changes String, StringImpl, StringView and StringBuilder to use size_t instead of int for lengths. Obviously a lot of code needs to change as a result of this.
2019-12-08SystemMonitor: Show thread name instead of process nameAndrew Kaster
Add the thread name to CThreadStatistics and display it in the system monitor's process model instead of the process name.
2019-12-02LibIPC: Move IPC client/server connection templates to LibIPCAndreas Kling
Move over the CoreIPC::Server and CoreIPC::Client namespace stuff into LibIPC where it will soon becomes LibIPC-style things.
2019-12-02WindowServer: Port to the new IPC systemAndreas Kling
This patch introduces code generation for the WindowServer IPC with its clients. The client/server endpoints are defined by the two .ipc files in Servers/WindowServer/: WindowServer.ipc and WindowClient.ipc It now becomes significantly easier to add features and capabilities to WindowServer since you don't have to know nearly as much about all the intricate paths that IPC messages take between LibGUI and WSWindow. The new system also uses significantly less IPC bandwidth since we're now doing packed serialization instead of passing fixed-sized structs of ~600 bytes for each message. Some repaint coalescing optimizations are lost in this conversion and we'll need to look at how to implement those in the new world. The old CoreIPC::Client::Connection and CoreIPC::Server::Connection classes are removed by this patch and replaced by use of ConnectionNG, which will be renamed eventually. Goodbye, old WindowServer IPC. You served us well :^)
2019-12-01Kernel+SystemMonitor: Log amounts of I/O per threadAndreas Kling
This patch adds these I/O counters to each thread: - (Inode) file read bytes - (Inode) file write bytes - Unix socket read bytes - Unix socket write bytes - IPv4 socket read bytes - IPv4 socket write bytes These are then exposed in /proc/all and seen in SystemMonitor.
2019-12-01LibCore: Improve logging of errors in safe_syscall() somewhatAndreas Kling
2019-11-26Kernel: Make syscall counters and page fault counters per-threadAndreas Kling
Now that we show individual threads in SystemMonitor and "top", it's also very nice to have individual counters for the threads. :^)
2019-11-26Kernel: Expose per-thread information in /proc/allAndreas Kling
Previously it was not possible to see what each thread in a process was up to, or how much CPU it was consuming. This patch fixes that. SystemMonitor and "top" now show threads instead of just processes. "ps" is gonna need some more fixing, but it at least builds for now. Fixes #66.
2019-11-26SystemServer+LibCore: Implement socket takeoverSergey Bugaev
SystemServer can now create sockets on behalf of services before spawning any of them, and pass the open socket fd as fd 3. CLocalServer gains a method to complete the takeover and listen on the passed fd. This is not used by any services at the moment.
2019-11-26LibCore: Assert instead of crashing in CEventLoop::current()Sergey Bugaev
2019-11-26LibCore: Make CFile::open() truncate when opening something "WriteOnly"Andreas Kling
Unless we're also opening to append (and/or if the file is required to be a new file), CFile::open(WriteOnly) will now truncate the file.
2019-11-23LibCore: Move puff() from LibDraw to LibCoreAndreas Kling
Since it's used both by CGzip and PNGLoader, it seems most appropriate to keep this in LibCore.
2019-11-23LibCore: Have CNetworkJob protect itself during the on_finish callbackAndreas Kling
Otherwise, the callback may trigger the destruction of the CNetworkJob and make it difficult to continue execution correctly.
2019-11-23LibIPC+AudioServer: Allow unsolicited server-to-client IPC messagesAndreas Kling
Client-side connection objects must now provide both client and server endpoint types. When a message is received from the server side, we try to decode it using both endpoint types and then send it to the right place for handling. This now makes it possible for AudioServer to send unsolicited messages to its clients. This opens up a ton of possibilities :^)
2019-11-19Lagom: Fix buildAndreas Kling
2019-11-11LibCore: Add CConfigFile::open() for opening an arbitrary INI fileAndreas Kling
2019-11-10LibCore: Rename class Gzip -> CGZipMarcel Schneider
2019-11-10LibCore: Add Content-Encoding handling to CHttpJobMarcel Schneider
2019-11-10LibCore: Add a gzip implementationMarcel Schneider
2019-11-05LibCore+LibGUI: Allow inserting a CObject/GWidget before anotherAndreas Kling
When adding a widget to a parent, you don't always want to append it to the set of existing children, but instead insert it before one of them. This patch makes that possible by adding CObject::insert_child_before() which also produces a ChildAdded event with an additional before_child pointer. This pointer is then used by GWidget to make sure that any layout present maintains the correct order. (Without doing that, newly added children would still be appended into the layout order, despite having a different widget sibling order.)
2019-11-04LibCore: Make CTCPServer's local address/port getters return OptionalsAndreas Kling
2019-11-04LibCore: Constify CTCPServer's local_address() and local_port()Andreas Kling
2019-11-04LibCore: Add local_{address,port} functions to CTCPServerConrad Pankoff
2019-11-04LibCore: Flush outgoing IPC messages before trying to send a new oneAndreas Kling
This ensures that messages are sent in order.
2019-11-03LibCore: Put a limit on how many unsent messages an IPC server queuesAndreas Kling
This patch adds a limit of 200 unsent messages per client. If a client does not handle its incoming messages and we manage to queue up 200 messages for it, we'll now disconnect that client. :^)
2019-11-03LibCore: Have IPC server connections queue up unsendable messagesAndreas Kling
If an IPC client is giving us EAGAIN when trying to send him a message, we now queue up the messages inside the CoreIPCServer::Connection and will retry flushing them on next post/receive. This prevents WindowServer from freezing up when one of its clients is not taking care of its incoming messages.