Commit Graph

8656 Commits

Author SHA1 Message Date
Luca Bacci
c515f793e5 GWinHttpFile: Set display-name and type at the start of the query_info() function
Those attributes do not need the HTTP(S) request data, so just set them
right away.
2024-02-21 11:52:36 +01:00
Ondrej Holy
bf7d941088 gcontextspecificgroup: Wait until stop_func is done
Currently, the `stop_func` is executed on an extra thread, and the
`g_context_specific_group_remove` function returns before the `stop_func`
finishes. It may happen that the `stop_func` is never executed if the
program terminates soon after calling it. Let's wait until the `stop_func`
is done.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/3258
2024-02-20 13:39:31 +01:00
Philip Withnall
43924f7cf5 Merge branch 'fix-issue-3210' into 'main'
GWinHttpFile: Add support for G_FILE_ATTRIBUTE_STANDARD_TYPE

Closes #3210

See merge request GNOME/glib!3908
2024-02-14 09:22:36 +00:00
Luca Bacci
6ee0772146 GWinHttpFile: Add support for G_FILE_ATTRIBUTE_STANDARD_TYPE
Fixes #3210
2024-02-14 10:06:50 +01:00
Philip Withnall
434d3ff524 docs: Mention GioUnix-2.0 GIR namespace alongside gio-unix-2.0.pc
This should clarify things a little for users of language bindings, who
don’t directly use `.pc` files.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-12 17:54:10 +00:00
Philip Withnall
c498c9a8c9 docs: Split out platform specific GIO and GLib documentation
This creates `GioUnix`, `GioWin32`, `GLibUnix` and `GLibWin32`. These
bodies of documentation are in addition to the main, platform agnostic,
documentation for both libraries.

This commit necessarily includes various mechanical changes to update
the repository namespace used in various existing documentation links to
platform specific APIs.

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

Helps: #3037
2024-02-12 17:54:10 +00:00
Philip Withnall
0d9170c6b8 gio: Remove unnecessary appinfo_sources variable
There was no obvious logical need to list the `GAppInfo` subclass
sources separately in the build. It makes more sense to add them to the
platform-specific source lists, since they are platform specific.

This will be used in an upcoming commit which generates
platform-specific GIR files, so needs the full platform-specific lists
of sources.

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

Helps: #3037
2024-02-12 17:54:10 +00:00
Philip Withnall
f63cc38328 gfiledescriptorbased: Move across typedef from giotypes.h
`GFileDescriptorBased` is in `gio-unix-2.0` rather than `gio-2.0`, so
its types shouldn’t be declared in a header belonging to the latter.

This hasn’t been a problem previously because C is fine with that. But
upcoming commits are going to split the introspection scanning for
`gio-2.0` and `gio-unix-2.0`, and the introspection scanner is a little
more picky about declarations not being spread all over the place.

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

Helps: #3037
2024-02-12 17:54:10 +00:00
Philip Withnall
2cacc09398 Merge branch '3231-gir-symbols-cleanup' into 'main'
introspection: Remove various public symbols from newly generated GIRs

Closes #3231

See merge request GNOME/glib!3910
2024-02-09 10:58:29 +00:00
Philip Withnall
71801e445e gthreadedresolver: Move private testing symbols to a private header
The symbols still have to be exported from the library (since they’re
called from unit tests), but there was never any reason for them to be
in a public header.

This means they now disappear from `Gio-2.0.gir`.

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

Helps: #3231
2024-02-09 10:05:56 +00:00
Maxim Moskalets
cbcb35a77a gapplication: add GApplication:version property
This property is supposed to be used by authors of applications that use GAppliaction to output the version by --version flag or otherwise if a version is needed.

Closes #3198

Signed-off-by: Maxim Moskalets <Maxim.Moskalets@kaspersky.com>
2024-02-09 10:04:14 +00:00
Luca Bacci
665ab65e7e file_copy_fallback: Check if attributes could be retrieved
See #3210
2024-02-08 17:11:01 +01:00
Michael Catanzaro
b7ef29560d Merge branch 'statvfs-type' into 'main'
glocalfile: Support statvfs.f_type

