8963 Commits

Author SHA1 Message Date
Philip Withnall
ff2c5c3e74
tests: Fix non-atomic accesses to atomic variables in cancellable test
As suggested by Marco Trevisan in !4206.

This might eliminate some spurious failures of the test.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-04 14:06:15 +00:00
Marco Trevisan (Treviño)
d7c8bb0726 gcancellable: Ignore cancelled callback on disposed source
Prevent to access to a disposed gsource in the GCancellable cancelled
signal callback.

Due to the fact that the signal is called in the same thread in which
the cancellable get cancelled, we may receive the callback just after
the GSource has been disposed or during its disposal.

To prevent this, let's pass to the signal a pointer to the source itself
and nullify atomically the first time we're calling a callback or
disposing it.

In case the dispose function wins the race, then the callback will just
do nothing, while the disposal will continue as expected.

In case the callback wins the race, during the concurrent disposal we'll
just wait for the callback to be completed, before returning the disposal
itself that will likely lead to freeing the GSource.

Closes: #3448
2025-02-04 13:01:03 +00:00
Philip Withnall
eec7ba6ef3 Merge branch '3592-dbus-serial-overflow' into 'main'
gdbusconnection: Prevent sending a serial of zero on overflow

Closes #3592

See merge request GNOME/glib!4470
2025-02-04 11:09:45 +00:00
Philip Withnall
f7a0e5f13f Merge branch 'wip/nacho/gregistry' into 'main'
Registry backend fixes

See merge request GNOME/glib!4468
2025-02-04 10:40:03 +00:00
Philip Withnall
8297bbc00c
gdbusmessage: Check that message serial is not set to zero
It’s disallowed by the D-Bus specification.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3592
2025-02-04 10:32:44 +00:00
Philip Withnall
b94b44407a
gdbusconnection: Prevent sending a serial of zero on overflow
It finally happened: someone managed to keep a process alive long
enough, and using a single `GDBusConnection`, to overflow the
`last_serial` counter in the connection and send an invalid message with
serial of zero (which is disallowed by the D-Bus specification).

Avoid that happening in future by skipping serials of zero on overflow,
and wrapping straight back around to 1.

This looks a little more confusing than it is, because `last_serial` is
pre-incremented on use, so to skip zero, we explicitly set it to zero.
This is exactly what happens when the `GDBusConnection` is initialised
anyway.

I can’t think of a way to add a unit test for this — there is no way to
affect the value of `last_serial` except by sending messages (each one
increments it), and in order to get it to overflow by sending messages
at 1kHz, the test would have to run for 49 days.

Instead, I tested this manually by temporarily modifying
`GDBusConnection` to initialise `last_serial` to `G_MAXUINT32 - 3`, then
checked that the unit tests all still passed, and that the overflow code
was being executed.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3592
2025-02-04 10:32:37 +00:00
Silvio Lazzeretti
23ad130b15 registrybackend: fix some memory leaks 2025-02-04 08:38:48 +01:00
Silvio Lazzeretti
f45b5ea776 registrybackend: make subscribe and unsubscribe thread-safe
The registry backend uses a thread to monitor
registry changes and send notifications.
The state of this thread and structures used
for communicating with it are kept in the watch
variable.
The subscribe and unsubscribe functions might be
concurrently called from multiple threads and
need to communicate with the monitoring thread.
For this reason we need to synchronize the access
to the watch variable.
2025-02-04 08:38:45 +01:00
Felix Xing
e99e27848e Add checking for <sys/ucred.h>
A new header check is added for non-standard <sys/ucred.h>. Some platforms, like Linux, might support <sys/param.h>, <sys/mount.h>, and <fstab.h> but not this. Which can cause compilation to fail for gio/gunixmounts.c
2025-02-03 09:19:17 -05:00
Felix Xing
a177c46b19 Add support for QNX8.0
This request brings support to the latest version of QNX software. _g_get_unix_mount_points (void) for getfsent() system also works on QNX. To avoid duplicating codes, it will be reused.
2025-01-31 09:18:02 -05:00
Andre Miranda
62d8d0b6ec gosxappinfo: Fix leak
Slightly reworked by Philip Withnall (any mistakes his).
2025-01-28 12:03:10 +00:00
Andre Miranda
8b64bb8751 gosxappinfo: Correctly launch list of files
Fixes #3587
2025-01-24 12:29:54 +00:00
Maximiliano
9d3c384565 gioenums: Add deprecation for FLAGS_NONE
g-ir won't pick it if it is not in its own doc block.

