Commit Graph

8863 Commits

Author SHA1 Message Date
Simon McVittie
124b4571bb tests: Add a data-driven test for signal subscriptions
This somewhat duplicates test_connection_signals(), but is easier to
extend to cover different scenarios.

Each scenario is tested three times: once with lower-level
GDBusConnection APIs, once with the higher-level GDBusProxy (which
cannot implement all of the subscription scenarios, so some message
counts are lower), and once with both (to check that delivery of the
same message to multiple destinations is handled appropriately).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-23 19:08:19 +01:00
Ondrej Holy
dbb7a12a96 gunixmounts: Use fallback if libmount monitoring fails
The recently added libmount-based unix mount monitoring may fail when the
device exceeds inotify limits. Let's fallback to the older implementation
in case of the `mnt_monitor_get_fd` function failure. This among others
fixes tracker-miners failures caused by seccomp rules.

Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/315
2024-04-23 12:59:40 +02:00
Michael Catanzaro
81eaabb308 Merge branch 'completion-bins' into 'main'
completion: Invoke the command being completed

See merge request GNOME/glib!4013
2024-04-17 18:04:02 +00:00
Philip Withnall
70c0f3bff6
completion: Rework quoting in gsettings completion script
This is a partial revert and rework of commit
c79575362e, for the `gsettings` script
only (the other completion scripts are fine).

I blindly added quoting to everything shellcheck told me to, without
testing it properly.

As it turns out, the `$schemadir` argument to `gsettings` invocations
was deliberately not quoted, so that it would expand to zero arguments
if unset, and two arguments (`--schemadir /some/path`) if set earlier in
the command-being-completed.

Quoting it meant that it expanded to one argument (the empty string) if
unset, which caused the `gsettings` subcommands to fail, and hence any
further tab completion to fail.

Fix that as suggested on https://www.shellcheck.net/wiki/SC2086 by
turning `schemadir` into an array, which either has zero members if
unset, or two members if set.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-17 17:43:50 +01:00
Philip Withnall
295a6fb965
completion: Add missing copyright and licensing headers
The copyright entries come from looking at `git log gio/completion/*`
and, in particular, `git log -- gio/gsettings-bash-completion.sh` (etc.)
as the files were moved after being originally written, and haven’t
really changed since.

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

Helps: #1415
2024-04-17 17:43:44 +01:00
Philip Withnall
cc22637856
completion: Invoke the command being completed
As suggested by Ville Skyttä in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4012#note_2084405,
make sure to invoke the copy of the command which is being completed
when asking for completions of a given subcommand.

This avoids accidentally invoking any old `gdbus`/`gresource`/etc.
binary which is hanging around in another part of `$PATH`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-17 17:43:38 +01:00
Philip Withnall
8138246ab8
inotify: Add license and copyright headers to meson.build
The copyright from `git log gio/inotify/meson.build` is now included in
the file header. The following commits are too trivial to be
copyrightable:
 - d10be6102f
 - 03e86d000f
 - 1741fc2c6e
 - 8733d172a3

The file was contributed while the `COPYING` file for GLib was
LGPL-2.1-or-later, so was previously implicitly licensed as that.
Let’s make that explicit.

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

Helps: #1415
2024-04-17 15:46:23 +01:00
Philip Withnall
417f6a4bde
inotify: Trivially add SPDX-License-Identifier to inotify files
The license and copyright are already stated in human-readable form in
these files, so this should be uncontroversial.

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

Helps: #1415
2024-04-17 15:46:11 +01:00
Philip Withnall
34050a5c12
codegen: Add license and copyright headers to remaining files
The `.flake8` file has a trivial version history, so the copyright is
straightforward from that.

`meson.build` has a more complex history, but the only significant
contributions were from Centricular. From `git log
gio/gdbus-2.0/codegen/meson.build`, the other (following) commits are
too trivial to be copyrightable:
 - d10be6102f
 - 30b25a6fd9
 - 95fa229f34
 - 631c3534b7
 - 00d7568e4f
 - 9734e4854e
 - 65be80c3ed
 - 66e4ba806a
 - a1c78d63ef
 - a73ca336aa
 - 19353017a7
 - b4231844a2
 - 4cb945d780
 - 4ce58df854
 - e2433308c4
 - 013980d839

Both files were contributed while the `COPYING` file for GLib was
LGPL-2.1-or-later, so both were previously implicitly licensed as that.
Let’s make that explicit.

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

Helps: #1415
2024-04-17 15:33:24 +01:00
Philip Withnall
68d8f721f3
codegen: Trivially add SPDX-License-Identifier to codegen Python files
The license and copyright are already stated in human-readable form in
these files, so this should be uncontroversial.

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

Helps: #1415
2024-04-17 15:31:50 +01:00
Philip Withnall
869ef92858 Merge branch 'shellcheck-completions' into 'main'
tests: Enable shellcheck for bash completion scripts

