Commit Graph

21877 Commits

Author SHA1 Message Date
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
Sebastian Dröge
8b1f24f658 Check for SYS_sched_getattr before using it unconditionally
Really old versions of Linux don't have yet. In that case fall back to
the fallback code.

See 8aeca4fa64 (note_686823)
2020-01-16 16:02:39 +02:00
Xavier Claessens
bc77510b67 Merge branch 'ci-nodownload' into 'master'
ci: Avoid downloading subprojects for each job

See merge request GNOME/glib!388
2020-01-16 13:54:24 +00:00
Philip Withnall
65541f1ad6 ci: Add some documentation to the style check CI test
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:48:56 +00:00
Philip Withnall
3499bd7713 Merge branch 'issue-1998-gsettings-schema-dir-env-var-multiple-dirs' into 'master'
Support multiple directories in GSETTINGS_SCHEMA_DIR

Closes #1998

See merge request GNOME/glib!1315
2020-01-16 11:16:13 +00:00
wouter bolsterlee
809a9210c3 Support multiple directories in GSETTINGS_SCHEMA_DIR
This adds support for specifying multiple directories in the
GSETTINGS_SCHEMA_DIR environment variable by separating the values
using G_SEARCHPATH_SEPARATOR_S (colon on UNIX-like systems).

While programs could already register multiple custom GSettings schema
directories, it was not possible to achieve the same without writing
custom code, e.g. when using the gsettings command line tool.

Fixes #1998.
2020-01-16 10:20:34 +00:00
Philip Withnall
321fea1c5e Merge branch 'wip/muktupavels/notifications' into 'master'
gfdonotificationbackend: remove notifications when bus name vanishes

See merge request GNOME/glib!1317
2020-01-16 06:52:16 +00:00
Xavier Claessens
595e12b5fb ci: Pass --wrap-mode=nodownload to every task
The CI should not waste resources in downloading subprojects for each
task. It should also not rely on external hosts to be available.

Windows case will be handled in MR #402 by migrating to docker.
2020-01-15 21:36:57 -05:00
Xavier Claessens
5f99781d70 ci: Update all docker images 2020-01-15 21:36:57 -05:00
Xavier Claessens
b077c1403e ci: Cache subprojects in docker images 2020-01-15 21:36:57 -05:00
Xavier Claessens
8661d94c3e ci: Install some missing packages in fedora docker image 2020-01-15 21:36:57 -05:00
Xavier Claessens
5daad373a3 ci: Use variables for docker images 2020-01-15 21:36:57 -05:00
Philip Withnall
c0a019c293 Merge branch 'threadpool-inherit-prio' into 'master'
GThreadPool - Don't inherit thread priorities when creating new threads

Closes #1834

See merge request GNOME/glib!1113
2020-01-15 21:56:26 +00:00
Sebastian Dröge
8aeca4fa64 GThreadPool - Don't inherit thread priorities when creating new threads
By default (on POSIX) we would be inheriting thread priorities from the
thread that pushed a new task on non-exclusive thread pools and causes a
new thread to be created. This can cause any non-exclusive thread pool
to accidentally contain threads of different priorities, or e.g. threads
with real-time priority.

To prevent this, custom handling for setting the scheduler settings for
Linux and Windows is added and as a fallback for other platforms a new
thread is added that is responsible for spawning threads for
non-exclusive thread pools.

Fixes https://gitlab.gnome.org/GNOME/glib/issues/1834
2020-01-15 23:18:33 +02:00
Philip Withnall
8e82d549ee Merge branch 'gutils-crash' into 'master'
Fix crash in gutils when application is prevented access to passwd file

See merge request GNOME/glib!1309
2020-01-15 18:14:00 +00:00
Руслан Ижбулатов
9d4d5dfca8 GWin32AppInfo: fix a potential memory leak
Make sure that hndexe_fc_basename is only allocated before it is
actually used.
2020-01-15 18:04:14 +00:00
Руслан Ижбулатов
9f070db4c5 GWin32AppInfo: Support rundll32-using applications
1) When parsing the executable name out of the command line,
see if the executable is rundll32.exe. If that is the case,
use the DLL name from its first argument as the "executable"
(this is used only for matching, and Windows Registry matches
these programs by their DLLs, so this is correct; for running
the application GLib would still use the command line, with
rundll32).

2) If an app runs with rundll32, ensure that rundll32 arguments
can be safely quoted. Otherwise GLib will break them with its
protective quotation.
2020-01-15 18:04:14 +00:00
Philip Withnall
93784fb4c2 Merge branch 'codegen-allow-interactive-auth' into 'master'
gdbus-codegen: Add a GDBusCallFlags arg to method calls

See merge request GNOME/glib!1286
2020-01-15 18:01:52 +00:00
Philip Withnall
a711d59a2f Merge branch 'tz' into 'master'
gtimezone: fix parsing of Julian day in POSIX TZ format

Closes #1999

