Commit Graph

21404 Commits

Author SHA1 Message Date
Xavier Claessens
09d995286b doc: Run gtkdoc-check with unit tests
This has the side effect of always rebuilding the doc at each build when
gtk_doc option is enabled (not by default). Most importantly, this will
enable doc check on our CI.
2020-01-29 15:54:53 +01:00
Xavier Claessens
74bb6c98cb doc: add missing indexes 2020-01-29 15:54:53 +01:00
Xavier Claessens
6e8a7c2cd4 doc: Add back gdbus-object-manager-example
This requires Meson 0.52.0 for the return value of gnome.gtkdoc().
2020-01-29 15:40:17 +01:00
Xavier Claessens
6d05ac2fa9 Revert "docs: remove GDBusObjectManager example"
This reverts commit 398c048c66.

It got removed because it used to cause build issues, but now that we
have a CI let's hope it won't be a problem any more.
2020-01-29 15:40:17 +01:00
Philip Withnall
0d3d3e1d84 Merge branch 'deprecatedvolatile' into 'master'
Avoid C++20 deprecated assignment to volatile

See merge request GNOME/glib!1170
2020-01-29 13:09:38 +00:00
Philip Withnall
ecdeee26a9 Merge branch 'BUG_running_docs' into 'master'
docs: tag enclose 'all' and 'help' values

See merge request GNOME/glib!1018
2020-01-29 12:54:32 +00:00
Stephan Bergmann
3e4bca79ff Avoid C++20 deprecated assignment to volatile
794c1a30bc "macro wrappers for
g_once_init_enter/leave" added this line (whose intent is unclear to me).

<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1152r4.html>
"Deprecating volatile" (scheduled for inclusion in C++20) will make the
assignment expression

  *(location) = (result)

deprecated when the LHS is of (non-class) volatile type, which is the case when
g_once_init_leave is expanded as part of e.g. G_DEFINE_TYPE_WITH_CODE (in
gobject/gtype.h), where location is a pointer to some

  static volatile gsize g_define_type_id__volatile = 0;

Recent Clang trunk emits -Wdeprecated-volatile for it under -std=c++2a since
<https://github.com/llvm/llvm-project/commit/
4a6861a7e5b59be24a09b8b9782255d028e7aade> "[c++20] P1152R4: warn on any
simple-assignment to a volatile lvalue".

The fix is to make the assignment expression a discared-value expression by
casting it to void (which in turn requires casting the second branch of the
surrounding conditional expression to void, too; not sure what the top-level
cast to void was intended for, and whether it would still be needed under
certain circumstances).
2020-01-29 13:33:08 +01:00
Nelson Benítez León
fc1e2bc9f0 docs: tag enclose 'all' and 'help' values
so they are not confused as being normal text.

Seen at:
https://developer.gnome.org/glib/stable/glib-running.html
2020-01-29 12:11:24 +00:00
Michael Catanzaro
394a72bc11 Fix crash caused by g_network_monitor_base_add_network()
This avoids a crash when starting Evolution, and fixes the
network-monitor and network-monitor-race test cases on my developer
workstation. (I assume the CI is not crashing due to lack of network
access there.)

Problem is that if a network already exists in the networks table,
g_hash_table_add() "destroys" (unrefs) it before adding the new one
(which we failed to ref before adding). This means we just accidentally
lost a ref. In practice, the network gets unexpectedly destroyed here
before returning.

Fixes #2020
2020-01-27 16:20:20 -06:00
Anders Jonsson
b3328d77c1 Update Swedish translation 2020-01-27 22:06:10 +00:00
Rafael Fontenelle
ab32d5c920 Update Brazilian Portuguese translation 2020-01-27 17:59:52 +00:00
Umarzuki Bin Mochlis Moktar
298281ff55 Update Malay translation 2020-01-27 12:27:35 +00:00
Philip Withnall
9734e4854e gdbus-codegen: Add --glib-max-allowed argument
This complements the `--glib-min-required` argument, just like the
`GLIB_MIN_REQUIRED` and `GLIB_MAX_ALLOWED` preprocessor defines which
control access to APIs in C.

Currently, it doesn’t affect code generation at all. When we next change
code generation, we will need to gate any new API usage on this
argument.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1993
2020-01-27 10:42:26 +00:00
Philip Withnall
4d1c3e15f9 gdbus-codegen: Rename --glib-min-version to --glib-min-required
This makes it consistent with the `GLIB_MIN_REQUIRED` defines which are
used for API stability/versioning in C code.