See merge request GNOME/glib!4012
2024-04-17 07:43:12 +00:00
Jan Tojnar
156e0c865a docs: Fix broken links
The file was renamed in 5d80471d4b.
2024-04-16 14:33:45 +01:00
Philip Withnall
827bca3212
completion: Ignore SC2207 for COMPREPLY assigments
Using the same justification as in
https://gitlab.gnome.org/GNOME/dconf/-/merge_requests/81#note_2083220:
it’s hard to get this right, with error handling, in a way which is
understandable to people reading it, and which both bash and shellcheck
will be happy with.

On the assumption that none of the completions generated by any of these
utilities will include ‘problematic’ characters (ones which would cause
word splitting or globbing in bash), just ignore the shellcheck
warnings. Note that I have not actually closely verified that these
utilities can’t return ‘problematic’ characters.

This means we can enable shellcheck, with fatal warnings, for these
scripts, and hence catch future regressions.

If someone wants to improve the handling of globbing/word splitting in
some/all of these array assignments in future, the shellcheck disables
can be removed.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:09:36 +01:00
Philip Withnall
6024fb9753
completion: Quote argument to unset
Otherwise it gets globbed and the wrong thing potentially gets unset.
Spotted by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:08:39 +01:00
Philip Withnall
17f0cad2c7
completion: Drop some unused variables
Spotted by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:08:08 +01:00
Philip Withnall
7ad93a0c95
completion: Use read -r rather then plain read
This means that backslashes in the input (which is unlikely, but I guess
possible) won’t affect line splitting. Spotted by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:07:12 +01:00
Philip Withnall
b1ef6a125e
completion: Quote variable dereferences within variable dereferences
Otherwise they could get split. Spotted by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:06:13 +01:00
Philip Withnall
d3d811f4e5
completion: Split declaration and assignment of variables
Having them on the same line masks failure of the subcommand generating
the value being assigned. Spotted by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:05:04 +01:00
Philip Withnall
a7ad2a4c3a
completion: Drop unnecessary $ from variables in arithmetic expressions
It’s not needed, according to shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 14:03:19 +01:00
Philip Withnall
c79575362e
completion: Add missing quoting
As suggested by shellcheck.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 13:58:49 +01:00
Philip Withnall
aaf715a046
completion: Stop using old backtick quoting for subcommands
Fixes a shellcheck warning.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 13:54:33 +01:00
Philip Withnall
f95e8b4e7c
completion: Add shellcheck shell hints to all completion scripts
Because completion scripts are not executed directly, they don’t have a
shebang line, so shellcheck can’t be sure which shell syntax to use for
them. Help it out.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-16 13:51:44 +01:00
Michael Catanzaro
5c8fbc3cda Merge branch 'scan-build' into 'main'
Fix various bugs found by scan-build and refresh scan-build config in CI

See merge request GNOME/glib!4005
2024-04-15 15:47:45 +00:00
Michael Catanzaro
e831627881 Merge branch '3310-subprocess-sigpipe' into 'main'
gsubprocess: Globally ignore SIGPIPE

Closes #3310

See merge request GNOME/glib!3991
2024-04-15 15:33:00 +00:00
Philip Withnall
ad0532f2bf
xdgmimeglob: Fix a memory leak on a duplicate-entry path
Rather than `strdup()`ing strings when passing them into
`_xdg_glob_list_append()`, `strdup()` them *inside* the function
instead.

This avoids a leak in the case that the list entry (tuple of `data` and
`mime_type`) already exists in the list.

This has been upstreamed as
https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/36.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 18:45:52 +01:00
Philip Withnall
ae3bd19108
gresource: Improve resource unregistration performance slightly
Rather than iterating over the list twice: once to find the resource,
and once to re-find its link and delete it, just use
`g_list_delete_link()` to delete what was found.

This has the lovely side-effect of squashing a false positive from
scan-build, which thought there was a use-after-free of `resource` in
the caller, due to `g_resource_unref()` being called on it here.

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

Helps: #1767
2024-04-12 18:45:46 +01:00
Philip Withnall
1ed199a881
tests: Use g_assert_*() rather than g_assert() in gdbus-export tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 18:45:39 +01:00
Philip Withnall
3f30ec86cd
gdbusconnection: Fix user_data leaks on error
There were a couple of functions in `GDBusConnection` which take a
`user_data` argument, but which then leak it if they error out early.

A true positive spotted by scan-build!

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

Helps: #1767
2024-04-12 18:45:31 +01:00
Philip Withnall
b8225c905b
gdbusconnection: Ensure out_serial return value is always set
There were some error paths where it wasn’t set, returning an
uninitialised value to the caller.

Spotted by scan-build.

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

