Commit Graph

1047 Commits

Author SHA1 Message Date
Matthew Olsson
a98ad191c7 Userland: Add ESCAPING annotations to a bunch of places
This isn't comprehensive; just a result of a simple grep search.
2024-05-22 21:55:34 -06:00
Dan Klishch
5a85067b49 Revert "LibCore: Add Core::deferred_invoke_if(F, Condition)"
This reverts commit a362c37c8b.

The commit tried to add an unused function that continued our tradition
of not properly waiting for things but instead flooding event loop with
condition checks that delay firing of the event. I think this is a
fundamentally flawed approach. See also checks for
`fire_when_not_visible` in LibCore/EventLoopImplementationUnix.cpp.
2024-05-21 23:32:54 +02:00
Ali Mohammad Pur
57714fbb38 RequestServer: Handle IPC requests on multiple threads concurrently
Previously RS handled all the requests in an event loop, leading to
issues with connections being started in the middle of other connections
being started (and potentially blowing up the stack), ultimately causing
requests to be delayed because of other requests.
This commit reworks the way we handle these (specifically starting
connections) by first serialising the requests, and then performing them
in multiple threads concurrently; which yields a significant loading
performance and reliability increase.
2024-05-20 08:03:35 +02:00
Ali Mohammad Pur
e003c0bf06 LibCore: Remove the spammy "too late for a reloading timer" debug log 2024-05-20 08:03:35 +02:00
Ali Mohammad Pur
96c7e83345 LibCore: Make Timers and Notifiers aware of threads
Previously sharing a Timer/Notifier between threads (or just handing
its ownership to another thread) lead to a crash as they are
thread-specific.
This commit makes it so we can handle mutation (i.e. just deletion
or unregistering) in a thread-safe and lockfree manner.
2024-05-20 08:03:35 +02:00
Ali Mohammad Pur
a362c37c8b LibCore: Add Core::deferred_invoke_if(F, Condition)
This will invoke the function F only if the provided Condition is met,
otherwise the execution of the function F will be further deferred.
2024-05-20 08:03:35 +02:00
Liav A
7e8dfe758c LibCore: Add a small library with only ArgsParser for DynamicLoader
This will be used in the DynamicLoader code, as it can't do syscalls via
LibCore code.
Because we can't use most of the LibCore code, we convert the versioning
code in Version.cpp to use LibC uname() function.
2024-05-14 15:42:42 -06:00
implicitfield
4574a8c334 Kernel+LibC+LibCore: Implement mknodat(2) 2024-05-14 22:30:39 +02:00
Sergey Bugaev
9d2d78c57c LibCore: Make MachPort build on GNU Mach 2024-05-02 07:46:53 -06:00
Andrew Kaster
05731f93b6 LibCore: Don't use designated initializers for struct cmsghdr
This can cause issues with older versions of glibc warning when not
initializing the flexible array member for CMSG_DATA. Such as glibc
shipped with Ubuntu 20.04.
2024-05-01 06:33:00 +02:00
Andrew Kaster
12a9702acb LibCore: Make singleton process helpers public 2024-04-27 20:32:12 -04:00
Andrew Kaster
70149079e4 LibCore: Add initializer for LocalServer from already connected socket 2024-04-27 20:32:12 -04:00
Timothy Flynn
207f3f1cb4 LibCore: Remove unnecessary lifetime extension from ProcessSpawnOptions
We don't need `file_actions` to be a constant-reference. It's created
in-place by its one user (HackStudio). Because it is currently a const-
ref, if we try to create a ProcessSpawnOptions like so:

    Core::ProcessSpawnOptions options { .name = "foo"sv };

We get the following error with clang 18:

    lifetime extension of temporary created by aggregate initialization
    using a default member initializer is not yet supported; lifetime of
    temporary will end at the end of the full-expression
2024-04-27 15:17:31 +02:00
Timothy Flynn
1560d6ad62 LibCore: Remove the now-obsolete SingletonProcess helper files 2024-04-24 15:51:58 -06:00
Timothy Flynn
c723fc9611 LibCore: Support launching a singleton process with an IPC connection
This largely adapts the code from SingletonProcess.cpp to work a bit
closer with Core::Process. Ideally, we'll move the daemonizing feature
into Core::Process::disown() eventually.
2024-04-24 15:51:58 -06:00
Timothy Flynn
8448897f14 LibCore: Implement a move operator for Core::Process
We implement the move constructor already. A future commit will have
code of the form:

    process = move(other_process);