It doesn’t otherwise change the behaviour of the `--glib-min-version`
argument.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1993
2020-01-27 10:11:46 +00:00
Philip Withnall
93607c4137 Merge branch 'thread-pool-initialization-logic' into 'master'
Fix initialization logic of GThreadPool if the first created pool is an exclusive one

Closes #2012

See merge request GNOME/glib!1340
2020-01-27 09:39:59 +00:00
Sebastian Dröge
78bae85d21 Fix initialization logic of GThreadPool if the first created pool is an exclusive one
Previously we would only ever run the initialization code once, but part
of it only if a non-exclusive pool was created. This caused the shared
state to be inconsistent if the first pool to be created was exclusive
and the second non-exclusive.

Fixes https://gitlab.gnome.org/GNOME/glib/issues/2012
2020-01-25 11:08:22 +02:00
Philip Withnall
ac0c0b5b28 Merge branch '1925-network-monitor-performance' into 'master'
gnetworkmonitorbase: Use a hash table for storing networks

Closes #1925

See merge request GNOME/glib!1313
2020-01-22 16:47:54 +00:00
Philip Withnall
4a488ced5d gnetworkmonitorbase: Use a hash table for storing networks
Rather than using an array, which requires a lot of iteration over it to
check whether a particular network is present. Using a hash table only
requires iteration in the can_reach() case, where we need to match a
mask in the networks array, rather than equal it.

This should improve performance for large numbers of routes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1925
2020-01-22 11:14:34 +00:00
Philip Withnall
0d9d548932 Merge branch 'sizeof-member' into 'master'
Add and use g_sizeof_member() macro

See merge request GNOME/glib!1333
2020-01-22 11:07:03 +00:00
Philip Withnall
ba4e5672ea Merge branch 'wip/seb128/skip-memory-tests-if-portal-missing' into 'master'
tests: Skip GMemoryMonitor tests if xdg-desktop-portal is not available

See merge request GNOME/glib!1338
2020-01-22 08:52:20 +00:00
Sebastien Bacher
422e861633 tests: Skip GMemoryMonitor tests if xdg-desktop-portal is not available
It's useful to have glib tests passing even if you don't have a full
desktop stack available
2020-01-22 10:19:03 +02:00
Iain Lane
b876325c5f Merge branch 'wip/laney/skip-memory-monitor-tests-if-dbusmock-is-too-old' into 'master'
tests: Skip GMemoryMonitor tests if the dbusmock template is not available

See merge request GNOME/glib!1296
2020-01-22 08:13:04 +00:00
Iain Lane
0d4f1a9b21
tests: Skip GMemoryMonitor tests if the dbusmock template is not available
This template is not currently in any released version of dbusmock.
2020-01-22 07:41:17 +00:00
Marc-André Lureau
fd61a21ecd Add and use G_SIZEOF_MEMBER() macro
A convenient macro present in the Linux kernel, named FIELD_SIZE() there.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-01-21 19:54:55 +04:00
Philip Withnall
b413c50dcd 2.63.4
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-21 12:41:48 +00:00
Philip Withnall
3f51963b2d ci: Add checks for banned keywords in merge requests
Using the same approach as we have for code style checks (the
`style-check-diff` CI job), check the diff for any banned keywords like
‘TODO’, and also check the commit messages.

The keyword ‘TODO’ is often used by developers to indicate a part of a
commit which needs further work, and hence which shouldn’t yet be merged.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1551
2020-01-21 12:26:47 +00:00
Philip Withnall
120e6435c7 genviron: Message if g_setenv()/g_unsetenv() are used after threads spawned
g_setenv() and g_unsetenv() can never be thread-safe, so emit a message if
they are used after any threads have been spawned.

This can’t catch interactions between setenv() and g_thread_new(), or
between g_setenv() and pthread_create(), but it’ll catch most
misbehaviour in GLib-centric code.

Currently, the message is a `g_debug()` call. Eventually, I’d like to
upgrade it to a `g_warning()`, but there are a number of GLib tests
which call g_setenv() after threads have been created, and they need to
be fixed first. Emitting a `g_debug()` message gives people an
opportunity to start fixing their code.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #715
2020-01-21 12:07:17 +00:00
Philip Withnall
6271b5eb93 gthread: Count how many threads have been started
This will be used in a following commit to warn if setenv() is used
after another thread has been created.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #715
2020-01-21 11:56:34 +00:00
Philip Withnall
4c1b675eac Merge branch '1232-object-manager-client-signal-race' into 'master'
gdbusobjectmanagerclient: Fix race in signal emission