Helps: #1767
2024-04-12 18:45:03 +01:00
Philip Withnall
978ca4731c
gactiongroup: Add a missing array termination annotation
It might not actually be needed (I haven’t checked if the default is
correct), but it certainly does no harm and makes things explicit.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 13:56:20 +01:00
Philip Withnall
3ec4ba4d1b
gactiongroup: Minor copyediting of documentation, comments and warnings
No functional changes.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 13:56:07 +01:00
Sudhanshu Tiwari
527e696553 Removed an extra new line in gio/gactiogroup.c 2024-04-12 13:55:51 +01:00
Sudhanshu Tiwari
a43ee8991e Ports the documentation comments in gio/gactiongroup.c to GI-Docgen 2024-04-12 13:55:51 +01:00
L. E. Segovia
5d08fb2e45 gunixmounts: Fix typo in comment regarding Android API level 2024-04-02 08:48:39 -03:00
L. E. Segovia
e0fca3e7a7 gunixmounts: Use __ANDROID__ to test for the OS, not __BIONIC__
See https://android.googlesource.com/platform/bionic/+/HEAD/docs/defines.md
2024-04-02 08:44:58 -03:00
L. E. Segovia
0da4b1bf31 gio-launch-desktop, gmessages: Fix journald support using __BIONIC__ to skip support on Android
As per the Bionic docs, this functionality is Android, not bionic specific.

See: https://android.googlesource.com/platform/bionic/+/HEAD/docs/defines.md
2024-04-02 08:40:48 -03:00
Philip Withnall
2cee8e3d06 Merge branch 'port-gaction-comments-2' into 'main'
Port the remaining documentation comments in `gio/gaction.c` to GI-Docgen

See merge request GNOME/glib!3986
2024-04-01 15:33:54 +00:00
Sudhanshu Tiwari
57d6b945f1 Ported the remaining documentation comments in gio/gaction.c to GI-Docgen 2024-04-01 16:00:23 +01:00
Philip Withnall
e46f2347d2 Merge branch 'style/spelling' into 'main'
docs: spelling and grammar fixes

See merge request GNOME/glib!3990
2024-04-01 14:13:19 +00:00
Philip Withnall
ef461fb391 gsubprocess: Globally ignore SIGPIPE
Just like we already do in `GSocket`.

This is necessary when using `g_subprocess_communicate()` with a
subprocess which calls `close()` on its stdin FD at some point. `cat`
does this just before exiting, for example.

This causes a `write()` to the stdin pipe in the parent process to fail
with `EPIPE` and `SIGPIPE`. The condition is not detectable in advance,
because the `close()` call could happen after the `GMainContext` has
dispatched a `g_subprocess_communicate()` callback.

If it weren’t for the `SIGPIPE`,`g_subprocess_communicate()` would be
able to handle the `EPIPE` just fine. `SIGPIPE` seems like a default
error handling path which was useful in 1980 for writing pipe-heavy
command line apps, but which is more of a broken stair for writing
larger modern apps which have more than one data flow path.

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

Fixes: #3310
2024-04-01 14:41:33 +01:00
Ville Skyttä
b20647c2e2 docs: spelling and grammar fixes
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2024-04-01 11:01:06 +00:00
Ville Skyttä
bf1508fa76 completion: make gsettings work in nounset mode
With the shell in nounset mode, an error is emitted on referencing
`schemadir` as it is not initialized in all code paths.

Initialize to an empty string to fix.

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2024-04-01 10:31:34 +00:00
Philip Withnall
ed4f29cce8 gio: Change ‘unrecognised’ to ‘unrecognized’ in various user-visible places
The source language of GLib is technically en-US, so we should
consistently use en-US spellings.

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

Helps: #3269
2024-03-27 12:07:42 +00:00
Calvin Walton
013980d839 Use the python found by meson as the interpreter for installed scripts
The python interpreter found by `/usr/bin/env python3` is not
necessarily the same installation as the one that's found by meson's
`pymod.find_installation('python')`. This means that even though meson
is checking that the python installation it found includes the
'packaging' module, the scripts might not have access to that module
when run.

For distribution packaging, it's usually desirable to have python script
interpreters be fully specified paths, rather than use `/usr/bin/env`,
to ensure the scripts run using the expected python installation (i.e.
the one where the python 'packaging' dependency is installed).

The easiest way to fix this is to set the script interpreter to the
`full_path()` of the python interpreter found by meson. The specific
python interpreter that will be used can be selected through the use of
a meson machine file by overriding the "python" program. Many
distributions already have this set up using meson packaging helpers.
2024-03-25 15:17:59 -04:00
Michael Catanzaro
e124c34ad6 Merge branch 'io-priority-docs' into 'main'
gio: Fix docs links to description of I/O priority

See merge request GNOME/glib!3978
2024-03-22 15:16:11 +00:00
Philip Withnall
71d60faef3 Merge branch 'copy-move-async-with-closures' into 'main'
Add g_file_copy_async_with_closures() and g_file_move_async_with_closures()

See merge request GNOME/glib!3939
2024-03-22 00:55:07 +00:00
Philip Withnall
7feeafd9db gio: Fix docs links to description of I/O priority
There are a lot of links to the description of I/O priority in the GIO
docs, and they’re all currently broken since the docs build was ported
to gi-docgen.

Use a simple find and replace (see below) to fix them. This doesn’t port
any of the surrounding docs to gi-docgen format, but should still
improve things overall.
```sh
git search-replace --fix '\[I/O priority\]\[io-priority\]///[I/O priority](iface.AsyncResult.html#io-priority)'
```

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

