Commit Graph

21346 Commits

Author SHA1 Message Date
Philip Withnall
bb501bb8be Merge branch 'mcatanzaro/pkcs11-deferral' into 'master'
Revert "gtlscertificate: Add support for PKCS #11 backed certificates"

See merge request GNOME/glib!1347
2020-01-31 12:19:15 +00:00
Philip Withnall
5941bfa49c Merge branch 'mcatanzaro/#2020' into 'master'
Fix crash caused by g_network_monitor_base_add_network()

Closes #2020

See merge request GNOME/glib!1343
2020-01-31 12:15:20 +00:00
sicklylife
b6b18f0190 Update Japanese translation 2020-01-30 16:21:59 +00:00
sicklylife
556b8df3fd Update Japanese translation 2020-01-30 16:14:13 +00:00
Michael Catanzaro
d58e5de9e9 Revert "gtlscertificate: Add support for PKCS #11 backed certificates"
This reverts commit b6d8efbebc.

This GLib API is good, but the implentation is not ready, so there's no
reason to commit to the API in GLib 2.64. We can reland again when the
implementation is ready.

There are three problems: (a) The glib-networking implementation normally
works, but the test has been broken for a long time. I'm not comfortable
with adding a major new feature without a working test. This is
glib-networking#104. (b) The WebKit implementation never landed. There
is a working patch, but it hasn't been accepted upstream yet. This API
isn't needed in GLib until WebKit is ready to start using it.
https://bugs.webkit.org/show_bug.cgi?id=200805. (c) Similarly, even if
the WebKit API was ready, that itself isn't useful until an application
is ready to start using it, and the Epiphany level work never happened.

Let's try again for GLib 2.66. Reverting this commit now just means we
gain another six months before committing to the API forever. No reason
to keep this in GLib 2.64 when nothing is using it yet.
2020-01-30 04:19:22 -06: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
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
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
Sebastian Dröge
d1a3be5605 Remove trailing comma from SYS_sched_getattr meson check 2020-01-19 10:48:33 +02:00
Sebastian Dröge
012660b8fa Add runtime checks and a fallback if we can't get the thread scheduler settings
On Linux the sched_getattr syscall might be available at compile-time
but not actually work at runtime (e.g. because an older kernel is
running or valgrind is used). Instead of killing the process, return
FALSE and handle this gracefully at runtime with some fallback code.

Fixes https://gitlab.gnome.org/GNOME/glib/issues/2007
2020-01-19 10:47:52 +02:00
Sebastian Dröge
457ea97c75 Merge branch 'threadpool-sched-getattr' into 'master'
Check for SYS_sched_getattr before using it unconditionally

See merge request GNOME/glib!1325
2020-01-17 07:40:38 +00:00
Emmanuele Bassi
60dc7e612d Merge branch 'style-check-docs' into 'master'
ci: Add some documentation to the style check CI test

See merge request GNOME/glib!1324
2020-01-16 14:19:27 +00:00