Closes #1232

See merge request GNOME/glib!1335
2020-01-21 11:52:30 +00:00
Philip Withnall
5d32b99d0c Merge branch '604-dbus-name-watching-simplification' into 'master'
gdbusnamewatching: Check cancellation of a watch before calling back

Closes #604

See merge request GNOME/glib!1336
2020-01-21 11:15:36 +00:00
Philip Withnall
5853d5c8e4 gdbusobjectmanagerclient: Fix race in signal emission
Following on from #978, it seems that #1232 is another instance of the
same problem: signals emitted across threads can’t guarantee their user
data is kept alive between committing to emitting the signal and
actually invoking the callback in the relevant thread.

Fix that by using weak refs to the `GDBusObjectManagerClient` as the
user data for its signals, rather than no refs. Strong refs would create
an unbreakable reference count cycle.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1232
2020-01-21 11:07:21 +00:00
Philip Withnall
5c7a88e972 Merge branch '978-dbus-signal-emission-race' into 'master'
Fix race between D-Bus signal emission and unsubscription

Closes #978

See merge request GNOME/glib!1332
2020-01-21 10:43:39 +00:00
Philip Withnall
73a33e5019 gdbusnamewatching: Check cancellation of a watch before calling back
It’s possible for `g_bus_unwatch_name()` to be called after a
name-appeared or name-vanished handler has been scheduled to be called
in another thread, but before that callback is actually invoked. If so,
the subscribing thread will receive a callback after it’s called
`g_bus_unwatch_name()`, which is unexpected and could cause bugs.

Double-check `client->cancelled` in the target thread before actually
invoking the callback.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #604
2020-01-20 19:19:30 +00:00
Philip Withnall
79792574d4 gdbusnamewatching: Remove a redundant function argument
It was always set to `FALSE`. This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #604
2020-01-20 19:19:30 +00:00
Sebastian Dröge
33ee190b3d Merge branch 'wip/pwithnall/thread-settings-fixes' into 'master'
gthread: Ensure GThreadSchedulerSettings is always defined

See merge request GNOME/glib!1334
2020-01-20 19:06:28 +00:00
Philip Withnall
df0610aa55 ci: Use --wrap-mode=default on macOS CI runner (only)
This is a partial revert of commit 595e12b5fb for macOS only, since we
can’t run a VM image on that CI runner, and hence can’t easily
pre-populate it with cached dependencies.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-20 15:30:44 +00:00
Philip Withnall
03380a4928 tests: Fix header inclusion in win32-appinfo.c
This fixes the following build failure on FreeBSD:
```
  In file included from ../gio/tests/win32-appinfo.c:24:
  /usr/include/malloc.h:3:2: error: "<malloc.h> has been replaced by <stdlib.h>"
  #error "<malloc.h> has been replaced by <stdlib.h>"
```

Hopefully it doesn’t break Windows.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-20 15:22:03 +00:00
Philip Withnall
37b1acdf8c gdbusconnection: Document threading and refcounting for signals
This is essentially a mini writeup of #978.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #978
2020-01-20 15:13:52 +00:00
Philip Withnall
a434bfbb3d gdbusnameowning: Fix race between connection shutdown and NameLost
As with all D-Bus signal subscriptions, it’s possible for a signal
callback to be invoked in one thread (T1) while another thread (T2) is
unsubscribing from that signal. In this case, T1 is the main thread, and
T2 is the D-Bus connection worker thread which is unsubscribing all
signals as it’s in the process of closing.

Due to this possibility, all `user_data` for signal callbacks needs to
be referenced outside the lifecycle of the code which
subscribes/unsubscribes the signal. In other words, it’s not safe to
subscribe to a signal, store the subscription ID in a struct,
unsubscribe from the signal when freeing the struct, and dereference the
struct in the signal callback. The data passed to the signal callback
has to have its own strong reference.

Instead, it’s safe to subscribe to a signal and add a strong reference
to the struct, store the subscription ID in that struct, and unsubscribe
from the signal when the last external reference to your struct is
dropped. That unsubscription should break the refcount cycle between the
signal connection and the struct, and allow the struct to be completely
freed. Only with that approach is it safe to dereference the struct in
the signal callback, if there’s any possibility that the signal might be
unsubscribed from a separate thread.