Helps: #3250
2024-03-22 00:53:05 +00:00
Philip Chimento
64b06c633a gfile: Add g_file_{copy,move}_async_with_closures
g_file_copy_async() and g_file_move_async() are written in a way that is
not bindable with gobject-introspection. The progress callback data can
be freed once the async callback has been called, which is convenient
for C, but in language bindings the progress callback closure is
currently just leaked.

There is no scope annotation that fits how the progress callback should
be treated:

- (scope call) is correct for the sync versions of the functions, but
  incorrect for the async functions; the progress callback is called
  after the async functions return.
- (scope notified) is incorrect because there is no GDestroyNotify
  parameter, meaning the callback will always leak.
- (scope async) is incorrect because the callback is called more than
  once.
- (scope forever) is incorrect because the callback closure could be
  freed after the async callback runs.

This adds g_file_copy_async_with_closures() and
g_file_move_async_with_closures() for the benefit of language bindings.

See: GNOME/gjs#590
2024-03-22 00:20:00 +00:00
Philip Chimento
685d3dfbdc gsettings: Add g_settings_bind_with_mapping_closures()
This is an introspection-friendly version of g_settings_bind_with_mapping.
Having two callbacks that share the same user data is not supported by
girepository, so the existing function is not introspectable.

Closes: #564
2024-03-21 23:38:13 +00:00
Sudhanshu Tiwari
fa5237650b Ported the first 3 documentation comments in gaction.c to gi-docgen 2024-03-20 11:34:33 +00:00
Philip Withnall
e83e4c5535 tests: Mark several additional tests as can_fail on GNU Hurd
These consistently fail on scheduled CI runs, which is not helping our
ability to catch Hurd regressions.

For example, https://gitlab.gnome.org/GNOME/glib/-/jobs/3709402

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

See: #3148
2024-03-19 13:01:26 +00:00
Nirbheek Chauhan
92a97c4f48 meson: Fix a needless recompilation of some gdbus tests
The gdbus-example-objectmanager visibility header was being re-created
on reconfigure, causing a needless rebuild of gdbus tests that were
using the visibility header.

All other invocations of gen_visibility_macros are via custom_target.
2024-03-13 03:32:56 +05:30
Simon McVittie
fb4b780eea glib-compile-resources: Provide placeholders for options with an argument
If we don't do this, the --help text is formatted as though the option
did not expect an argument.

IDENTIFIER is a new translated string, but it is developer-oriented,
so a missing translation is not particularly bad. COMMAND is already
present in translations.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-28 11:28:00 +00:00
Simon McVittie
5622a4a625 gdbus: Add command-line placeholder for ADDRESS
If we don't do this, the --help text is formatted as though the option
did not expect an argument.

This introduces a new translated string, but it is developer-oriented,
so a missing translation is not particularly bad.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-28 11:27:21 +00:00
Philip Withnall
9a661ab970 gsocketclient: Fix a use-after-free in g_socket_client_connected_callback()
The ref held by `data->task` may be the last one on the `GTask`. The
`GTask` stores `attempt->data` as its task data, and so when the `GTask`
is finalised, `attempt->data` is too. `connection_attempt_remove()`
needs to access `attempt->data`, so must be called before the
`g_object_unref()` in this situation.

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

Fixes: #3266
2024-02-27 09:03:03 +00:00
Philip Withnall
ca4e6f81d2 Merge branch 'wip/oholy/gvolumemonitor-leak' into 'main'
gcontextspecificgroup: Wait until stop_func is done

Closes #3258

See merge request GNOME/glib!3934
2024-02-26 18:06:45 +00:00
Luca Bacci
4337f8f735 GWinHttpFile: Check for matching attributes before sending the HTTP(S) request
We might not need to make an HTTP(S) request at all

Fixes #3080
2024-02-21 11:56:36 +01:00
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
Philip Withnall
96c317418a gdbusconnection: Support matching object paths with arg0 matching
GDBus has always supported matching strings with arg0 matching
(`G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH`). In D-Bus 1.5, support was added
to the spec for also matching object paths. This got forgotten about and
was never added to GDBus, meaning that
`G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH` won’t match against a signal arg0
of type `o`.

Fix that, and add a unit test.

To do so, we need to add a new `g_dbus_message_get_arg0_path()` API to
complement the existing `g_dbus_message_get_arg0()` API. The approach of
letting `g_dbus_message_get_arg0()` return an object-path *or* a string
would not work, as it’s also called in the implementation of
`G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE`, which must only match
string-typed arg0 values and not object-path-typed ones.

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

Fixes: #3183
2023-11-28 14:42:41 +00:00
Philip Withnall
10e9a917be gdbusmessage: Cache the arg0 value
Technically we can’t rely on it being kept alive by the `message->body`
pointer, unless we can guarantee that the `GVariant` is always
serialised. That’s not necessarily the case, so keep a separate ref on
the arg0 value at all times.