which there is no reason to forbid.
2024-04-24 15:51:58 -06:00
Timothy Flynn
9986350e97 LibCore: Support launching a process with an IPC connection
Much of the code here is adapted from Ladybird. But rather than doing a
manual fork, we use Core::Process to spawn the underlying process.
2024-04-24 15:51:58 -06:00
Timothy Flynn
dc52404aec LibCore: Add a Core::Process action to close a file after spawning 2024-04-24 15:51:58 -06:00
Timothy Flynn
76af4503c1 LibCore: Return the singleton process's PID along with its IPC client
The PID will be used for Ladybird's task manager.
2024-04-22 14:46:10 -06:00
Timothy Flynn
bf50881e61 LibCore+LibSQL+LibWebView: Move launching a singleton process to LibCore
This just moves the code to launch a single process such as SQLServer to
LibCore. This will allow re-using this feature for other processes, and
will allow moving the launching of SQLServer to Ladybird.
2024-04-22 14:46:10 -06:00
Timothy Flynn
5dd3b91f0e LibCore+LibWebView: Move process statistics to LibCore
This will be needed to collect statistics from processes that do not
have anything to do with LibWebView. The ProcessInfo structure must be
virtual to allow callers to add application-specific information.
2024-04-22 14:46:10 -06:00
Shannon Booth
88b343061e LibCore: Make short_name optional for ArgsParser
This allows us to not need to pass through a 0 in many cases for
options which do not support a short value.
2024-04-22 08:10:08 +02:00
Andrew Kaster
a18c7c4405 LibCore: Let LocalSocket send and receive messages with SCM_RIGHTS
These new methods combine send/receive with send_fd/receive_fd.

This is the 'correct' way to use SCM_RIGHTS, rather than trying to
emulate the Serenity behavior on other Unixes.
2024-04-19 16:38:55 -04:00
Andrew Kaster
0e699743c4 LibCore: Move PosixSocketHelper's read EOF handling to a helper
We'll call this from upcoming LocalSocket methods directly
2024-04-19 16:38:55 -04:00
Nico Weber
0c935f8f42 LibGfx/JPEG2000: Support reading raw jpeg2000 codestreams
Most JPEG2000 files put the codestream in an ISOBMFF box structure
(which is useful for including metadata that's bigger than the
~65k marker segment data limit, such as large ICC profiles), but
some files just store the codestream directly, for example
https://sembiance.com/fileFormatSamples/image/jpeg2000/balloon.j2c

See https://www.iana.org/assignments/media-types/image/j2c for the
mime type.

The main motivation is to be able to use the test data in J.10 in
the spec as a test case.
2024-04-19 12:42:34 -04:00
Nico Weber
f2e381ae19 LibCore: Add ".jpf" as a JPEG2000 extension
This is what Photoshop uses for JPEG2000 outputs.
2024-04-19 12:42:34 -04:00
Nico Weber
2467374ea9 LibCore: Add comment with link to mime registry to MimeData.cpp 2024-04-19 12:42:34 -04:00
Dan Klishch
5ed7cd6e32 Everywhere: Use east const in more places
These changes are compatible with clang-format 16 and will be mandatory
when we eventually bump clang-format version. So, since there are no
real downsides, let's commit them now.
2024-04-19 06:31:19 -04:00
Aliaksandr Kalenik
fea58a4160 LibCore: Support xml in guess_mime_type_based_on_filename() 2024-04-18 08:10:05 +00:00
Andreas Kling
1cb5385a29 LibCore: Stop obsessing about tiny OOMs in Core::Timer
Work towards #20405
2024-04-17 07:16:52 +02:00
Andrew Kaster
77f18cf062 LibCore: Add a rough abstraction class around Mach port rights 2024-04-09 16:43:27 -06:00
Shannon Booth
9c9a378455 LibCore: Implement Core::System::hardware_concurrency() 2024-04-06 07:20:22 +02:00
Shannon Booth
aab5d4e6f9 LibCore: Prevent SIGPIPE on Sockets by default
While this is the default for an underlying socket, it doesn't seem good
to have this as the default for our socket wrapper.