See merge request GNOME/glib!3893
2024-02-07 14:24:52 +00:00
Philip Withnall
9eeb8a87d3 glocalfile: Support statvfs.f_type
This is another way to get the file system type from `statvfs()`, newly
added in glibc 2.39
(https://lwn.net/ml/libc-alpha/38790850.J2Yia2DhmK@pinacolada/).

This hasn’t been tested with glibc 2.39 as I don’t have it, but the
change seems fairly straightforward.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 10:34:59 +00:00
Philip Withnall
90ec3d3499 gtask: Clarify when GTask:completed is suitable to use
It’s not suitable to use to check if your own code has already called
`g_task_return_*()`, as it doesn’t directly correlate to that.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 10:34:08 +00:00
Philip Withnall
15cef2ea59 gfiledescriptorbased: Fix incorrect precondition return value
`0` is a valid FD, `-1` is not, so `-1` is more suitable to use.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 10:34:08 +00:00
Simon McVittie
fc7942f46b gdbus-codegen: If writing body to stdout, don't try to include header
If we're writing the body to standard output, we cannot know what the
filename of the corresponding header is going to be, but it seems
vanishingly unlikely that it will be either `stdout.h` (which we would
traditionally have generated) or `-.h` (which we would have generated
since !3886).

This makes some of the output snippets sufficiently short that black(1)
requires that they are folded into a single line.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 14:06:45 +00:00
Simon McVittie
5e8f053d33 tests: Exercise gdbus-codegen --interface-info-header with empty input
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 13:55:35 +00:00
Simon McVittie
02a3417ac4 tests: Exercise gdbus-codegen --interface-info-body with empty input
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 13:55:33 +00:00
Simon McVittie
6a1fdb8145 codegen: Use - instead of stdout for output to stdout
In command-line tools, ordinary filenames normally do not have
special-cased meanings, so commit 3ef742eb "Don't skip dbus-codegen tests
on Win32" was a command-line API break: in the unlikely event that a
user wanted to write to a file named exactly `stdout`, this would have
been an incompatible change.

There is a conventional pseudo-filename to represent standard output,
which is `-` (for example `cat -` is a no-op filter). Adding support
for this is technically also a command-line API break (in the very
unlikely event that a user wants to write to a file named exactly `-`,
they would now have to write it as `./-`), but filenames starting with
a dash often require special treatment anyway, so this probably will not
come as a surprise to anyone.

When the output filename is `-` we don't want to use `#ifdef _____` as
a header guard, so special-case it as `__STDOUT__` as before.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 11:53:06 +00:00
Philip Withnall
1757365af3 Merge branch 'dbus-codegen-tests' into 'main'
Don't skip dbus-codegen tests on Win32

Evolved from https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3857

See merge request GNOME/glib!3874
2024-02-05 10:18:28 +00:00
Maxim Moskalets
aa8ed92fba gresources: fix memory leak from libelf
Memory was leaking when allocating it inside libelf and losing the pointer to it (it was an automatic variable) when returning NULL from the get_elf function in some cases

Closes #3242

Signed-off-by: Maxim Moskalets <Maxim.Moskalets@kaspersky.com>
2024-02-03 15:23:15 +03:00
Jordan Petridis
9c65e9ba2d gio: tests: Use slightly more explicit assert functions
Found by using teyit [1] on the code

https://github.com/isidentical/teyit
2024-02-02 16:15:35 +02:00
Philip Withnall
5744f55c11 Revert "Don't skip dbus-codegen tests on Win32"
This reverts commit fbdc9a2d03.

It was not submitted through a merge request and broke CI. Reverting it
immediately to unbreak CI and hence the rest of the development
pipeline. The changes can be re-submitted as a merge request so they’re
properly tested in CI before being merged.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3857#note_1994336
2024-02-02 10:01:24 +00:00
John Ralls
fbdc9a2d03 Don't skip dbus-codegen tests on Win32
And coincidentally on Darwin either.
2024-02-01 15:17:26 -08:00
Philip Withnall
5f12851312 Merge branch 'wip/oholy/libmnt_monitor' into 'main'
gunixmounts: Use libmnt_monitor API for monitoring

See merge request GNOME/glib!3845
2024-01-31 14:30:09 +00:00
Ondrej Holy
c7254fb3ad gunixmounts: Use mnt_monitor_veil_kernel option
The previous commit enabled the `/run/mount/utab` monitoring. The problem
is that the `mount-changed` signal can be emitted twice for one mount. One
for the `/proc/mounts` file change and another one for the `/run/media/utab`
file change. This is still not ideal because e.g. the `GMount` objects for
mounts with the `x-gvfs-hide` option are added and immediately removed.
Let's enable the `mnt_monitor_veil_kernel` option to avoid this.

Related: https://github.com/util-linux/util-linux/pull/2725
2024-01-31 14:53:42 +01:00
Ondrej Holy
1abbbd761e gunixmounts: Use libmnt_monitor API for monitoring
The `GUnixMountMonitor` object implements monitoring on its own currently.
Only the `/proc/mounts` file changes are monitored. It is not aware of the
`/run/mount/utab` file changes. This file contains the userspace mount
options (e.g. `x-gvfs-notrash`, `x-gvfs-hide`) among others. There is a
problem when `/sbin/mount.<type>` (e.g. `mount.nfs`) helper programs are
used. In that case, the `/run/mount/utab` file is updated later than the
`/proc/mounts` file and thus the `GUnixMountMonitor` clients (e.g.
`gvfs-udisks2-volume-monitor`, `gvfsd-trash`) don't see the userspace
options until the next `mount-changed` signal. Let's use the `libmnt_monitor`
API for monitoring instead and emit the `mount-changed` signal also when the
`/run/mount/utab` file is changed.

Related: https://issues.redhat.com/browse/RHEL-14607
Related: https://github.com/util-linux/util-linux/pull/2607
2024-01-31 14:53:42 +01:00
Michael Catanzaro
936bb9ecfb Merge branch 'memory-monitor-portal-fix' into 'main'
tests: Fix typo in memory-monitor-portal.py.in

See merge request GNOME/glib!3860
2024-01-30 16:39:09 +00:00
Philip Withnall
8da4fc17b9 gthreadedresolver: Fix leak on error path
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3236
2024-01-30 09:53:00 +00:00
Philip Withnall
b2144afe28 tests: Fix typo in memory-monitor-portal.py.in
This was my mistake in commit 67a9fbf1fa.

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

Helps: #3237
2024-01-30 07:38:13 +00:00
John Ralls
3ef742ebee Don't skip dbus-codegen tests on Win32
And coincidentally on Darwin either.
2024-01-28 20:07:44 -08:00
Philip Chimento
28835733a2 tests: Fix defaultvalue test on macOS
Without these includes, the g_osx_app_info_get_type() in
giotypefuncs.inc is missing a declaration.
2024-01-23 21:35:54 -08:00
Philip Withnall
67a9fbf1fa tests: Wait for memory monitor to be able to handle signals before testing
This fixes a race condition which frequently caused the
`memory-monitor-dbus.py` test to fail.

The registration of the `LowMemoryMonitor` object on the bus, and the
`GMemoryMonitorDBus`’s connection to the warning signal raced, such that
it was possible for the mock `LowMemoryMonitor` to emit a warning signal
before the `GMemoryMonitorDBus` proxy was listening, and hence the proxy
would never see the signal.

Fix this by explicitly synchronising the two before proceeding to the
tests.

Make the same changes in the `memory-monitor-portal.py` test too, even
though that one was not failing. This should remove the need for a 2s
wait on every test run.

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

Fixes: #2887
2024-01-23 11:02:48 +00:00
Philip Withnall
e0276a3a17 tests: Wait for LMM server to be available when starting test
Otherwise the test can go on to wait for a signal from the service
before it’s actually finished starting up.

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

Helps: #2887
2024-01-23 11:02:48 +00:00
Philip Withnall
1f2d9e69c9 tests: Assert correct monitor implementation is used in power-profile-monitor-dbus
This wasn’t failing, but it seems like a sensible thing to check.

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

Helps: #2887
2024-01-23 11:02:48 +00:00
Philip Withnall
6b22aaaa68 tests: Assert correct monitor implementation is used in memory-monitor-dbus
This wasn’t failing, but it seems like a sensible thing to check.

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

Helps: #2887
2024-01-23 11:02:48 +00:00
Philip Withnall
e3b81b3f0d tests: Rework assertEventually() to use GLib main context
Rather than sleeping and blocking everything, use a timeout source on
the main context so that inputs can continue to be handled while waiting
for a timeout.

This introduces no functional changes to the test.

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

Helps: #2887
2024-01-23 11:02:48 +00:00
Philip Withnall
8a4ad5f998 tests: Add some debug output to memory-monitor-dbus.py test
This will hopefully help diagnose #2887.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #2887
2024-01-22 11:22:45 +00:00
Philip Withnall
5278efbd63 tests: Ensure Python assertEventually() function uses correct main context
It should be doing already (or the tests would never work), but make it
clearer in the code that the same `GMainContext` is being iterated as is
being woken up in the rest of the test.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #2887
2024-01-22 11:22:01 +00:00
Hailey Somerville
c65e163240 gio, gmodule, gthread: compile windows resources only in shared build
When linking static libraries, multiple resources is an error unless
handled in a special way. glib and gobject do not have this problem,
as they already only include resources when building a shared lib.
2024-01-21 18:51:52 +11:00
Emmanuele Bassi
4ff4f073a4 Merge branch 'altiera/docs' into 'main'
docs: Fix links to symbols outside the allowed namsepace

See merge request GNOME/glib!3809
2024-01-18 18:35:21 +00:00
Philip Withnall
5c05dfad97 tests: Run more appinfo tests under a GTestDBus environment
I ran Bustle/dbus-monitor on the session bus while running the full GLib
test suite, and noticed that these tests were causing `Launched` signal
emissions on the main session bus. That suggested they weren’t isolated
properly, which at best causes noise on the bus and at worst could cause
spurious test failures.

Fix that by running those tests in a `GTestDBus` environment, as some of
the other appinfo tests already are.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-18 15:22:30 +00:00
Philip Withnall
048afc5923 Merge branch 'wip/smcv/issue3226' into 'main'
tests: Don't test --external-data with toolchains that can't do the setup

Closes #3226

See merge request GNOME/glib!3819
2024-01-15 15:41:44 +00:00
Philip Withnall
cbb29a54c3 Merge branch 'socket-test-leak' into 'main'
tests: Fix a minor leak in the socket test

See merge request GNOME/glib!3821
2024-01-15 15:32:01 +00:00
Philip Withnall
6900e0450f Merge branch '3093-gdbus-header-validation' into 'main'
gdbusmessage: Validate the types of all known message headers

Closes #3093

See merge request GNOME/glib!3748
2024-01-15 15:21:44 +00:00
Emmanuele Bassi
b5c07063c3 docs: Use code for class names in links
So that they fit with the documentation guidelines, and with the links
generated by gi-docgen.
2024-01-15 14:43:53 +00:00
Philip Withnall
c7ace595e8 tests: Fix a minor leak in the socket test
As seen in [CI](https://gitlab.gnome.org/GNOME/glib/-/jobs/3436216):
```
==13767== 144 (40 direct, 104 indirect) bytes in 1 blocks are definitely lost in loss record 528 of 562
==13767==    at 0x4A18B2C: g_type_create_instance (gtype.c:1928)
==13767==    by 0x49F92FF: g_object_new_internal (gobject.c:2235)
==13767==    by 0x49FA247: g_object_new_valist (gobject.c:2574)
==13767==    by 0x49F8D81: g_object_new (gobject.c:2047)
==13767==    by 0x4AE2337: g_inet_socket_address_new (ginetsocketaddress.c:387)
==13767==    by 0x4B1DB94: g_socket_address_new_from_native (gsocketaddress.c:230)
==13767==    by 0x4B16CC2: g_socket_get_local_address (gsocket.c:2071)
==13767==    by 0x40E102: test_receive_bytes_from (socket.c:2469)
==13767==    by 0x4901E78: test_case_run (gtestutils.c:2974)
==13767==    by 0x49022B2: g_test_run_suite_internal (gtestutils.c:3069)
==13767==    by 0x490241A: g_test_run_suite_internal (gtestutils.c:3088)
==13767==    by 0x4902690: g_test_run_suite (gtestutils.c:3168)
==13767==    by 0x4900C8F: g_test_run (gtestutils.c:2275)
==13767==    by 0x40EE8A: main (socket.c:2614)
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3220
2024-01-15 14:16:21 +00:00
Simon McVittie
fb5dd18f21 tests: Don't test --external-data with toolchains that can't do the setup
There are several reasons why we might not be able to do the test setup
for --external-data: non-Linux platform, missing ld or objcopy,
objcopy doesn't support --add-symbol, or the CPU family is MIPS
(on which cc -r does not necessarily emit the specific MIPS ABI flavour
that we are targeting, for example different functionality levels or
different NaN encodings).

If we can't link in the test data, then obviously this test is not going
to pass. It was already skipped on non-Linux, but not on platforms that
hit one of the other reasons for the test setup to fail.

In particular, this test failed on Debian mips64el since commit 81059169,
which stopped linking the necessary resource on MIPS platforms, but
continued to assert that the resource is present at runtime.

Fixes: 81059169 "GIO/tests: skip test_resources_binary on MIPS platform"
Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3226
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-01-13 19:54:28 +00:00
Jordan Petridis
3f9f5c1420 docs: Fix links to symbols outside the allowed namsepace
Use markdown links for anything that the docs don't depend upon,
like gtk, pixbuf, etc
2024-01-09 21:24:22 +02:00
Emmanuele Bassi
2b2b04d188 Shorten the title for D-Bus interface docs
The title of an interface can be arbitrarily long, considering that
reverse DNS namespaces can be pretty complex. Instead of using the whole
interface name, we can use the name without the prefix.
2023-12-29 01:02:00 +00:00
Philip Withnall
ec3fb9a48c Merge branch 'glib-gir-sources' into 'main'
gobject: Make GLib-2.0 gir build depend on GObject dependency

See merge request GNOME/glib!3772
2023-12-22 14:45:37 +00:00
Michael Catanzaro
c2fab14030 gapplication: ensure app ID is set when sending notification
Otherwise, we hit a bunch of criticals later on. Also, document this
requirement to ensure there is no ambiguity.

Fixes #3203
2023-12-21 10:44:25 -06:00
Philip Withnall
833d3fb6cf Merge branch 'file-uri-cleanup' into 'main'
glocalvfs: Remove unnecessary and buggy code

See merge request GNOME/glib!3776
2023-12-21 12:42:27 +00:00
Marco Trevisan (Treviño)
9c4ff01feb build: Move gir generation to an introspection folder
Generating gir and typelib files has inter-dependencies that may depend
on other elements.

For example, glib requires gobject and gdump generated files require
gmodule, so we've a cyclic dependency because gmodule requires gobject,
that requires glib.

To prevent this, let's just generate the introspection files at once in
a different meson file so that we don't have to deal with this.

As per this we could even revert commit fa37ab6d0 since gio is now
compiled before the gir files.
2023-12-20 21:35:53 +01:00
Colomban Wendling
1fa03292c1 glocalvfs: Remove unnecessary and buggy code
The code for stripping the query and fragment from file:// URIs was
wrong, as it would not properly strip a query if there was a fragment.

Fortunately, that code was actually useless, as the "stripped URI" was
passed to g_filename_from_uri() that does proper stripping itself.

So simply drop this extra unnecessary stripping logic from GLocalVFS's
get_file_for_uri() and let g_filename_from_uri() do all the work.
2023-12-20 19:25:50 +01:00
Colomban Wendling
5790ce14e8 tests: Test file:// URIs with both query and fragment 2023-12-20 19:23:40 +01:00
Marco Trevisan (Treviño)
81068e5c00 gio: Use g_task_return_error_literal() where we don't need formatting 2023-12-20 16:14:57 +00:00
Marco Trevisan (Treviño)
7c71090723 gtask: Add g_task_return_new_error_literal()
Avoids going through the formatting function or nesting GError calls.
2023-12-20 16:14:57 +00:00
Marco Trevisan (Treviño)
f08609b169 gio/tests/task: Use wait_for_completed_notification() to wait for task 2023-12-19 20:29:44 +01:00
Marco Trevisan (Treviño)
39f820e507 gio/tests/task: Also check for formatted error messages 2023-12-19 18:55:29 +01:00
Philip Withnall
98e4b3adec tests: Add tests for g_socket_receive_bytes() and g_socket_receive_bytes_from()
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-18 14:23:03 +00:00
Philip Withnall
7463a256cb tests: Add a missing no-error assertion in the socket tests
It doesn’t fail, but at least now it’s there to catch problems if they
do happen.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-18 14:23:03 +00:00
Philip Withnall
e46184205f tests: Use g_assert_*() rather than g_assert() in socket tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-18 14:23:03 +00:00
Philip Withnall
309f5384ca tests: Clear up freeing of test data in socket test
The same struct was reused across multiple tests, but without a shared
way of freeing its members. Refactor to add one.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-18 14:23:03 +00:00
Emmanuele Bassi
7cb953dab8 Add GBytes variants for GSocket receive methods
The current buffer API is pretty much C-specific, and cannot be
adequately described in a way that is friendly to introspection and
language bindings: the passed buffer is allocated by the caller, but the
written size of the buffer is in the return value.

Using GBytes, we get a better API at the cost of an additional
allocation.
2023-12-18 14:23:03 +00:00
Jens Georg
b363e07527 gapplication: Fix minor typo in docs 2023-12-16 17:06:36 +01:00
Philip Withnall
91c82b046e tests: Re-format codegen.py with black
This is just the result of running `black $(git ls-files '*.py')`.

For some reason, the `sh-and-py-check` CI job didn’t run on merge
request !3751, so this non-standard formatting slipped through onto
`main`.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3754#note_1939914

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-11 16:53:44 +00:00
Philip Withnall
b96778ee43 tests: Use textwrap.dedent to indent expected strings pleasingly
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-11 16:52:07 +00:00
Philip Withnall
b014d622ee Merge branch 'fix_new_rst_anchors' into 'main'
Fix generated RST anchors for methods, signals and properties

See merge request GNOME/glib!3751
2023-12-11 14:19:44 +00:00
Michael Olbrich
19a6742fc2 gdbusconnection: don't cache G_IO_ERROR_CANCELLED errors
It can cause failures for shared connection objects.

What can currently happen is this:
1. A user starts to asynchronously create a proxy object
2. A user starts to asynchronously create another proxy object

At this point, the asynchronous initialization for the two proxy objects
share the not yet initialized connection object.

3. While the shared connection objected is created, the user cancels the
   creation with the supplied cancellable from the fist proxy object.
4. initable_init caches the canceled error and marks the connection as
   initialized.
5. The initialization of the second proxy object fails with the same
   canceled error.

To avoid this, clear the error in this case and destroy any member
variables that may have been created before the creation was canceled.

This way, the initialization of the second proxy object will restart the
connection initialization and with probably succeed.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-12-11 14:17:14 +00:00
Philip Withnall
cecc5ef778 tests: Add more tests of header validation in D-Bus message serialisation
See the previous commit. These additions were kept in a separate commit
to make the changes to the existing tests in the previous commit
clearer.

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

Helps: #3093
2023-12-11 12:50:52 +00:00
Philip Withnall
fb60ebb0df gdbusmessage: Validate the types of all known message headers
Previously, the code only validated the types of *required* message
headers, and did not validate optional ones.

Now, the headers are validated in one step, and a subsequent step checks
whether the required ones are present.

The existing tests have been updated to match the new error message
wording. More tests will be added to test the new behaviour in a
subsequent commit.

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

Fixes: #3093
2023-12-11 12:50:52 +00:00
tytan652
605be9a1e9 tests: Add tests for gdbus-codegen generated RST
Those tests check if methods, signals and properties documentation are
properly generated.
2023-12-11 13:48:43 +01:00
tytan652
9a4e54e1b7 Fix generated RST anchors for methods, signals and properties 2023-12-09 15:37:37 +01:00
Philip Withnall
e646c631b2 tests: Assert there no errors first in gdbus-test-codegen
Before checking the properties of `*_proxy`, assert that there were no
errors in constructing the proxy first. Otherwise the property checks
will crash on `NULL` pointer dereferences.

The test is still intermittently buggy somewhere, but at least this
commit will cause a relevant error message to be printed on failure.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-05 15:58:45 +00:00
Philip Withnall
c40fa821b8 Merge branch 'python3.12-remove-distutils' into 'main'
Switch from the Python distutils module to the packaging module

Closes #3134

See merge request GNOME/glib!3740
2023-12-05 15:50:15 +00:00
Jordan Williams
6ef967a0f9 Switch from the deprecated distutils module to the packaging module
The distutils module was removed in Python 3.12.
2023-12-05 14:18:10 +00:00
Philip Withnall
b097adf18a xdgmime: Update to upstream commit c2c814d4051f232
(Modulo the changes in
https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/10 which are
still under discussion. Plus the proposed warning fixes from
https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/33.)

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

Fixes: #3191
2023-12-04 13:13:13 +00:00
Philip Withnall
44d25c5ad4 Merge branch 'socket-client-cleanups' into 'main'
gsocketclient: Document delays/timeouts better

See merge request GNOME/glib!3394
2023-12-03 23:26:53 +00:00
Philip Withnall
da48656ee7 gsocketclient: Add a missing connection_attempt_remove() call
The connection attempt should always be removed before being unreffed.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-03 23:11:39 +00:00
Philip Withnall
f5f418b057 gsocketclient: Track whether the connection attempt delay is reached
Just for debugging purposes, track whether the Connection Attempt Delay
(https://datatracker.ietf.org/doc/html/rfc8305#section-8) has been
reached for each attempt.

This makes it a bit easier to diagnose `GSocketClient` problems in a
debugger.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-03 23:11:38 +00:00
Philip Withnall
ac6864ded7 gsocketclient: Rename ‘connection timeout’ to ‘connection delay’
This makes it match the terminology from RFC 8305 better, which refers
to a ‘connection attempt delay’. This is a delay because it determines
the spacing between trying additional connection attempts. It’s not a
timeout because it shouldn’t cause cancellation of any ongoing
connection attempts.

This commit introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-12-03 23:11:11 +00:00
Emmanuele Bassi
b53218a509 Merge branch '3037-doc-build-cleanups' into 'main'
build: Rename -Dgtk_doc option to -Ddocumentation and fix some g-ir-scanner warnings

See merge request GNOME/glib!3736
2023-12-01 22:48:17 +00:00
Philip Withnall
039876e6d9 gsocket: Enable TCP_NODELAY by default for stream GSockets
`TCP_NODELAY` disables Nagle’s algorithm, which is generally a better
default for modern networks than having it enabled. Nagle’s algorithm
delays sending small data blobs until they fill an entire TCP segment,
so as to amortise the cost of sending the segment.

This improves bandwidth at the cost of latency. Given the large
bandwidth capabilities of most modern networks, most streams are
constrained by latency rather than bandwidth, so disabling Nagle’s
algorithm makes sense.

Various other major bits of software (such as libcurl) already disable
Nagle’s algorithm by default.

Specific applications which need it can turn it back on by calling
`g_socket_set_option()`.

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

Fixes: #791
2023-11-29 17:08:10 +00:00
Philip Withnall
a581de2ee7 gsocketclient: Make connection_attempt_remove() safe to call twice
As spotted by Michael Catanzaro in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3394#note_1730123,
on the code path where a `ConnectionAttempt` is cancelled, it will
currently be removed from the `connection_attempts` list by the
cancellation code, and then *again* by the `if
(task_completed_or_cancelled ())` code in
`g_socket_client_connected_callback()`.

That would previously have resulted in a double-unref of the
`ConnectionAttempt`. So change `connection_attempt_remove()` to be a
no-op if the attempt isn’t found in `connection_attempts`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-11-29 15:55:48 +00:00
Philip Withnall
320c9d6d0d gsocketclient: Add some additional debug prints
These make it a bit easier to track the ongoing tasks, as the tasks
and/or their closures are not tracked in a big list somewhere.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-11-29 15:55:48 +00:00
Philip Withnall
bc6d03c3c9 gsocketclient: Document async operation timeout/completion behaviour
These calls are where the `GSocketClient` Happy Eyeballs code relies on
other components within GLib (and glib-networking) to complete
asynchronous operations in a timely manner. `GSocketClient` doesn’t add
its own timeouts to monitor these async operations, so if the
implementations are buggy then a `GSocketClient` operation could stall
forever.

Make that a bit clearer.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-11-29 15:55:48 +00:00
Philip Withnall
240b8bbc2d gsocketclient: Clarify some internal comments
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-11-29 15:55:48 +00:00
Philip Withnall
69c6413182 gsocketclient: Rename an internal variable and change it to a counter
This introduces no functional changes, but makes it a little clearer
what the variable signifies, and provides a little more information when
debugging things.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-11-29 15:27:16 +00:00
Philip Withnall
c4b47c708d gwin32appinfo: Use correct gettext macro
`P_()` is for pspec strings — it gave us the option to split them out to
a separate translation domain. `_()` is for normal strings.

Spotted by Sophie Herold: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3411#note_1733329

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-29 13:41:34 +00:00
Sophie Herold
0d268c4825 Remove all nicks and blurbs from param specs
Nicks and blurbs don't have any practical use for gio/gobject libraries.
Leaving tests untouched since this features is still used by other libraries.

Closes #2991
2023-11-29 13:41:34 +00:00
Philip Withnall
f3aebf0c15 gio: Add various missing property documentation comments
Previously these properties would have been documented using the strings
from the pspec, but those will be removed in the following commit. Re-add
the documentation using those strings, but as gi-docgen documentation
comments.

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

Helps: #2991
2023-11-29 13:41:12 +00:00
Philip Withnall
d930b9058f gtlspassword: Add a missing (out) annotation
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-29 11:58:16 +00:00
Philip Withnall
045186a6f2 gthreadedresolver: Mark internal functions as private
This removes a few more g-ir-scanner warnings.

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

Helps: #3037
2023-11-29 11:57:54 +00:00
Philip Withnall
f50ef45220 gnetworking: Hide POSIX networking symbols from g-ir-scanner
They’re not part of the GLib API and don’t need to be exposed to the
scanner.

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

Helps: #3037
2023-11-29 11:57:20 +00:00
Philip Withnall
2a8b0c2388 gicon: Fix an invalid introspection annotation
`(hash)` is not an annotation — it’s probably a typo for `(virtual
hash)`.

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

Helps: #3037
2023-11-29 11:56:46 +00:00
Philip Withnall
d71d4507b8 gfileinfo: Drop an incorrect (transfer) annotation
This fixes a g-ir-scanner warning.

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

Helps: #3037
2023-11-29 11:56:16 +00:00
Philip Withnall
002f846312 gio: Add some missing (scope) annotations
This removes some of the gobject-introspection warnings.

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

Helps: #3037
2023-11-29 11:55:49 +00:00
Philip Withnall
7d0140eea0 gdbusmessage: Reformat a doc comment to gi-docgen format
In an attempt to make gobject-introspection stop warning about using
deprecated gtk-doc `Type:` tags.

It doesn’t work — the gobject-introspection parser is not clever enough
to notice the tag is inside a code block.

Still, a useful port.

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

Helps: #3037
2023-11-29 11:54:13 +00:00