This avoids a potential use-after-free.

Spotted by Thomas Haller in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3720#note_1924707.

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

Helps: #3183
2023-11-28 14:09:42 +00:00
Philip Withnall
bd33e0acd2 gio: Fix several incorrect links in documentation comments
Since commit 08f914b29, validation seems to have got a little
stricter/more correct.

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

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
c406c6de6b Merge branch '3148-stream-test' into 'main'
tests: Use a pipe rather than a socketpair in stream-rw_all test

Closes #3148

See merge request GNOME/glib!3691
2023-11-28 11:43:51 +00:00
Philip Withnall
4c86a85eaf Merge branch 'app-command-line-done' into 'main'
gapplicationcommandline: add `.done()` method

Closes #596

See merge request GNOME/glib!3693
2023-11-27 14:15:36 +00:00
Aleksandr Mezin
c03c983d94 gapplicationcommandline: add .done() method
Fixes #596
2023-11-27 14:15:36 +00:00
Philip Withnall
01cdce7573 glocalfileinfo: Increase size of the content-type sniff buffer to 16KiB
It was previously 4KiB, but this isn’t enough for sniffing the
content-type of some GPT disk images (they use 4KiB sectors, and the
magic bytes are in the second sector). A buffer of 8KiB would work,
but 16KiB seems harmless and more future proof.

Most of the time, the buffer size should be set by xdgmime anyway, based
on the largest sniff buffer its database needs. Currently (with
shared-mime-info master) that’s 18730 bytes, so even with a 16KiB buffer
we’re going to potentially mis-identify a few file types.

Tested manually by modifying the example GPT image from shared-mime-info
(https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/master/tests/mime-detection/disk.gpt)
to remove the magic at offset 0x200 and add it instead at offset 0x1000,
then running:
```
cp shared-mime-info.git/tests/mime-detection/disk.gpt ./disk-without-extension
gio info -a standard::content-type ./disk-without-extension
```

It should print `application/vnd.efi.img` rather than
`application/octet-stream`.

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

Fixes: #3186
2023-11-27 13:22:21 +00:00
Philip Withnall
29200648da Merge branch 'circular-mime-inheritance' into 'main'
xdgmime: Handle buggy type definitions with circular inheritance

See merge request GNOME/glib!3714
2023-11-22 10:35:34 +00:00
Alex Henrie
77902e1b1c xdgmime: Add continue statements after goto labels in_xdg_mime_(cache_)mime_type_subclass
To fix the Android build.
2023-11-21 11:14:58 -07:00
Philip Withnall
059618956b Merge branch 'muslc-ci' into 'main'
add muslc ci

See merge request GNOME/glib!3524
2023-11-21 14:55:29 +00:00
Alex Henrie
d9c50cac5d xdgmime: Handle buggy type definitions with circular inheritance
This fixes a stack overflow reported by a user who had both the
definition of text/javascript from shared-mime-info 2.3 and the
definition of text/javascript from shared-mime-info 2.4 installed at the
same time. In 2.3, text/javascript is a subtype of
application/ecmascript, but in 2.4 application/ecmascript is a subtype
of text/javascript. Having both at the same time resulted in circular
inheritance.