The tests need specific additional main loop cycles to completely emit
the NameLost signal callback. Ideally they need refactoring, but this
will do (1000 test cycles passed).

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #978
2020-01-20 15:13:52 +00:00
Philip Withnall
4ec2175d21 gdbusconnection: Tidy up unsubscription code
This just removes a now-redundant intermediate array. This means that
the `SignalSubscriber` instances are now potentially freed a little
sooner, inside the locked segment, but they are already careful to only
call their `user_data_free_func` in the right thread. So that should not
deadlock.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #978
2020-01-20 15:13:52 +00:00
Philip Withnall
30c8eb85ab gthread: Ensure GThreadSchedulerSettings is always defined
It’s now used unconditionally for `shared_thread_scheduler_settings` in
`gthreadpool.c`, so it actually needs to have a storage definition.

Fixes a build failure on FreeBSD.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-20 14:39:52 +00:00
Philip Withnall
130455bbb2 gdbusconnection: Fix race when emitting D-Bus signal callbacks
Instead of storing a copy of the `callback` and `user_data` from a
`SignalSubscriber` in a `SignalInstance` struct (which is the closure
for signal callback data as it’s sent from the D-Bus worker thread to
the thread which originally subscribed to a signal), store a strong
reference to the `SignalSubscriber` struct itself.

This keeps the `SignalSubscriber` alive until the emission is
complete, which ensures that the `user_data` is not freed prematurely.
It also slightly reduces the allocation size of `SignalInstance` (not
that it matters).

This is threadsafe because the fields in `SignalSubscriber` are all
immutable after construction.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #978
2020-01-20 14:30:39 +00:00
Philip Withnall
bee27dd9f0 gdbusconnection: Tidy up destroy notification for signal subscriptions
Tie the destruction of the `user_data` to the destruction of the
`SignalSubscriber` struct. This is tidier, and ensures that the fields
in `SignalSubscriber` are all immutable after being set, so the
structure can safely be used across threads without locking.

It doesn’t matter which thread we call `call_destroy_notify()` in, since
it always defers calling `user_data_free_func` to the user-provided
`GMainContext`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #978
2020-01-20 14:30:39 +00:00
Philip Withnall
9b1c8d7dd5 gdbusconnection: Allocate SignalSubscriber structs individually
The `SignalSubscriber` structs contain the callback and `user_data` of each
subscriber to a signal, along with the `guint id` token held by that
subscriber to identify their subscription. There are one or more
`SignalSubscriber` structs for a given signal match rule, which is
represented as a `SignalData` struct.

Previously, the `SignalSubscriber` structs were stored in a `GArray` in
the `SignalData` struct, to reduce the number of allocations needed
when subscribing to a signal.

However, this means that a `SignalSubscriber` struct cannot have a
lifetime which exceeds the `SignalData` which contains it. In order to
fix the race in #978, one thread needs to be able to unsubscribe from a
signal (destroying the `SignalData` struct) while zero or more other
threads are in the process of calling the callbacks from a previous
emission of that signal (using the callback and `user_data` from zero or
more `SignalSubscriber` structs). Multiple threads could be calling
callbacks because callbacks are invoked in the `GMainContext` which
originally made a subscription, and GDBus supports subscribing to a
signal from multiple threads. In that case, the callbacks are dispatched
to multiple threads.

In order to allow the `SignalSubscriber` structs to outlive the
`SignalData` which contained their old match rule, store them in a
`GPtrArray` in the `SignalData` struct, and refcount them individually.

This commit in itself should make no functional changes to how GDBus
works, but will allow following commits to do so.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #978
2020-01-20 14:30:39 +00:00
Philip Withnall
e1cf40a6b2 glib.supp: Ignore the one-off GTask thread pool allocation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-20 11:24:15 +00:00
Philip Withnall
fda1c651d5 Merge branch 'w32-gstat-ino-master' into 'master'
W32: Correctly set st_ino when doing private stat()

See merge request GNOME/glib!1330
2020-01-20 10:49:23 +00:00
Philip Withnall
adee3b31dc Merge branch 'appinfo-rundll32' into 'master'
Add rundll32 support to GAppInfo

Closes #1932

See merge request GNOME/glib!1259
2020-01-20 10:36:29 +00:00
Philip Withnall
2a0b1d8ba0 Merge branch 'threadpool-sched-getattr-runtime-check' into 'master'
Add runtime checks and a fallback if we can't get the thread scheduler settings

Closes #2007

See merge request GNOME/glib!1327
2020-01-20 10:14:11 +00:00
Jordi Mas
3fd06991df Update Catalan translation 2020-01-19 22:20:27 +01:00
Руслан Ижбулатов
9b232fa743 W32: Correctly set st_ino when doing private stat() 2020-01-19 16:57:39 +00:00