See merge request GNOME/glib!1314
2020-01-15 17:57:16 +00:00
Matthew Leeds
2a605f6e15 gdbus-codegen: Add call_flags and timeout_msec args
Currently the code generated by gdbus-codegen uses
G_DBUS_CALL_FLAGS_NONE in its D-Bus calls, which occur for each method
defined by the input XML, and for proxy_set_property functions. This
means that if the daemon which implements the methods checks for
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION and only does interactive
authorization if that flag is present, users of the generated code have
no way to cause the daemon to use interactive authorization (e.g. polkit
dialogs).

If we simply changed the generated code to always use
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, its users would have no
way to disallow interactive authorization (except for manually calling
the D-Bus method themselves).

So instead, this commit adds a GDBusCallFlags argument to method call
functions. Since this is an API break which will require changes in
projects using gdbus-codegen code, the change is conditional on the
command line argument --glib-min-version having the value 2.64 or
higher.

The impetus for this change is that I'm changing accountsservice to
properly respect G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, and
libaccountsservice uses generated code for D-Bus method calls. So
these changes will allow libaccountsservice to continue allowing
interactive authorization, and avoid breaking any users of it which
expect that. See
https://gitlab.freedesktop.org/accountsservice/accountsservice/merge_requests/46

It might make sense to also let GDBusCallFlags be specified for property
set operations, but that is not needed in the case of accountsservice,
and would require significant work and breaking API in multiple places.

Similarly, the generated code currently hard codes -1 as the timeout
value when calling g_dbus_proxy_call*(). Add a timeout_msec argument so
the user of the generated code can specify the timeout as well.

Also, test this new API. In gio/tests/codegen.py we test that the new
arguments are generated if and only of --glib-min-version is used with a
value greater than or equal to 2.64, and in gio/tests/meson.build we
test that the generated code with the new API can be linked against.

The test_unix_fd_list() test also needed modification to continue
working now that we're using gdbus-test-codegen.c with code generated
with --glib-min-version=2.64 in one test.

Finally, update the docs for gdbus-codegen to explain the effect of
using --glib-min-version 2.64, both from this commit and from
"gdbus-codegen: Emit GUnixFDLists if an arg has type `h` w/
min-version".
2020-01-15 09:37:41 -08:00
Benjamin Berg
3b039ab181 gmain: Mark G_SOURCE_FUNC as available in 2.58
This means that GLib will generate appropriate deprecation warnings if
`GLIB_VERSION_MAX_ALLOWED` has been set to target a GLib version older
than 2.58.
2020-01-15 16:56:34 +01:00
Alberts Muktupāvels
5d791352f2 gfdonotificationbackend: remove notifications when bus name vanishes
Notification id (notify_id) is generated by notification daemon and
is valid only while daemon is running. If notification backend will
resend/reuse existing notification id (replace_id) after notification
daemon has been restarted it could replace wrong notification as same
id now can be used by different notification.
2020-01-15 16:38:52 +02:00
Sebastian Dröge
6f34e84002 Merge branch 'thread-win32-inherit-prio' into 'master'
GThread - Inherit parent thread priority by default for new Win32 threads

See merge request GNOME/glib!1301
2020-01-15 14:19:36 +00:00
Emmanuele Bassi
7b24e21d51 Merge branch '1997-base64-wrapping-docs' into 'master'
gbase64: Fix documentation for line wrapping lengths

Closes #1997

See merge request GNOME/glib!1321
2020-01-15 14:12:25 +00:00
Daniel P. Berrange
3c0685ec4a gtimezone: fix parsing of Julian day in POSIX TZ format
The timezone(3) man page on Fedora 31 describes the start/end
field in the POSIX TZ format as follows:

[quote]
   The start field specifies when daylight  saving  time  goes
   into  effect and the end field specifies when the change is
   made back to standard time.  These fields may have the fol‐
   lowing formats:

   Jn     This  specifies  the Julian day with n between 1 and
          365.  Leap days are not counted.   In  this  format,
          February 29 can't be represented; February 28 is day
          59, and March 1 is always day 60.

   n      This specifies the  zero-based  Julian  day  with  n
          between  0  and 365.  February 29 is counted in leap
          years.

   Mm.w.d This specifies day d (0 <= d <= 6) of week w (1 <= w
          <=  5)  of  month  m  (1 <= m <= 12).  Week 1 is the
          first week in which day d occurs and week 5  is  the
          last week in which day d occurs.  Day 0 is a Sunday.
[/quote]

The GTimeZone code does not correctly parse the 'n' syntax,
treating it as having the range 1-365, the same as the 'Jn'
syntax. This is semantically broken as it makes it impossible
to represent the 366th day, which is the purpose of the 'n'
syntax.

There is a code comment saying this was done because the Linux
semantics are different from zOS and BSD. This is not correct,
as GLibC does indeed use the same 0-365 range as other operating
systems. It is believed that the original author was mislead by
a bug in old versions of the Linux libc timezone(3) man pages
which was fixed in

  commit 5a554f8e525faa98354c1b95bfe4aca7125a3657
  Author: Peter Schiffer <pschiffe@redhat.com>
  Date:   Sat Mar 24 16:08:10 2012 +1300

    tzset.3: Correct description for Julian 'n' date format

    The Julian 'n' date format counts atrting from 0, not 1.

    Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>