The new logic keeps a list of all parents that have already been
checked, which is more comprehensive than the old workaround that was
implemented in commit 38869ece2 ("xdgmime: Prevent infinite loops from
badly-formed MIME registrations").

https://bugs.archlinux.org/task/80279
2023-11-20 09:46:51 -07:00
Philip Withnall
6d2f63ecf1 giotypes: Drop redundant duplicate documentation blocks
This fixes a load of warnings about ‘multiple comment blocks documenting
<something> identifier’.

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

Helps: #3037
2023-11-15 12:37:12 +00:00
Philip Withnall
6e4d50fa5c docs: Move the gunixmounts SECTION
Move it to a separate page.

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

Helps: #3037
2023-11-15 11:48:23 +00:00
Philip Withnall
9c414d437e docs: Move the gpollableutils SECTION
Move it to a separate page.

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

Helps: #3037
2023-11-15 11:48:23 +00:00
Philip Withnall
708de2fc12 docs: Move the gnetworking SECTION
Move it to a separate page.

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

Helps: #3037
2023-11-15 11:48:23 +00:00
Philip Withnall
de8e39b344 docs: Move the gmenumodel SECTION
Move it to a separate page, since it doesn’t quite make sense to
incorporate into the `GDBusConnection` docs.

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

Helps: #3037
2023-11-15 11:48:23 +00:00
Philip Withnall
ef049cbaca docs: Move the GIOScheduler SECTION
Move it to a separate page, as there isn’t a `GIOScheduler` struct.
Ensure that all its functions/methods/types are correctly marked as
deprecated. Fix a few broken links about I/O priority which pointed to
it.

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

Helps: #3037
2023-11-15 11:48:23 +00:00
Philip Withnall
de56743bf6 docs: Move the GTask SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 15:17:22 +00:00
Philip Withnall
3d8f1dc203 docs: Move the GUnixFDMessage SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 15:12:53 +00:00
Philip Withnall
a84a704dc6 docs: Move the GVfs SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 15:12:53 +00:00
Philip Withnall
e42bfcb9ae docs: Move the GSocketConnectable SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
b480a733c0 docs: Move the GSubprocess SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
7f6a126f39 docs: Move the GSocketControlMessage SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
8af86abefb docs: Move the GTlsConnection SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
2abbaac589 docs: Move the GIOModule and GIOExtensionPoint SECTIONs
Move them to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
fe8785862a docs: Move the GIOError SECTION
Move it to a separate page as there’s no struct documentation to hang it
off.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
d00a53416f docs: Move the GFileIOStream SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
172bb52e3f docs: Move the GFile SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
70881dbabe docs: Move the GDBusObjectSkeleton SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
108f7e4c65 docs: Move the GDBusObjectManagerServer SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
74735d878f docs: Move the dbusutils SECTION
Move it to a separate page as there’s no struct to hang the
documentation off.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
3205b03df6 docs: Move the GDBusProxy SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
e4de0868ee docs: Move the GDBusObjectManager SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
6492dd7054 docs: Move the GDBus name watching SECTION
Move it to a separate content page as there’s no struct to hang the docs
off.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
beb56279ef docs: Move the GDBus name owning SECTION
Move it to a separate content page as there’s no struct to hang the docs
off.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
f25ede6d1c docs: Move the GDBusMenuModel SECTION
Move it to the struct docs.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
c7e21d2f59 docs: Move the GDBusIntrospection SECTION
Move it to a separate content page as there is no `GDBusIntrospection`
type to hang the rest of the documentation off.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Philip Withnall
84bed2f6ae docs: Move the GDBusError SECTION
Adding it all to the docs for the `GDBusError` enum seemed a bit much,
so I moved it to its own content page.

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

Helps: #3037
2023-11-14 14:32:19 +00:00
Ondrej Holy
30e102518a gcontenttype: Make filename valid utf-8 string before processing
The `g_content_type_guess_for_tree` function segfaults currently when
processing filenames that are not valid unicode strings. Let's use the
`g_filename_to_utf8` and `g_utf8_make_valid` functions before other
processing to prevent that.

Let's also add a test for it to avoid this in future.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/3168
2023-11-13 12:14:01 +00:00
Pablo Correa Gómez
8901ffeffe
ci: add muslc CI 2023-11-12 15:39:14 +01:00
Thomas Haller
7098250e7a gutils: avoid race setting prgname from g_option_context_parse()/g_application_run()
g_option_context_parse()/g_application_run()/g_test_init() for
convenience also call g_set_prgname(), when the prgname is unset at this
point. This was racy.

Fix the race by using an atomic compare-and-exchange and only reset the
value, if it is unset still.
2023-11-08 16:36:14 +01:00
Philip Withnall
d59bac3f32 tests: Fix gio-tool.py test on macOS
Content types are different on macOS.

This fixes commit 9028c9bdf.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3158
2023-11-08 10:29:43 +00:00
Emmanuele Bassi
85d93fb581 Merge branch 'codegen-deps-fixes' into 'main'
meson: Add missing dependencies for utility files for gdbus-codegen

See merge request GNOME/glib!3689
2023-11-07 15:21:27 +00:00
Philip Withnall
e87f8e9c5a Merge branch '3158-info-critical' into 'main'
gio-tool-info: Fix critical warning when --attributes are specified and add basic unit tests

Closes #3158

See merge request GNOME/glib!3684
2023-11-07 14:37:11 +00:00
Philip Withnall
9028c9bdf3 gio-tool-info: Fix critical warning when --attributes are specified
When `--attributes` is specified and doesn’t include `standard::name` in
its list, `gio` would print a critical warning from the (mandatory) call
to `g_file_info_get_name()`.

Fix that by making the call to `g_file_info_get_name()` optional.

Add a unit test too.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Fixes: #3158
2023-11-07 13:51:56 +00:00
Philip Withnall
3e0a99a059 tests: Add a very basic test suite for gio-tool
It gives nowhere near full coverage, but it’s something we can build on
in future.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3158
Helps: #2950
2023-11-07 13:51:56 +00:00
Philip Withnall
077104e63b tests: Run processes under test with G_DEBUG=fatal-warnings
Modify all the similar Python test wrappers to set
`G_DEBUG=fatal-warnings` in the environment of the program being tested,
so we can catch unexpected warnings/criticals.

Adding this because I noticed it was missing, not because I noticed a
warning/critical was being ignored.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
120e0ee649 tests: Set a default timeout value for GIO Python tests
Otherwise every test has to set one explicitly, which is a bit tedious.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
96ee1ea086 gio-tool: Print help output to stdout when --help is passed
If the help output is explicitly requested by the user, it’s
conventional for it to be printed to stdout rather than stderr.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Philip Withnall
7c97b93837 gio-tool: Factor out repetitive lists of subcommands
Store their details in an array which can be iterated over instead.

This introduces no functional changes, just a cleanup which will allow
following commits to be neater.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-07 13:51:56 +00:00
Sergey Bugaev
150965a9b3 gsocket: Fix detecting timeouts
If she socket is dispatched at exactly the previously set ready time,
it should already be considered to have timed out. This can easily
happen in practice when using a low resolution timer.

This fixes a test failure on GNU/Hurd, see
https://gitlab.gnome.org/GNOME/glib/-/issues/3148

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-11-06 15:14:02 +03:00
Sergey Bugaev
6b7b211338 gio: Add G_IO_ERROR_DESTINATION_UNSET
...and map EDESTADDRREQ to it.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-11-06 15:04:01 +03:00
Philip Withnall
c37bf851e5 tests: Use g_assert_*() rather than g_assert() in stream-rw_all tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-02 17:49:31 +00:00
Philip Withnall
a0de4963e8 tests: Use a pipe rather than a socketpair in stream-rw_all test
The test only needs a unidirectional channel, and a pipe is sufficient
for that.

This may simplify things when running the test on Hurd; see
https://gitlab.gnome.org/GNOME/glib/-/issues/3148#note_1874198.

Additionally, set `O_NONBLOCK` on the pipe since the test seems to
expect that partial writes will succeed and that writes to a full buffer
will fail rather than block.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3148
2023-11-02 17:47:53 +00:00
Philip Withnall
9e95163a3c docs: Move the GZlib*Compressor SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
38c4809719 docs: Move the GWin32RegistryKey SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
754047849c docs: Move the GWin32*Stream SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
7df150eaac docs: Move the GVolumeMonitor SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
ed247401bf docs: Move the GVolume SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
830db4e3c0 docs: Move the GUnixSocketAddress SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
1390713af9 docs: Move the GUnix*Stream SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
68d3f6e53a docs: Move the GUnixCredentialsMessage SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
2be7859f10 docs: Move the GUnixConnection SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
78411d0975 docs: Move the GTlsDatabase SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
15ae12628d docs: Move the GTls*Connection SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
a463a29522 docs: Move the GTlsCertificate SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
45a815ae6d docs: Move the GSocketService SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
bf5c0cc2ba docs: Move the GSocketListener SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
1c34680833 docs: Move the GSocketAddressEnumerator SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
832bf0f90c docs: Move the GSimpleProxyResolver SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-02 16:30:23 +00:00
Philip Withnall
c16c639729 docs: Move the GSettings SECTIONs
Move them to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
8c3e0aa406 docs: Move the GRemoteActionGroup SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
bfa5d99305 docs: Move the GDBusObject SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
ac7cbb146e docs: Move the gtls SECTION
Move it to a separate Markdown page.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-11-02 16:30:23 +00:00
Philip Withnall
1fdbc06385 meson: Add missing dependencies for utility files for gdbus-codegen
Various parts of the build (such as `objectmanager-rst-gen`) depend on
running `gdbus-codegen` after it’s been built, but they currently only
encode a dependency to the main codegen Python file and not the
supporting files. This can cause `gdbus-codegen` to fail with an
`ImportError` if the build races so that `objectmanager-rst-gen` is
built before the codegen supporting files.

Example failure here: https://gitlab.gnome.org/pwithnall/glib/-/jobs/3266471
```
FAILED: gio/tests/gdbus-object-manager-example/objectmanager-rst-gen-org.gtk.GDBus.Example.ObjectManager.Animal.rst gio/tests/gdbus-object-manager-example/objectmanager-rst-gen-org.gtk.GDBus.Example.ObjectManager.Cat.rst
/usr/bin/python3 gio/gdbus-2.0/codegen/gdbus-codegen --interface-prefix org.gtk.GDBus.Example.ObjectManager. --generate-rst objectmanager-rst-gen --output-directory gio/tests/gdbus-object-manager-example ../gio/tests/gdbus-object-manager-example/gdbus-example-objectmanager.xml
Traceback (most recent call last):
  File "/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/gdbus-codegen", line 53, in <module>
    from codegen import codegen_main
  File "/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/codegen_main.py", line 29, in <module>
    from . import dbustypes
  File "/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/dbustypes.py", line 22, in <module>
    from . import utils
ImportError: cannot import name 'utils' from 'codegen' (/builds/pwithnall/glib/_build/gio/gdbus-2.0/codegen/__init__.py)
```

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-02 14:26:31 +00:00
Zander Brown
d33752b5ce
gtask: Add g_task_return_prefixed_error()
An equivalent to g_propagate_prefixed_error, but for errors sent though
GTask, allowing tasks to easily provide extra context to callers.
2023-11-02 02:55:55 +00:00
Philip Withnall
d1eb463ce2 gio-tool: Remove unnecessary exit() call
All the calls to `usage()` are immediately followed by a `return` from
`main()` which sets an appropriate exit status.

Calling `exit()` early means that running `gio --help` returns exit
status 1, which is incorrect — it should (by convention) return 0.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-02 00:50:21 +00:00
Simon McVittie
76148fc6db tests: Don't assume that sh optimizes simple commands into exec
Depending on the operating system, /bin/sh might either be bash (for
example on Fedora or Arch) or dash (for example on Debian or Ubuntu)
or some other POSIX shell.

When bash is asked to run a simple command with no shell keywords or
metacharacters, like this one, it replaces itself with the program
via execve(), but dash does not have that optimization and treats it
like any other program invocation in a larger script: it will fork,
exec the program in the child, and wait for the child in the parent.

This seems like it conflicts with sleep_and_kill() assuming that it can
use the subprocess's process ID as the sleep(1) process ID. Specifically,
if it sends SIGKILL, it will go to the sh(1) process and not the sleep(1)
child, which could result in the sh(1) process being terminated and
its sleep(1) child being leaked.

To get the bash-like behaviour portably, explicitly use the exec builtin
to instruct the shell to replace itself with sleep(1), so that the
process ID previously used for the shell becomes the process ID of the
sleep process.

This appears to resolve an intermittent hang and test timeout on Debian
machines (especially slower ones), although I'm not 100% clear on the
mechanics of how it happens.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3157
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-11-01 17:56:48 +00:00
Marco Trevisan
d1fcb4f253 Merge branch 'gio-test-dependencies' into 'main'
tests: Fix dependency of test.gresource on test-generated.txt

See merge request GNOME/glib!3682
2023-11-01 14:55:25 +00:00
Philip Withnall
5ff31ae57d Merge branch 'zbrown/fix-4ce58df8' into 'main'
codegen: install codegen, not just the wrapper

Closes #3161

See merge request GNOME/glib!3670
2023-11-01 14:22:29 +00:00
Philip Withnall
a61888bceb tests: Fix dependency of test.gresource on test-generated.txt
`test-generated.txt` is listed in `test.gresource.xml`, so it needs to
be specified as a dependency in the `custom_target()` which uses
`test.gresource.xml`.

Fixes intermittent build failures like:
```
FAILED: gio/tests/test.gresource
/builds/GNOME/glib/_build/gio/glib-compile-resources --compiler=gcc --target=gio/tests/test.gresource --sourcedir=/builds/GNOME/glib/gio/tests --sourcedir=/builds/GNOME/glib/_build/gio/tests --internal ../gio/tests/test.gresource.xml
../gio/tests/test.gresource.xml: Failed to locate test-generated.txt in any source directory.
```

See !3671 and #3163.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2023-11-01 11:24:17 +00:00
Philip Withnall
9695ddfc70 Revert "gio/tests: Add test generated txt as the resources test dependency"
This reverts commit 0b9900e4e7.

The dependency was added in the wrong place: `test-generated.txt` is
needed when compiling `test.gresource`, not when compiling the test
which ultimately uses that gresource.

See !3671 and #3163.
2023-11-01 11:10:39 +00:00
Marco Trevisan (Treviño)
0b9900e4e7 gio/tests: Add test generated txt as the resources test dependency
This is required by the resources used in some tests, however we did not
depend on it so we had some random build failures:
  https://gitlab.gnome.org/3v1n0/glib/-/jobs/3253787
2023-10-27 18:41:51 +02:00
Zander Brown
e2433308c4
codegen: install codegen, not just the wrapper
Turns out, wasn't jhbuild this time

Fix: 4ce58df854
2023-10-27 04:21:58 +01:00
Alessandro Bono
168de73a73 meson: Improve PTRACE_O_EXITKILL presence check
The PTRACE_O_EXITKILL symbol in sys/ptrace.h is an enum member, not
a macro. The #ifdef check added to the GSubprocess test-case in
272ec5dbca will not detect it.

Use cc.has_header_symbol() to properly detect it. According to the
documentation: "Symbols here include function, variable, #define,
type definition, etc.".

Fixes: 272ec5dbca
Closes: https://gitlab.gnome.org/GNOME/glib/-/issues/3156
2023-10-26 10:54:34 +02:00
Philip Withnall
58cce38f37 Merge branch 'migrate-to-gi-docgen8' into 'main'
Switch to using gi-docgen for docs (batch 8)

See merge request GNOME/glib!3667
2023-10-25 14:28:43 +00:00
Philip Withnall
14b02d2631 docs: Move the GUnixFDList SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-10-25 15:10:16 +01:00
Philip Withnall
2f662b6063 docs: Move the GTlsPassword SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-10-25 15:10:16 +01:00
Philip Withnall
c015ecf0b7 docs: Move the GTlsInteraction SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-10-25 15:10:16 +01:00
Philip Withnall
850878dfaa docs: Move the GTlsFileDatabase SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-10-25 15:10:16 +01:00
Philip Withnall
74fbc75920 docs: Move the GThreadedSocketService SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-10-25 15:10:16 +01:00
Philip Withnall
325e3a6f5b docs: Move the GThemedIcon SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-10-25 15:10:16 +01:00
Philip Withnall
5817f52222 docs: Move the GTestDBus SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-10-25 15:10:16 +01:00