Requires
https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/512,
otherwise the deprecated tag won't be set in the introspection data.
2025-01-13 19:42:09 +00:00
Philip Withnall
6f6743de61
gfilteroutputstream: Fix duplicated property name in doc comment
Looks like a copy/paste error from the doc comment immediately below.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-31 13:05:02 +00:00
Michael Catanzaro
55fbcb21d9 Merge branch 'autorelease-urlspec' into 'main'
Use autorelease pool to manage cocoa memory.

Closes #3568

See merge request GNOME/glib!4448
2024-12-22 00:49:56 +00:00
John Ralls
d3705ecdcf g_osx_appinfo_launch: Use autorelease pool to manage cocoa memory.
Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/3568
2024-12-21 13:12:41 -08:00
Philip Withnall
fbe324086e Merge branch 'unix-mounts-docs' into 'main'
gunixmounts: Clarify GUnixMountMonitor documentation and convert to gi-docgen linking syntax

Closes #3569

See merge request GNOME/glib!4447
2024-12-20 18:40:04 +00:00
Philip Withnall
46160f9aad
gunixmounts: Convert docs to gi-docgen linking syntax
Improve formatting while I’m there, and try and ensure all the docs in
these two files matches the
[guidelines](https://developer.gnome.org/documentation/guidelines/devel-docs.html#writing-api-references).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3250
2024-12-20 15:11:41 +00:00
Philip Withnall
12f969eb79
gunixmounts: Consistently capitalise Unix in the documentation
Let’s not go with SHOUTY UNIX or quiet unix, let’s just call it what
Wikipedia calls it (https://en.wikipedia.org/wiki/Unix).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-20 12:42:58 +00:00
Philip Withnall
05afb30510
gunixmounts: Document caveats with *_changed_since() APIs
They need a `GUnixMountMonitor` to give valid timestamps, and if you
have one of those then you might as well listen to its signals anyway.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3569
2024-12-20 12:34:12 +00:00
Philip Withnall
2f010f5618
gunixmounts: Fix typo in deprecation documentation
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-20 12:25:22 +00:00
Philip Withnall
5029f3aae9
gio: Fix a link to a specifications document
If only someone would go ahead and invent a whole section of the list of
HTTP status codes which could be used to inform a client of where a
document has been moved to.

For the sake of argument, let’s say it could be status codes 300–399,
since they appear to be completely unused at the moment.

😩

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-12-19 23:09:17 +00:00
FeRD (Frank Dana)
9f016e5de4 Fix pointer-to-paramref syntax in docs
The documentation for GLib and Gio contains a number of documentation
comment blocks where a parameter reference (e.g. `@err`) is also
discussed in its dereferenced pointer form, which is generally
annotated as `*@err`. This inevitably confuses the MarkDown parser,
which sees the `*` as the beginning of an italicized text span.

To avoid this, replace all `*@foo` with <code>`*foo`</code>, which
loses the `@`-sigil linking it to the `@foo` parameter, but formats
correctly in the rendered documentation. (`@foo` is automatically
formatted like <code>`foo`</code>, so the resulting appearance in
the docs is as intended.)
2024-12-15 18:51:26 -05:00
Simon McVittie
a4d084e975 gio, gobject: Improve reproducibility of enumtypes headers
`@filename@` expands to the (absolute or relative) path from the
build directory to the source directory, which can be rather verbose.
In practice Meson usually (always?) generates a relative path, but
even so, the resulting installed header is not necessarily reproducible
if using different build directories outside the source directory.

We don't really need a full path here anyway: the basename is enough
of a hint to point a reader towards the file where the underlying
enum was defined.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-13 23:40:32 +00:00
fbrouille
d9844472a8 Add nullable annotations for GVfsFileLookupFunc
Add the nullable annotation on the parameter 'user_data'
and fix the description.
Add the nullable annotation on the return value.

Fixes #3561
2024-12-12 21:52:32 +00:00
Philip Withnall
cfa36f5e96 Merge branch '3559-revert-dbus-method-invocation-refcounting' into 'main'
Revert "gdbus: Fix leak of method invocation when registering an object with closures"

Closes #3559

See merge request GNOME/glib!4427
2024-12-11 12:41:16 +00:00
Sophie Herold
8be0a9af5b gdbus: Add nullable annotations for fd list outs 2024-12-10 22:23:56 +01:00
Philip Withnall
2442b370b4
gdbusconnection: Document existing refcount semantics of closures
As per the previous few commits, explicitly document the established
reference counting semantics of the method call closure for
`g_dbus_connection_register_object_with_closures()`.

This isn’t ideal, but
`g_dbus_connection_register_object_with_closures()` has had these
semantics for 10 years now, and it’s a bit late to change them to
something neater.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3559
2024-12-10 16:59:33 +00:00
Philip Withnall
25cbde1e16
gdbusconnection: Add a comment explaining why an invocation is ‘leaked’
It’s not leaked, it’s transferred forwards to the eventual
`g_dbus_method_invocation_return_*()` call.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3559
2024-12-10 15:59:04 +00:00
Philip Withnall
4641535596
Revert "gdbus: Fix leak of method invocation when registering an object with closures"
This reverts commit 092fedd5f085a2f1966b5c34befe8b603c1a0f07.

This was not the right change to make, and I shouldn’t have accepted the
MR. The situation is laid out in this comment:
https://gitlab.gnome.org/GNOME/glib/-/issues/2600#note_1385050

tl;dr: The reference on the `GDBusMethodInvocation` which is transferred
in to the `GDBusInterfaceMethodCallFunc` is balanced by a reference
transferred to `g_dbus_method_invocation_return_*()`. This is how the
refcounting has always worked for these functions, and even if we’d
probably arrange things differently if the code was written now, we
can’t change those semantics without breaking API.

In particular, bindings have various bits of custom code to account for
these reference tranfers (since they can’t be represented using
gobject-introspection annotations), so changing the semantics will break
bindings.

Fixes: #3559
2024-12-10 15:53:54 +00:00
Philip Withnall
8c3fda5c8d
tests: Skip unsupported dbus-appinfo test on GNU/Hurd for the moment
Parts of the `dbus-appinfo` test need support for converting an FD to a
path, and Hurd doesn’t currently allow that (see
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4396#note_2279923).

Since there’s no fix for that visible in the medium term (new kernel
APIs will need to be added), skip parts of the `dbus-appinfo` test which
require that functionality for now.

This prevents the whole test from failing, and means we can usefully get
results from the parts of it which don’t depend on converting FDs to
paths.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3538
2024-12-10 11:47:43 +00:00
Michael Catanzaro
c5f9eb51a2 Merge branch 'gio-tool-mount-docs' into 'main'
gio-tool: Clarify that `gio mount -l` only lists user-interesting things

See merge request GNOME/glib!4423
2024-12-09 14:32:21 +00:00
Philip Withnall
fa33e232d2
gio-tool: Clarify that gio mount -l only lists user-interesting things
It doesn’t list all mounts, only the ones you’d expect to see in a file
chooser sidebar.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3555
2024-12-08 23:03:07 +00:00
Martin Domig
70fe6839a5 Fix typo in test_extended_schema
Signed-off-by: Martin Domig <martin.domig@wolfvision.net>
2024-12-08 22:15:03 +01:00
Martin Domig
d63d27b195 Add test for g_settings_schema_has_key on extended schema
The test checks that the keys of the base schema do all exist in the
extended schema.

Signed-off-by: Martin Domig <martin.domig@wolfvision.net>
2024-12-08 22:13:51 +01:00
Johannes Marte
58f9667def GSettingsSchema: fix g_settings_schema_has_key()
A settings schema that extends another schema should return TRUE for
all keys that are present in the extended schema. The list of keys
returned by list_keys() already includes these,
so it makes sense to include them in has_key().

Signed-off-by: Johannes Marte <johannes.marte@wolfvision.net>
2024-12-06 08:06:18 +01:00
Philip Withnall
f3a82ba866 Merge branch 'gdbus-missing-nullable' into 'main'
gdbus: Add a few missing `(nullable)` annotations to GDBus method invocation related functions

See merge request GNOME/glib!4414
2024-12-04 08:37:40 +00:00
Sebastian Dröge
f5678377c0 gdbus: Add a few missing (nullable) annotations to GDBus method invocation related functions
Sender can be NULL if not specified by the caller, e.g. on peer-to-peer
connections.

Interface name can be NULL on method calls if it was not specified by
the sender.

Both is explicitly allowed by the DBus specification.
2024-12-03 06:22:52 +00:00
Sebastian Dröge
092fedd5f0 gdbus: Fix leak of method invocation when registering an object with closures
The invocation passed in is owned by the callback.
2024-12-02 16:46:17 +00:00
Philip Withnall
c64f82fa79 Merge branch 'wip/pwithnall/procfs-refactor' into 'main'
tests: Factor out a function to convert FD to path

See merge request GNOME/glib!4396
2024-11-26 12:06:28 +00:00
tytan652
9335698b87 gdbusconnection: Allow creating connection with cross-namespace 2024-11-25 17:42:27 +01:00
Philip Withnall
2b155f86dd Merge branch 'update-macos-min' into 'main'
Raise minimum supported macOS version to 10.13 (High Sierra)

Closes #3441

See merge request GNOME/glib!4405
2024-11-21 11:13:04 +00:00
John Ralls
9bbb1acd7d Raise minimum supported macOS version to 10.13 (High Sierra).
Allows removing all macOS version ifdefs.

Closes https://gitlab.gnome.org/GNOME/glib/-/issues/3441
2024-11-20 18:15:34 -08:00
Philip Withnall
ccee4c2342 Merge branch 'feature/gresource-static-validate-args' into 'main'
gio/gresource: validate args of g_static_resource_init

Closes #3517

See merge request GNOME/glib!4372
2024-11-19 18:10:18 +00:00
Philip Withnall
dfe252429c Merge branch 'uninstalled_variables' into 'main'
meson: Add variables to -uninstalled.pc files

See merge request GNOME/glib!4399
2024-11-19 12:01:06 +00:00
Philip Withnall
0a48bfe79a
tests: Factor out a function to convert FD to path
This could potentially eventually become a public GLib API, but there
doesn’t seem to be a huge need for it right now (e.g. this file contains
the only use of `/proc/self/fd/%d` in GLib), so let’s keep it private
for now and avoid committing to API stability just yet.

This gives time for other platforms to add their platform-specific
implementations for it too, if they need. I’ve added a couple of
pointers to what I *think* the right APIs might be, from my research,
but I have not prototyped those implementations.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-11-19 11:54:25 +00:00
Sebastian Geiger
ccf4403e39 gio/gresource: validate args of g_static_resource_init
Signed-off-by: Sebastian Geiger <sbastig@gmx.net>
2024-11-17 13:18:06 +01:00
Benjamin Otte
33b9338fb0 converteroutputstream: Raise error for data at end
When a conversion is finished, the code would return 0 from its write
vfunc. This is disallowed by the API of g_output_stream_write() and
causes g_output_stream_splice() as used by g_converter_convert_bytes()
to turn into an infinite loop.

Instead, raise a G_IO_ERROR_MESSAGE_TOO_LARGE error so that the calling
code can decide how to deal with it.

Testcase included.

Closes #3532
2024-11-16 07:46:24 +00:00
Xavier Claessens
0b776bc20c meson: Add variables to -uninstalled.pc files
This allows building a glib project within glib's devenv. Otherwise
Meson won't find glib tools.
2024-11-13 11:07:12 -05:00
Philip Withnall
7dacfa7799 Merge branch 'wip/hadess/test-warning-fix' into 'main'
appmonitor: Fix warning building test

See merge request GNOME/glib!4395
2024-11-13 13:40:45 +00:00