Fixes: #1999

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2020-01-15 14:11:59 +00:00
Daniel P. Berrange
6cd263f655 gtimezone: fix inverted ignore_leap param parsing julian day
The callers of parse_tz_boundary inverted the value passed
for the ignore_leap parameter. Fortunately the method impl
also had an inverted test cancelling out the first bug.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2020-01-15 14:11:59 +00:00
Sebastian Dröge
be537d8b51 GThread - Inherit parent thread priority by default for new Win32 threads
This is the default behaviour on POSIX and having different behaviour
between the two GThread implementations could lead to subtle problems.
2020-01-15 15:23:20 +02:00
Philip Withnall
8d3c502074 gbase64: Fix documentation for line wrapping lengths
The implementation has always wrapped at 76 characters, rather than 72,
ever since it was introduced in commit 5cf8f1d4a8 in 2006. At this
stage, it’s probably best to fix the documentation rather than the
implementation.

The likely bug in the implementation is the comparison
```
(++already) >= 19
```

19 × 4 = 76, so it seems like an off-by-one error in the comparison.
What was actually wanted was 18 × 4 = 72.

Thanks to Simon McVittie for the investigation and diagnosis.

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

Fixes: #1997
2020-01-15 13:15:54 +00:00
Jakub Jelen
d2107c17c8 Reproducer for the null pw_name returned from getpwuid()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2020-01-15 14:07:20 +01:00
Jakub Jelen
17d6fc4e64 gutils: Avoid null dereference if getpwuid fails to acquire some information about user
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2020-01-15 14:07:20 +01:00
Emmanuele Bassi
9ed4b813e5 Merge branch 'wrapdb-workaround' into 'master'
subprojects: Temporarily avoid using wrapdb while it’s down

See merge request GNOME/glib!1320
2020-01-15 12:53:19 +00:00
Philip Withnall
cab577222f subprojects: Temporarily avoid using wrapdb while it’s down
This should fix our CI, which is currently failing on any system which
requires using the zlib subproject (typically VS systems) as wrapdb is
down. Work around that by pointing our wrap file at the underlying
github hosting instead.

See https://github.com/mesonbuild/meson/issues/6446#issuecomment-574241715

This can be reverted when wrapdb is working again.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-15 10:53:47 +00:00
Xavier Claessens
547f5316e3 Merge branch '1416-macos-ci' into 'master'
ci: Add macOS CI runner

Closes #1416

See merge request GNOME/glib!1273
2020-01-14 21:09:48 +00:00
Michael Catanzaro
9765ce80c9 Merge branch 'mcatanzaro/rehandshake' into 'master'
Fully deprecate TLS rehandshakes

See merge request GNOME/glib!1305
2020-01-07 21:14:38 +00:00
Michael Catanzaro
bbbaae9fb7 Fully deprecate TLS rehandshakes
Previously, the documentation indicated that it was possible to call
g_tls_connection_handshake() after an initial handshake to trigger a
rehandshake, but only if TLS 1.2 or older is in use. However, there is
no documented way to ensure TLS 1.2 gets used. Nowadays, TLS 1.3 is used
by default.

I'm removing support for rehandshaking from glib-networking, as part of
a large refactoring where keeping rehandshakes would have entailed
significant additional complexity. So let's update the documentation to
indicate this is no longer ever supported. Applications should not
notice any difference.

Also, sync some previous handshake and rehandshake changes from
GTlsConnection to GDtlsConnection that were missed by mistake. I
try to remember to always update GDtlsConnection when touching
GTlsConnection documentation, but it's easy to forget.
2020-01-07 14:52:20 -06:00
Bastien Nocera
e706cc9cf2 Merge branch 'wip/hadess/fix-gmemory-monitor-example' into 'master'
GMemoryMonitor docs fixes

See merge request GNOME/glib!1294
2020-01-07 17:51:51 +00:00
Bastien Nocera
2394bc755a docs: Add full code example for GMemoryMonitor 2020-01-07 18:29:53 +01:00
Bastien Nocera
b04be9efc7 docs: Fix markup that led to unreadable example
We used XML to markup when we should have used our own brand of markdown
instead. This fixes the example being unreadable unless we trimmed the
XML away from it.
2020-01-07 18:29:53 +01:00
Philip Withnall
4151dfea82 Merge branch 'wip/hadess/test-fixes' into 'master'
gio: Fix socket test

See merge request GNOME/glib!1295
2020-01-07 16:21:20 +00:00
Philip Withnall
a7880d84d0 Merge branch 'wip/smcv/gvariant-memcpy0' into 'master'
gvariant-core: Don't pass NULL second argument to memcpy

See merge request GNOME/glib!1303
2020-01-07 16:16:35 +00:00