This fixes a crash in ladybird when connecting to the python HTTP server
with HTTPS.
2024-04-05 16:02:46 +02:00
Timothy Flynn
c23060e21b Userland: Avoid some now-unneeded explicit conversions to Bytes 2024-04-04 11:23:21 +02:00
Shannon Booth
b169ffd1cf LibCore: Allow formatting a DateTime in GMT
HTTP dates are always expressed in GMT, so add an API to support that
behaviour.
2024-04-02 07:51:02 +02:00
Shannon Booth
86d29bd775 LibCore: Avoid narrowing conversion in DateTime::to_string 2024-04-02 07:51:02 +02:00
Shannon Booth
28307d0db6 LibCore: Add modified time to Resource
For now, all Resources are implemented with a modification time, but the
public API has been left as an Optional since abstractly, not all
resources will have a modification time.
2024-04-02 07:51:02 +02:00
Timothy Flynn
f6ea4bbff8 LibCore: Turn LibCoreMinimal into a normal shared library
We were able to keep LibCoreMinimal a bit smaller as an object library,
but that is causing ODR violations in the fuzzer build (realistically,
should be an issue in all builds, but only the fuzzer actively complains
for some reason).

To make it a shared library, we have to add a couple more symbols to it,
and make LibCore publicly depend on it.
2024-03-29 16:23:34 -04:00
Timothy Flynn
5ddfcfd07e LibCore+LibTimeZone: Move TZDB utilities from LibTimeZone to LibCore
We had weakly defined a couple utilities needed by Core::DateTime when
LibCore was unable to depend on LibTimeZone. This is no longer the case.
2024-03-26 12:25:21 -04:00
Timothy Flynn
f7ddcb1f98 LibCore: Separate some LibCore sources into a minimal object library
We have been dancing around circular dependencies between LibCore and
generated sources. For example, LibURL currently cannot depend on
LibUnicode because the LibUnicode generators depend on LibCore, and
LibCore depends on LibURL. LibTimeZone is in a similar situation.

To alleviate this, we can define the minimal sources that the code
generators need as an object library. This will allow the generators to
depend on this library, rather than the full LibCore.
2024-03-26 12:25:21 -04:00
Timothy Flynn
c8febe5169 LibCore: Update FIXME in LibCore's CMakeLists.txt
We have a FileWatcher implementation for macOS.
2024-03-26 12:25:21 -04:00
Nico Weber
1ab28276f6 LibGfx: Add the start of a JPEG2000 loader
JPEG2000 is the last image format used in PDF filters that we
don't have a loader for. Let's change that.

This adds all the scaffolding, but no actual implementation yet.
2024-03-25 20:35:00 +01:00
Ali Mohammad Pur
61148e9bc2 LibCore: Ignore timer events after stop() has been called 2024-03-25 14:16:55 +01:00
MINAqwq
e1598233e1 LibCore: Remove unnecessary or invalid write after child remove 2024-03-22 16:32:39 -04:00
Shannon Booth
e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00
Timothy Flynn
1f44c9468a LibCore: Replace MIME type description lookup with a more generic method
Rather than adding a bunch of `get_*_from_mime_type` functions, add just
one to get the Core::MimeType instance. We will need multiple fields at
once in Browser.
2024-03-16 08:42:33 +01:00
Timothy Flynn
a973fe13cb LibCore: Use Core::System::pipe2 for creating the event loops waking FDs 2024-03-13 12:52:07 -04:00
Timothy Flynn
40beebca71 LibCore: Apply the flags provided to System::pipe2 on all systems
We currently drop the flags on the floor for systems that do not have a
pipe2 syscall. Instead, use fcntl to set the flags.
2024-03-13 12:52:07 -04:00
Nico Weber
58838db445 LibGfx: Add the start of a JBIG2 loader
JBIG2 is infamous for two things:

1. It's used in xerox scanners were it falsifies scanned numbers:

https://www.dkriesel.com/en/blog/2013/0802_xerox-workcentres_are_switching_written_numbers_when_scanning

2. It was allegedly used in an iOS zero day, in a very cool way:

https://googleprojectzero.blogspot.com/2021/12/a-deep-dive-into-nso-zero-click.html

Needless to say, we need support for it in Serenity. (...because it's
used in PDF files.)

This adds all the scaffolding, but no actual implementation yet.

It's enough for `file` to print the mime type of .jb2 files, but `image`
can't do anything with the files yet.
2024-03-09 16:01:22 +01:00
Andrew Kaster
e09bfc1a8c LibCore: Recognize .mjs as a common extension for application/javascript 2024-03-06 07:19:10 +01:00