Commit Graph

6209 Commits

Author SHA1 Message Date
Michael Catanzaro
30524fbdb5 gdbusserver: properly escape all components of server address
https://gitlab.gnome.org/GNOME/glib/merge_requests/911#note_530668
2019-06-17 12:08:06 -05:00
Michael Catanzaro
16cdda5d35 gdbus: run peer test multiple times with different addresses
This ensures that D-Bus connections established with unix:dir and
unix:path addresses actually work properly. Previously, we only tested
unix:tmpdir and TCP addresses.
2019-06-17 12:08:06 -05:00
Michael Catanzaro
eca16677c0 gdbus: Fix minor leak in peer test
This has to be freed even on Windows.
2019-06-17 12:08:06 -05:00
Michael Catanzaro
beac9fe211 gdbus: Clean up sockets and nonces from filesystem
When we close the GDBusServer, it should remove any non-abstract Unix
sockets or TCP nonce files it created from the filesystem.

Fixes #1808
2019-06-17 12:08:06 -05:00
Michael Catanzaro
f5631ecb94 gdbus: improve an error message
Namespace is one word.
2019-06-17 12:08:06 -05:00
Michael Catanzaro
99b580a0b2 gdbus: Stop server on dispose
This is not going to have much any effect currently since stop() just
disconnects a signal handler (that is going to be disconnected in
finalize anyway) and stops the socket service (that is going to be
destroyed in finalize), but it makes sense to do here for robustness.
2019-06-17 12:08:06 -05:00
Michael Catanzaro
fc597fa5f9 gdbus: support unix:dir= addresses
unix:dir= addresses are exactly the same as unix:tmpdir= addresses,
already supported by GDBus, except they forbid use of abstract sockets.
This is convenient for situations where abstract sockets are
impermissible, such as when a D-Bus client inside a network namespace
needs to connect to a server running in a different network namespace.
An abstract socket cannot be shared between two processes in different
network namespaces.

Applications could use unix:path= addresses instead, so this is only a
convenience, but there's no good reason not to support unix:dir=.
Currently it is not supported simply because unix:dir= is a relatively
recent addition to the D-Bus spec.
2019-06-17 12:07:10 -05:00
Michael Catanzaro
6a5c4252cd Merge branch '940-socket-listener-docs' into 'master'
gsocketlistener: Clarify when g_socket_listener_set_backlog() works

Closes #940

See merge request GNOME/glib!921
2019-06-17 17:05:42 +00:00
Philip Withnall
063722ef80 gsocketlistener: Clarify when g_socket_listener_set_backlog() works
Spotted by Paolo Borelli.

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

Fixes: #940
2019-06-17 16:26:48 +01:00
Philip Withnall
25636e50e0 gdbusmessage: Fix comparisons out of range for enum types
This was warning on macOS.

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

Fixes: #887
2019-06-17 15:45:30 +01:00
Philip Withnall
fa5996927f Merge branch 'drop-g-disable-deprecated' into 'master'
Drop G_DISABLE_DEPRECATED

Closes #1060 and #638

See merge request GNOME/glib!871
2019-06-14 11:24:25 +00:00
Emmanuele Bassi
94a56ae4f5 Merge branch '1807-dbus-server-docs' into 'master'
gdbusserver: Drop reference to non-existing function from documentation

Closes #1807

See merge request GNOME/glib!913
2019-06-12 12:05:56 +00:00
Philip Withnall
b1fbb36ba3 Merge branch 'prop-action-state-hints' into 'master'
property action: Add state hints

See merge request GNOME/glib!906
2019-06-12 11:59:58 +00:00
Philip Withnall
6e25d936fa gdbusserver: Drop reference to non-existing function from documentation
Spotted by Michael Catanzaro.

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

Fixes: #1807
2019-06-12 12:48:49 +01:00
Sebastian Dröge
03ce878736 Merge branch '1729-mime-result-prio' into 'master'
Resolve "g_content_type_guess segfaults when passed an empty data buffer on Mac OS"

Closes #1729

See merge request GNOME/glib!733
2019-06-11 11:38:33 +00:00
Sebastian Dröge
f78194e8d0 Merge branch 'settings-list-order' into 'master'
gsettings: Document that lists are returned in no defined order

See merge request GNOME/glib!851
2019-06-11 11:35:58 +00:00
Sebastian Dröge
e85f1ced5f Merge branch 'compile-schemas-strings' into 'master'
glib-compile-schemas: Improve translatable strings

See merge request GNOME/glib!678
2019-06-11 11:34:05 +00:00
Simon McVittie
11233f572d gdbusdaemon: Only authorize anonymous users on Windows, not Unix
On Unix, we expect EXTERNAL authentication to work.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:36 +01:00
Simon McVittie
a5923d4e49 gdbus-example-peer: Provide an example GDBusAuthObserver
It's somewhat unrealistic to use a GDBusServer without a
GDBusAuthObserver, because most D-Bus servers want to be like the
standard session bus (the owning user can connect) rather than being
like the standard system bus (all users can connect, the server is a
security boundary, and many bugs are security vulnerabilities).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:36 +01:00
Simon McVittie
281a03d603 GDBusAuthObserver: Document how to restrict authentication to EXTERNAL
This is simpler and more robust than DBUS_COOKIE_SHA1, which relies
on assumptions about random numbers and a secure home directory.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:36 +01:00
Simon McVittie
1da3280b9e GDBusAuthObserver: Fix mixup between authentication and authorization
Authentication is about proving who I am; authorization is about
whether, given the knowledge of who I am, I am allowed to do something.
GDBusServer and GDBusConnection carry out authentication automatically,
but rely on the library user to carry out authorization.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:35 +01:00
Simon McVittie
f5a01e0e4a GDBusServer: Document that a GDBusAuthObserver is usually desirable
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:35 +01:00
Simon McVittie
5e24d7cd14 Document where we expect credentials-passing to be supported
This is useful information for implementors of portable software to know
whether they can rely on credentials-passing.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-11 11:06:35 +01:00
Philip Withnall
f6736a2589 tests: Use a temporary directory for testfilemonitor
Previously, its tests were being run in the build directory, which is
fine (it should always be writable). If multiple tests were run in
parallel, for example with Meson’s `--repeat` option, their test files
would collide.

Fix that by running each test instance in a separate subdirectory of
`/tmp`.

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

Helps: #1634
2019-06-10 15:19:34 +01:00
Philip Withnall
f124349fa1 tests: Improve debug output on testfilemonitor failure
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1634
2019-06-10 14:58:45 +01:00
Matthias Clasen
459c4f296a property action: Add state hints
We have this information in the param specs,
we might as well pass it on to give consumers
a chance to present meaningful UIs for these
actions.
2019-06-10 00:03:25 +00:00
Philip Withnall
4e00fdea9b Merge branch 'filio' into 'master'
Include <sys/filio.h> for FIONREAD

See merge request GNOME/glib!889
2019-06-05 11:24:56 +00:00
Allison Karlitskaya
efeaf8f747 network-address test: add ipv6-fail ipv4-slow case
Add a case for when the IPv6 result comes back negative and the IPv4
result is significantly delayed.  This is exactly the case that causes
the bug addressed by GNOME/glib!865
2019-06-04 20:09:26 +01:00
Allison Karlitskaya
97f8d3e1d8 gnetworkaddress: fix "happy eyeballs" logic
The "happy eyeballs" RFC states that on receiving a negative response
for an IPv6 address lookup, we should wait for the IPv4 lookup to
complete and use any results we get from there.

The current code was not doing that: it was rather setting a timeout for
failing the resolution entirely.  In scenarios where the IPv4 response
comes more than 50ms after the IPv6 response (which is easily attainable
under valgrind in certain configurations) this means that the IPv4
response will never come.

Remove the timeout and just wait.

See merge request GNOME/glib!865
2019-06-04 20:09:26 +01:00
Maya Rashish
de2ad60578 Include <sys/filio.h> for FIONREAD 2019-06-04 13:13:37 +03:00
Philip Withnall
b73713d893 tests: Add a test for g_content_type_guess() with no arguments
It should produce a generic result, but not crash. It was previously
crashing on macOS.

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

Fixes: #1729
2019-06-03 12:16:50 +01:00
Philip Withnall
4a0cb8f3a1 xdgmime: Don’t set an out argument if it’s NULL
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1729
2019-06-03 12:13:53 +01:00
Philip Withnall
d586ab4c73 tests: Use g_assert_*() instead of g_assert() in contenttype tests
g_assert_*() give more helpful error messages on failure, and aren’t
compiled out by G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-03 12:13:53 +01:00
Sebastian Dröge
a4d01fcd4b Merge branch '1796-gio-pkg-bin-variables' into 'master'
build: Add various installed utilities to gio-2.0.pc

Closes #1796

See merge request GNOME/glib!881
2019-06-03 10:43:44 +00:00
Philip Withnall
799caf772b gsubprocess: Add missing (nullable) annotation to get_identifier()
The bottom of the documentation comment for this symbol seems to have
been missing.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-31 23:38:58 +01:00
Philip Withnall
7f256e63d0 tests: Fix small race in GSubprocess tests
This was introduced in commit 7846d6154a: g_subprocess_get_identifier()
will return NULL after the subprocess has exited, and the subprocess in
the `noop` test will exit as soon as it has started spawning. So if the
scheduler scheduled the testprog subprocess quickly, descheduled the
parent test process until the testprog exited, then the return value
from g_subprocess_get_identifier() would be NULL.

Move the g_subprocess_get_identifier() test to one which calls testprog
in `sleep-forever` mode, since that is guaranteed not to exit until
killed (which we do later in the test).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-31 23:35:27 +01:00
Philip Withnall
3a9f9e3509 build: Add various installed utilities to gio-2.0.pc
The most useful ones were already listed in the pkg-config file, but
some others (notably, `gio-querymodules`) were not. List them in the
pkg-config file with their installed paths so that the right binary is
used if GIO is installed in a non-default path.

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

Fixes: #1796
2019-05-31 21:23:05 +01:00
Philip Withnall
e37f0cbd89 gnetworkmonitornm: Consider NM_STATE_CONNECTED_SITE to be available
`NM_STATE_CONNECTED_SITE` is documented to mean that a default route is
available, but that the internet connectivity check failed. A default
route being available is compatible with the documentation for
GNetworkMonitor:network-available, which should be true if the system
has a default route for at least one of IPv4 and IPv6.

https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html

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

Fixes: #1788
2019-05-31 11:19:07 +01:00
Sebastian Dröge
8b3f186d8f Merge branch '1790-file-attribute-as-string-annotation' into 'master'
gfileinfo: Add missing (nullable) annotation to get_attribute_as_string()

Closes #1790

See merge request GNOME/glib!879
2019-05-31 10:16:43 +00:00
Sebastian Dröge
c1a15894e4 Merge branch 'writev-max-num-vectors' into 'master'
Clamp number of vectors to IOV_MAX / UIO_MAXIOV for GOutputStream writev()...

See merge request GNOME/glib!874
2019-05-31 10:04:57 +00:00
Philip Withnall
ebacb64539 gfileinfo: Slightly improve documentation formatting
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-31 10:58:10 +01:00
Philip Withnall
67a0d5237e gfileinfo: Add missing (nullable) annotation to get_attribute_as_string()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1790
2019-05-31 10:58:00 +01:00
Sebastian Dröge
20a2c379c4 Clamp number of vectors to IOV_MAX / UIO_MAXIOV for GOutputStream writev() calls in the implementations
More vectors will give an error and we can simply clamp here and
consider it like a short write instead.

In case of GSocketOutputStream this is done here instead of inside
GSocket before calling sendmsg() because we we can't generically handle
short writes when sending messages on a socket, e.g. for datagram
sockets this causes only part of the datagram to be sent and an error
would be more useful in this case than sending corrupted data.

Also reduce the fallback limit to 16 in gsocket.c as that's the minimum
value required by POSIX and add a static assertion that the limit is
never bigger than G_MAXINT as that's the type recvmmsg/sendmmsg take.
2019-05-31 12:51:59 +03:00
Philip Withnall
947355c101 Merge branch 'wip/oholy/copy-permissions' into 'master'
CVE-2019-12450: gfile: Limit access to files when copying

See merge request GNOME/glib!876
2019-05-31 09:09:30 +00:00
Philip Withnall
40ff475977 Annotate various types and macros as deprecated
These have all been documented as deprecated for a long time, but we’ve
never had a way to programmatically mark them as deprecated. Do that
now.

This is based on the list of deprecations from the reverted commit
80fcb1bc2.

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

Fixes: #638
2019-05-30 10:39:11 +01:00
Philip Withnall
1741fc2c6e build: Drop use of G_DISABLE_DEPRECATED from the build system
It’s no longer used in any of the headers. See preceding commits.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
e62e89f2f8 Fix various deprecation warnings in code and tests
This code uses, or tests, deprecated functions, types or macros; so
needs to be compiled with deprecation warnings disabled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
b4d58a7105 glib, gio: Use GLIB_DEPRECATED_MACRO instead of G_DISABLE_DEPRECATED
When defining deprecated macros, annotate them with
`GLIB_DEPRECATED_MACRO_IN_*()` and `GLIB_DEPRECATED_MACRO_IN_*_FOR()` to
conditionally emit warnings if people use them, depending on their
declared minimum and maximum GLib version requirements (see
`GLIB_VERSION_MIN_REQUIRED` and `GLIB_VERSION_MAX_ALLOWED`).

The old way of doing this was for users to define `G_DISABLE_DEPRECATED`
if they didn’t want to use deprecated APIs, but it reported errors via
missing symbols, and wasn’t version-dependent. It’s being phased out.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
70c8a7ef8d gdesktopappinfo: Improve documentation formatting slightly
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
9bfd7e2a9d gdesktopappinfo: Add deprecation version to GDesktopAppInfoLookup
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Ondrej Holy
d8f8f4d637 gfile: Limit access to files when copying
file_copy_fallback creates new files with default permissions and
set the correct permissions after the operation is finished. This
might cause that the files can be accessible by more users during
the operation than expected. Use G_FILE_CREATE_PRIVATE for the new
files to limit access to those files.
2019-05-24 09:58:18 +02:00
Philip Withnall
970599ab7a Merge branch 'osx-psn' into 'master'
gapplication: skip unexpected -psn_ parameter

Closes #1784

See merge request GNOME/glib!864
2019-05-23 10:16:01 +00:00
Ignacio Casal Quinteiro
e367a4f66f gapplication: skip unexpected -psn_ parameter
When an application is launched using Launch Services
osx will add an extra parameter which we were not
handling and then gapplication would abort. Instead we make
an initial parsing and like this we avoid the abort if this
parameter is provided

Fixes https://gitlab.gnome.org/GNOME/glib/issues/1784
2019-05-22 09:11:26 +02:00
Marco Trevisan (Treviño)
5deaf0bfdf gdbusserver: Use g_clear_signal_handler 2019-05-21 12:10:01 -05:00
Philip Withnall
13da7e5c2e Merge branch 'wip/ignazp/gtask-wait-time-fix' into 'master'
gtask: fix task_wait_time estimation

Closes #1683

See merge request GNOME/glib!644
2019-05-20 11:07:54 +00:00
Philip Withnall
9c4026d673 gsettings: Add missing ‘Deprecated’ tag to g_settings_list_keys() docs
It was already deprecated in the header, but the tag was missing from
the documentation.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-17 13:06:08 +01:00
Philip Withnall
d2b419c81f gsettings: Document that lists are returned in no defined order
The caller cannot assume that the lists returned by various GSettings
functions (for example, lists of keys or schemas) will be returned in
any particular order.

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

Helps: #1781
2019-05-17 13:03:27 +01:00
Philip Withnall
505f45ef95 tests: Remove redundant --tap options
Now that TAP output is used by default, passing `--tap` is unnecessary.

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

Helps: #1619
2019-05-14 12:42:51 +01:00
Michael Catanzaro
c252bd150a Merge branch 'wip/tingping/network-address-state' into 'master'
gnetworkaddress: Fix parallel enumerations interfering with each other

Closes #1771

See merge request GNOME/glib!823
2019-05-10 17:46:42 +00:00
Patrick Griffis
5ba42af9b1 gnetworkaddress: Fix parallel enumerations interfering with eachother
The parent GNetworkAddress contains a shared list of resolved
addresses that is used as a cache for multiple enumerations.

This commit ensures that the cache is only set upon completion of
DNS lookups and only read once by enumerations to avoid being in a
bad state.

Fixes #1771
2019-05-10 10:17:23 -07:00
Allison Karlitskaya
bdefe5f9e1 gsocketclient: Fix a leak in the connection code
We miss releasing the async operation's reference on a state object in
one of the error cases.

The call to connection_attempt_remove() (although it calls unref
internally) is not sufficient because this is releasing the reference
that the list owns.

Closes #1774
2019-05-09 12:57:00 +02:00
Philip Withnall
76966e6b28 Merge branch 'wip/ernestask/dtd-fix' into 'master'
gschema.dtd: Add target attribute to alias

See merge request GNOME/glib!814
2019-05-07 10:31:53 +00:00
Philip Withnall
0ff97045b8 Merge branch '1739-freebsd-too' into 'master'
tests: Don’t check for libdl on FreeBSD or NetBSD either

Closes #1739

See merge request GNOME/glib!810
2019-05-07 10:26:57 +00:00
Michael Catanzaro
b17436d952 Merge branch 'wip/tingping/socketclient-cancel-2' into 'master'
gsocketclient: Fix potential critical when cancelling connect

Closes #1747

See merge request GNOME/glib!783
2019-05-06 21:50:25 +00:00
Ernestas Kulik
3d9a896f2b gschema.dtd: Add target attribute to alias
The implementation requires it, but the DTD doesn’t even mention it.
2019-05-06 16:26:53 +02:00
Carlos Garnacho
133ad1d390 gappinfo: Add precondition checks to GAppLaunchContext env methods
Spotted in https://gitlab.gnome.org/GNOME/mutter/issues/586. Bad input
on GAppLaunchContext environment manipulation functions is caught by
inner code, but the warning is not seemingly related.

Add precondition checks to these functions so it's clear where does the
bad input come from.
2019-05-06 13:05:24 +02:00
Sebastian Dröge
d16a7b26eb Merge branch 'socket-docs-trivial' into 'master'
gsocket: Clarify in docs that `flags` arguments can be platform specific

See merge request GNOME/glib!732
2019-05-02 12:54:18 +00:00
Philip Withnall
c6342b975d tests: Don’t check for libdl on FreeBSD or NetBSD either
As with commit c14ac90ed2, it isn’t needed
and doesn’t exist.

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

Fixes: #1739
2019-05-02 13:00:48 +01:00
Philip Withnall
31c4a3afc5 Merge branch 'flaky-monitor' into 'master'
Remove monitor test

See merge request GNOME/glib!785
2019-04-30 10:04:03 +00:00
Philip Withnall
e9389efe5b gsocket: Clarify in docs that flags arguments can be platform specific
As suggested by Philip Chimento.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-29 13:21:08 +01:00
Fabrice Bellet
719133e882 gnetworkmonitornm: Fix network available detection
The network-available property can be asserted by querying the NMState
describing the current overval network state, instead of the
NMConnectivityState. The advantage of the NMState is that is reflects
immediately the network state modification, while the connectivity
state is tested at a fixed frequency.
2019-04-29 12:05:54 +00:00
Philip Withnall
798c59a14f Merge branch 'openbsd-no-ld' into 'master'
gio: tests, don't check for libdl on OpenBSD

See merge request GNOME/glib!802
2019-04-29 11:21:41 +00:00
Philip Withnall
4ceac0d40c Merge branch '1760-txt-record-docs' into 'master'
docs: Clarify support for multiple TXT record strings

Closes #1760

See merge request GNOME/glib!797
2019-04-29 10:50:05 +00:00
Philip Withnall
753eeb1bac gproxy: Add a missing ‘the’ to a documentation comment
Spotted by Michael Catanzaro.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-29 11:33:02 +01:00
Antoine Jacoutot
c14ac90ed2 gio: tests, don't check for libdl on OpenBSD
libdl does not exist on OpenBSD and is not required as the
functionnality is provided in libc.
2019-04-27 18:45:45 +02:00
Philip Withnall
5bb19b04af docs: Clarify support for multiple TXT record strings
Most TXT records only contain a single string, but some may contain
more.

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

Fixes: #1760
2019-04-26 16:49:38 +01:00
Philip Withnall
63af8ed0ea Merge branch 'mate-xfce4-term' into 'master'
gdesktopappinfo: Add support for MATE and Xfce4 terminals

See merge request GNOME/glib!795
2019-04-26 11:27:19 +00:00
Philip Withnall
e036d1bb29 docs: Improve formatting of GVariant types in GResolverRecordType docs
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-26 12:15:55 +01:00
Philip Withnall
38de3e9dc3 docs: Use ‘look up’ as a verb, rather than the noun ‘lookup’
Another niggle fixed.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-26 12:12:31 +01:00
Sebastian Dröge
0b562298fd Merge branch 'master-terminology' into 'master'
general: Remove a few unhelpful references to ‘master’

See merge request GNOME/glib!792
2019-04-25 15:26:06 +00:00
Colomban Wendling
292cb2cb1b gdesktopappinfo: Add support for MATE and Xfce4 terminals
Add support for mate-terminal and xfce4-terminal with higher precedence
over xterm as it's likely people that have those want to use them.
They both use the gnome-terminal `-x` switch instead of xterm's `-e`.
2019-04-25 16:10:49 +02:00
Philip Withnall
aba0b644c2 Merge branch 'issue-1751' into 'master'
cocoanotificationbackend: do not release readonly property

Closes #1751

See merge request GNOME/glib!786
2019-04-25 09:11:44 +00:00
Philip Withnall
192bf09529 general: Remove a few unhelpful references to ‘master’
Some of these have a negative master/slave connotation, and they add no
value. Change or drop them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-25 09:25:49 +01:00
Ignacio Casal Quinteiro
c4493d22d1 cocoanotificationbackend: do not release readonly property
Fixes a crash when releasing a property that was not retained before.

Helps: https://gitlab.gnome.org/GNOME/glib/issues/1751
2019-04-23 17:10:12 +02:00
Philip Withnall
9144aa2a86 tests: Fix some minor tests in the GResolver tests in manual mode
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1753
2019-04-23 11:31:04 +01:00
Michael Gratton
6b61395c2d build: Remove */.gitignore files
Since out-of-source-tree builds are now used after switching to meson,
we don't need .gitignore files in the source directories to ignore
build artifacts.

This fixes build errors when doing a meson build after an autotools
build, because generated files such as gio/xdp-dbus.c won't show up in
a `git status`, or be removed by a `git clean -f`, and so it won't be
obvious that such files need to be removed for the meson build to
succeed.
2019-04-22 22:17:43 +10:00
Emmanuele Bassi
5299e8754c Remove monitor test
The `monitor` test was originally written to test GFileMonitor with
directories. Over time, `testfilemonitor` acquired units for testing
directories as well, which made the `monitor` test reduntant.
2019-04-22 10:36:56 +01:00
Patrick Griffis
313e7cbad7 gsocketclient: Fix potential critical when cancelling connect
We are manually tracking the completion state of the connect task
so avoid just calling g_task_return_error_if_cancelled() without
checking that.

Fixes #1747
2019-04-16 10:26:01 -07:00
Adam Duskett
e7b0d89aeb Only build tests if certain conditions are met.
Currently, there is no way to prevent tests from building using meson.
When cross-compiling, building the tests isn't necessary.

Instead, only build the tests on the following conditions:
1) If not cross-compiling.
2) If cross-compiling, and there is an exe wrapper.
2019-04-16 10:19:41 +00:00
Emmanuele Bassi
cd04cf7778 Merge branch '1614-freebsd-threading-flaky' into 'master'
tests: Unmark several gdbus-* tests as flaky

Closes #1614

See merge request GNOME/glib!777
2019-04-15 09:11:13 +00:00
Philip Withnall
b11f323ee5 tests: Only run --external-data test on GNU ld/objcopy
Other GCC-like implementations of ld/objcopy (like LLVM) don’t yet
support the right command line arguments, so can’t compile the test.

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

https://gitlab.gnome.org/GNOME/glib/issues/1709
2019-04-12 18:00:12 +01:00
Philip Withnall
ea8e6502d4 build: Refactor resources test build instructions
This introduces no functional changes, but combines two duplicated lists
and makes the meson.build file a little easier to follow.

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

Helps: #1711
2019-04-12 18:00:12 +01:00
Philip Withnall
a06d7cc7b8 build: Fix some whitespace problems in gio/tests/meson.build
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 18:00:12 +01:00
Philip Withnall
bc81b2c4cb tests: Unmark several gdbus-* tests as flaky
After repeated local testing, I can’t reproduce failures with them:

   meson test --repeat 5000 gdbus-auth
   meson test --repeat 5000 gdbus-bz627724
   meson test --repeat 5000 gdbus-connection

The FreeBSD failures from pthread calls mentioned in #1614 should
probably manifest as use-after-free for GMutex or pthread_mutex_t on
Linux. Failing that, I haven’t seen any relevant FreeBSD failures on CI
for at least a month, so if it’s not fixed, the chances of debugging are
very low.

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

https://gitlab.gnome.org/GNOME/glib/issues/1614
2019-04-12 17:08:22 +01:00
Philip Withnall
1fbf82be17 gdbusprivate: Clarify GDBusMessage ownership transfers
Add g_steal_pointer() and g_clear_object() calls in various places to
clarify the ownership transfers for GDBusMessage instances, in a bid to
understand what’s going on in this code and to try to find a
use-after-finalize problem.

This introduces no functional changes, but hopefully makes the code a
little clearer.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 16:56:04 +01:00
Philip Withnall
96aa2e34b3 gdbusdaemon: Fix error handling for filtering outgoing messages
If the filter function for an outgoing message fails to copy the
GDBusMessage, that failure was previously ignored, and GDBusMessage
methods could be called on a NULL instance.

Avoid that.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 16:55:17 +01:00
Philip Withnall
2dac148299 gthreadedsocketservice: Handle thread pool push failure
This was previously silently ignored, and would result in a leak.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 15:24:05 +01:00
Philip Withnall
035c5d03f1 gthreadedsocketservice: Move obj reference to per-job data
Rather than keeping a reference to the GThreadedSocketService as the
user_data for every thread pool job, add it to a member of the per-job
data struct (GThreadedSocketServiceData). This should make no
difference overall, as it’s just moving the refcounting around, but it
does seem to fix an occasional double-unref crash on shutdown where the
GThreadedSocketService is unreffed during finalisation.

In any case, it makes the object ownership clearer.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 15:22:19 +01:00
Philip Withnall
63823ae628 gthreadedsocketservice: Abstract out a free function
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 15:21:33 +01:00
Philip Withnall
ec569ff2e2 gthreadedsocketservice: Tidy up property declarations
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-12 15:18:48 +01:00
Niels De Graef
6287f64e1d gdbus-tool: Colorize the output of "introspect"
When available on stdout, the `gdbus introspect` command will now add
colors to make it easier for humans to visually parse the output.

https://gitlab.gnome.org/GNOME/glib/merge_requests/761
2019-04-11 18:03:50 +02:00
Emmanuele Bassi
cf54fc3600 Merge branch '1737-gdbus-tool-wait' into 'master'
gdbus-tool: Fix units for `gdbus-tool wait` timeout

Closes #1737

See merge request GNOME/glib!753
2019-04-03 12:36:54 +00:00
Philip Withnall
abde3efb34 Merge branch 'wip/oholy/trash-autofs' into 'master'
gunixmounts: Return the last matching mount for same mount path

Closes #1727

See merge request GNOME/glib!740
2019-04-03 12:23:10 +00:00
Philip Withnall
8349ceeac9 Merge branch 'use_after_free' into 'master'
Fix use-after-free triggered by gnome-session-binary

See merge request GNOME/glib!741
2019-04-03 12:01:04 +00:00
Ignacio Casal Quinteiro
55870d4b42 Properly ensure the cocoa notification backend type 2019-03-29 15:52:38 +01:00
Philip Withnall
d86146df38 gdbus-tool: Fix units for gdbus-tool wait timeout
They were documented as being in seconds, but implemented as
milliseconds.

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

Fixes: #1737
2019-03-27 17:04:58 +00:00
Philip Withnall
ad614fc070 Merge branch 'cygwin-rtld_next' into 'master'
Check for RTLD_NEXT

See merge request GNOME/glib!750
2019-03-27 16:25:48 +00:00
Руслан Ижбулатов
a53ff7460e Check for RTLD_NEXT
Check for RTLD_NEXT being present, and disable the gsocketclient-slow
test if it's absent, since the shlib dependency of that test requires
RTLD_NEXT to function.

This allows the testsuite to be built on Cygwin, which behaves
exactly like UNIX, but doesn't have RTLD_NEXT.
2019-03-27 16:10:17 +00:00
Philip Withnall
ad19bb8f12 Merge branch '1258-input-stream-annotations' into 'master'
ginputstream: Add missing (out) annotations to read() functions

Closes #1258

See merge request GNOME/glib!738
2019-03-26 22:53:27 +00:00
Jan Tojnar
c940816181
gio: Add missing autocleanup definition for GSettingsSchemaKey 2019-03-26 16:40:28 +01:00
Jan Tojnar
edaae619e5
gio: Add missing autocleanup definition for GSettingsSchemaSource 2019-03-26 16:38:06 +01:00
Ignacio Casal Quinteiro
1e1759d5a2 gcocoanotificationbackend: give more priority than the gtk one
On OSX both backends are built. Generally we want to use the cocoa
backend by default and in case it is not supported, i.e because
the application is not using a bundle then we should fallback
to the gtk one.
2019-03-26 10:20:25 +01:00
Stefan Sperling
052ad6098d Fix use-after-free triggered by gnome-session-binary
ostream_flush_cb() was calling flush_data_list_complete() with a single
element list with an item that had already been freed. This was observed
on OpenBSD where memory is overwritten with 0xdf during free():

    error=0x0) at ../glib-2.58.3/gio/gdbusprivate.c:1156
1156          g_mutex_lock (&f->mutex);
(gdb) p /x *f
$74 = {mutex = {p = 0xdfdfdfdfdfdfdfdf, i = {0xdfdfdfdf, 0xdfdfdfdf}},
  cond = { p = 0xdfdfdfdfdfdfdfdf, i = {0xdfdfdfdf, 0xdfdfdfdf}},
  number_to_wait_for = 0xdfdfdfdfdfdfdfdf, error = 0x0}

This happened because the thread freeing the element didn't properly wait
for the asynchronous flush operation to finish.
Gnome's developer docs say: "g_cond_wait() must always be used in a loop"
https://developer.gnome.org/glib/stable/glib-Threads.html#g-cond-wait
2019-03-25 07:44:13 +01:00
Philip Withnall
89416debb0 gresolver: Convert encoding of gai_strerror() return value
It returns a string in the libc locale, which is not necessarily UTF-8.
Convert that to UTF-8 before returning it to the caller.

Spotted by Tomasz Miąsko.

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

Fixes: #1732
2019-03-22 13:32:14 +00:00
Philip Withnall
3a32c75876 ginputstream: Add missing (out) annotations to read() functions
This is a reversion of the reversion of commit
c192595268, after more discussion on the
issue.

Fixes: #1258
2019-03-22 13:20:41 +00:00
Ondrej Holy
bc52235efc gunixmounts: Return the last matching mount for same mount path
More mounts can have same mount path, but only the last one is
accessible. Thus we should always return the last matching mount from
g_unix_mount_at() and g_unix_mount_for(). This should also solve
problems with g_file_trash() on automounted filesystems, which are
caused by the recently added mount checks.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1727
2019-03-22 12:41:47 +01:00
Philip Withnall
3a11213b68 gresolver: Don’t use gai_strerror() on Windows, as it isn’t threadsafe
Instead, use WSAGetLastError().

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

Helps: #1732
2019-03-21 11:51:37 +00:00
Philip Withnall
114921ccd9 Merge branch 'dbus-address-tests' into 'master'
Improve gdbus-address parsing tests

See merge request GNOME/glib!730
2019-03-19 10:53:44 +00:00
Руслан Ижбулатов
5df0337f52 GIO: Convert ENOTSOCK to G_IO_ERROR_INVALID_ARGUMENT
instead of using a generic G_IO_ERROR_FAILED error code.
This is in line with what W32 part of the code is doing with WSAENOTSOCK.

This fix will break two tests in libsoup, which were written following
the implementation and thus expect G_IO_ERROR_FAILED when attempting to
do stuff with no-longer-valid socket descriptors.
2019-03-16 15:58:16 +00:00
Emmanuele Bassi
e5ba5845a1 Revert "headers: Add various missing G_DISABLE_DEPRECATED guards"
This reverts commit 80fcb1bc26.

G_DISABLE_DEPRECATED should never be used by anybody, least of all by
GLib. We have deprecation annotations for the compiler, these days, and
they are much better suited than a macro that makes symbols appear and
disappear. The fact that gtk-doc doesn't understand the deprecation
annotations is a limitation of gtk-doc, and it's gtk-doc that ought to be
fixed.

Commit 80fcb1bc broke GStreamer, which disables old API that was
deprecated before the introduction of the deprecation annotations, but
still uses newly deprecated one, and relies on the deprecation
annotations to do their thing. It also broke libsoup, as it uses
GValueArray in its own API.
2019-03-16 11:30:13 +00:00
Philip Withnall
631beb0404 tests: Improve test coverage of D-Bus tcp transport addresses
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:57 +00:00
Philip Withnall
f9fb7e8765 tests: Add test for unsupported unparseable D-Bus addresses
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:57 +00:00
Philip Withnall
3cd30c59e9 tests: Compile the test_unix_address() test unconditionally
Just skip the test if the unix transport isn’t supported. This means we
get better compilation coverage, and more explicit TAP output saying
that the test is being skipped on unsupported platforms.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:57 +00:00
Philip Withnall
264617cfb5 tests: Improve test coverage of D-Bus nonce-tcp transport addresses
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:57 +00:00
Philip Withnall
88d03facb9 tests: Improve test coverage of D-Bus unix transport addresses
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:56 +00:00
Philip Withnall
e0561cfdc5 tests: Split out D-Bus address parsing tests
Rather than having them in the unix-transport specific tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:36:56 +00:00
Philip Withnall
685d605832 tests: Always check an address is valid before checking it’s supported
This gets us extra test coverage for free.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:22:15 +00:00
Philip Withnall
e458b0168e gdbusaddress: Clean up memory management in _g_dbus_address_parse_entry()
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:20:54 +00:00
Philip Withnall
131ba66160 gdbusaddress: Require that transport names and keys are non-empty
The specification doesn’t explicitly say this, but it doesn’t say
otherwise, and it would be pretty weird to have an empty transport name
or key.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:20:16 +00:00
Philip Withnall
8966b0f8b1 gdbusaddress: Remove some always-true branches
g_strsplit() can never return NULL.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:19:55 +00:00
Philip Withnall
7f9e76d2bc gdbusaddress: Simplify address validation in is_valid_unix()
No need for the `meaningless` label and some unreachable if-branches.
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 14:18:55 +00:00
Philip Withnall
132c6ba0cf tests: Use g_assert_*() instead of g_assert() in gdbus-addresses test
g_assert_*() give better failure messages, and don’t get compiled out
with G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 13:46:29 +00:00
Tomasz Miąsko
2f290b3a5f tests: Check that cancelling g_file_replace don't overwrite existing file 2019-03-15 14:03:50 +01:00
Sebastian Dröge
c29bc822c2 Merge branch 'socket-client-connect-gerror-leak' into 'master'
GSocketClient - Free last error if a connection attempt fails and on retry the...

See merge request GNOME/glib!718
2019-03-15 11:46:57 +00:00
Philip Withnall
dd77a87cf8 docs: Fix various typos in linked symbol names
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
d6aa393578 gpollableoutputstream: Add vfunc documentation for writev_nonblocking
This was missing from the original merge request.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
6837c34c84 docs: Fix pluralised links to symbols
While gtk-doc can currently detect a link to a symbol which has been
pluralised by adding ‘s’, it can’t detect when ‘es’ is added. While
that’s being fixed, reword the documentation so the links are generated
correctly anyway.

gtk-doc fix here: https://gitlab.gnome.org/GNOME/gtk-doc/merge_requests/22

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
1f3375235b docs: Stop formatting integer literals using ‘%’
It makes gtk-doc try to link them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
1a8f8be6d0 gfile: Fix documentation links to non-existent symbols
I presume this documentation was written before those APIs were renamed
during code review.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
a385135d8b gfile: Add some missing parameter documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
d55ed6755e gdesktopappinfo: Fix an overly-specific ‘Since’ documentation line
This was causing gtk-doc to try and link to an API deprecation index
which doesn’t exist.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
80fcb1bc26 headers: Add various missing G_DISABLE_DEPRECATED guards
As pointed out by gtk-doc, these are all symbols which have been marked
as deprecated, but which aren’t protected by a deprecation guard. We
can’t use G_DEPRECATED_IN_* for them, as they are all non-function
symbols. Instead, wrap them in #ifndef G_DISABLE_DEPRECATED.

In some cases, we also need to wrap one or two functions which use the
deprecated types in G_DISABLE_DEPRECATED too.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Sebastian Dröge
f5a468a83a Merge branch 'socket-flags' into 'master'
gsocket: Remove (type) annotation from flags arguments

Closes gjs#227

See merge request GNOME/glib!728
2019-03-15 10:50:44 +00:00
Philip Withnall
49b807c022 gsocket: Remove (type) annotation from flags arguments
This is essentially a revert of commit
cc7f2f6b28. While those `flags` arguments
do accept values of type GSocketMsgFlags, they also accept OS-specific
flags which are not defined in GSocketMsgFlags.

The use of (type GSocketMsgFlags) makes language bindings like GJS
rightfully assert that values passed in to the argument only contain
flags from GSocketMsgFlags, which precludes the use of OS-specific
flags, and hence breaks various bits of code.

See https://gitlab.gnome.org/GNOME/gjs/issues/227#note_460136 and
https://gitlab.gnome.org/GNOME/glib/merge_requests/710#note_460249.

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

Fixes: https://gitlab.gnome.org/GNOME/gjs/issues/227
2019-03-15 10:28:14 +00:00
Philip Withnall
cf34d59bed Merge branch 'gdbus-win32-no-shortname' into 'master'
gdbusaddress, win32: don't rely on short names

Closes #1566

See merge request GNOME/glib!631
2019-03-15 10:21:08 +00:00
Philip Withnall
00c129f8eb Merge branch 'fix-network-available-check' into 'master'
Handle an UNKNOWN NetworkManager connectivity as NONE

See merge request GNOME/glib!719
2019-03-15 10:03:54 +00:00
Tom Schoonjans
32d012f5a9 build: install gosxappinfo.h on macOS
Closes #1725
2019-03-14 08:09:09 +00:00
Simon McVittie
b94a0fc2b4 appinfo: Fix documentation cross-reference
g_app_info_launch_default_for_uri() should link to _async() as an alternative, not to itself.
2019-03-13 14:52:10 +00:00
Philip Withnall
5649255351 codegen: Fix use of uninitialised variable
If using the --interface-info-{body,header} options to gdbus-codegen,
and the first interface to be outputted has no methods, but does have
properties or signals, an uninitialised variable would be used for the
property/signal ‘since’ values.

In other situations, the ‘since’ value for a prior method would have
been incorrectly used for the properties/signals.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-13 13:13:24 +00:00
Philip Withnall
df62731771 Merge branch 'win32-symlink-refactoring' into 'master'
Win32 symlink code refactoring

See merge request GNOME/glib!269
2019-03-13 11:55:27 +00:00
Vasily Galkin
b245344cec gdbus, tests, win32: test session dbus autolaunch
The test performs implicit autolaunching of a bus
and checks if it is connectible.

In build the test is moved from "only non-windows with have_dbus_daemon"
to "anywhere".

This is intentional: actually it doesn't execute any external
binaries on unix (so doesn't require dbus_daemon)
and now has win32 implementation.

The test has some problems that are not problems of test itself,
but are reasoned by current win32 implementation:

 - since the implementation uses global win32 kernel objects
with fixed names not depending on g_get_user_runtime_dir or other context
if preexisting bus running by some other libgio-using application
the test would silently pass.

 - since the implementation uses problematic time-based synchronization,
that has a race condition between opening and reading mmaped address,
the test may randomly fail (I'd not seen this in practice).

 - since the implementation autolaunched process works for 3 seconds
after last client disconnects, the executed subprocess runs for 3 seconds
after test exit, maybe locking the libgio-2.0-0.dll file for that time.
2019-03-12 21:54:47 +03:00
Vasily Galkin
b1f7c22a24 gdbus, tests: rename gdbus-unix-addresses test to gdbus-address-get-session
In preparation of adding non-unix testcase to the test.
2019-03-12 21:53:43 +03:00
Vasily Galkin
8c7670f0e1 gdbus, win32: autolaunch bus with gdbus.exe instead of rundll32
This is a bit of breaking change:
After this commit the apps relying of win32 dbus autolaunching,
need to install gdbus.exe alongside with libgio-2.0-0.dll.

A new command for gdbus tool is used for running server:
gdbus.exe _win32_run_session_bus

To implement it gdbus.exe uses the same exported function
g_win32_run_session_bus that earlier was used by rundll.
So (private) ABI was not changed.

It runs the bus syncronously, exiting after inactivity timeout -
all exactly like it was runed earlier with the help of rundll32.

While private exported function may have _some_
version compatibility issues between gdbus.exe and libgio-2.0-0.dll
compiling dbus server registration logic directly into gdbus.exe
can lead to _more hidden and more complex_ compatibility issues
since the names and behaviour of syncronization objects
used to publish server address would be required compatible between
gdbus.exe and libgio-2.0-0.dll.

So using "private" exported function to call
looks like more safe behaviour.

gdbus.exe binary was selected for this task since
it has corresponding name and at least for msys2 is shippied
in same package with libgio-2.0-0.dll

turn_off_the_starting_cursor function is also kept as is,
however it is not obvious if it is still needed
(by now I failed reproducing original issue).

Explicit g_warnings added to help with possible
problematic cases for absent or incompatible gdbus.exe

Mainloop is created after successful daemon creation
Before this change the function leaked mainloop on daemon creation fail
2019-03-12 21:53:29 +03:00
2932a58cd5 Handle an UNKNOWN NetworkManager connectivity as NONE
nm_conn_to_g_conn already handles UNKNOWN like NONE (returning
G_NETWORK_CONNECTIVITY_LOCAL in both cases). So in sync_properties
we should also set new_connectivity to G_NETWORK_CONNECTIVITY_LOCAL
for both NM_CONNECTIVITY_UNKNOWN and NM_CONNECTIVITY_NONE.

This has the added benefit that when NetworkManager returns the network
connectivity is UNKNOWN, we set network_available to FALSE as it should
be. Previously, there were cases in a laptop with no network access,
that g_network_monitor_get_network_available returned true, which was
wrong and is also fixed with this commit.
2019-03-12 18:39:42 +01:00
Sebastian Dröge
499c201472 GSocketClient - Free last error if a connection attempt fails and on retry the cancellable is cancelled 2019-03-12 10:32:56 +01:00
Philip Withnall
1b50643c99 gio: Fix various compiler warnings when compiling with G_DISABLE_ASSERT
Mostly unused variables which are only used in a g_assert() call
otherwise.

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

Helps: #1708
2019-03-08 19:46:21 +00:00
Philip Withnall
277c42ddc0 tests: Convert g_assert() to g_assert_*() in gio/tests/gsubprocess.c
g_assert_*() give more informative failure messages, and aren’t compiled
out when building with G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-08 19:46:20 +00:00
Philip Withnall
6a724d9ccd tests: Convert g_assert() to g_assert_*() in gio/tests/actions.c
g_assert_*() give more informative failure messages, and aren’t compiled
out when building with G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-08 19:46:20 +00:00
Philip Withnall
d89f18bb22 build: Add -UG_DISABLE_ASSERT when building tests
In order to allow GLib itself to be built with G_DISABLE_ASSERT defined,
we need to explicitly undefine it when building the tests, otherwise
g_test_init() turns into an abort.

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

Fixes: #1708
2019-03-08 19:46:20 +00:00
Philip Withnall
3d4a168715 tests: Fix some larger memory leaks in gdbus-proxy
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-07 13:57:38 +00:00
Philip Withnall
938f716c2f tests: Fix a minor memory leak in gdbus-proxy
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-07 13:04:12 +00:00
Philip Withnall
196e333ec2 tests: Use g_assert_*() instead of g_assert() in gdbus-proxy
g_assert_*() give more informative error messages on failure, and can’t
be disabled by G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-07 13:03:40 +00:00
Vasily Galkin
4342dbbe4d gdbus, win32: move most W32 dbus autolaunch code to gdbusprivate
This allows referencig them from more than single .c file.

Implementation moved without changes
from gdbusaddress.c to gdbusprivate.c

g_win32_run_session_bus signature also kept, so ABI unchanged.
2019-03-07 15:56:44 +03:00
Vasily Galkin
4ed5abda43 gdbusaddress, win32: don't rely on short names
Closes: https://gitlab.gnome.org/GNOME/glib/issues/1566

Short names were used in win32 implementation to allow launching
on installations where full path to libgio-2.0-0.dll contain spaces.
However, short names are optional on windows: so if they were disabled
that method fails - see issue linked above.

Since rundll32 doesn't support neither spaces, nor quotes in cmdline
this patch changes rundll32 argument to just .\gio-dll-name.dll
and uses the entire path directory containing gio dll as rundll32
current directory.

Added comments informing about potential subtleties discovered during
writing test for gdbusaddress on win32.
There are not known to have real-world user-visible effect,
so by now I'm only adding comments without creating issues.
2019-03-07 15:56:44 +03:00
Sebastian Dröge
c9c88a4b22 Merge branch 'fix-gjs-issue-227' into 'master'
socket: Fix annotation for flags in g_socket_receive_message

Closes gjs#227

See merge request GNOME/glib!710
2019-03-06 20:34:15 +00:00
Andrea Azzarone
d1cb974932 socket: Fix annotation for flags in g_socket_receive_message
Closes: https://gitlab.gnome.org/GNOME/gjs/issues/227
2019-03-06 18:16:52 +00:00
Philip Withnall
62bd79b6a2 Merge branch 'tdr' into 'master'
Fix data races in task test and gmenumodel test

See merge request GNOME/glib!706
2019-03-06 13:53:24 +00:00
Tomasz Miąsko
330f8999a8 tests: Fix data race in task test
Ensure that all tasks have already completed before accessing buf array
from main thread to avoid conflicting data access from multiple threads.
2019-03-06 14:21:13 +01:00
Christoph Reiter
e13c646465 gcancellable: add back lost NULL check in g_cancellable_cancel()
Commit f975858e86 removed the NULL check in g_cancellable_cancel() by
accident which makes it crash when called with NULL.

Add the check back and add a test so this doesn't happen again.

Fixes #1710
2019-03-05 16:44:16 +01:00
Tomasz Miąsko
0679bd2732 tests: Fix data race in gmenumodel test
Synchronize access to server_connection.
2019-03-05 15:14:58 +01:00
Philip Withnall
aeb7dbad30 Merge branch 'tsan' into 'master'
Fix thread safety issues

See merge request GNOME/glib!690
2019-03-05 11:46:33 +00:00
Matthias Clasen
147ac51f90 trash portal: Fix permission checks
Implement the approach suggested in
https://gitlab.gnome.org/GNOME/glib/merge_requests/276

1. Try to open O_RDWR. On success, pass that fd
2. If EACCESS => fail the trash op, we "need" read-write to successfully trash it
3. If EISDIR => re-open the fd with O_PATH, and pass that (which will fail on snap,
   but verify the dir for flatpaks)
2019-03-04 19:47:11 +00:00
Christoph Reiter
7fa9a2a5da Merge branch 'gi-267-rename-header' into 'master'
Rename gobjectenumtypes.[ch] to glib-enumtypes.[ch]

See merge request GNOME/glib!702
2019-03-04 15:03:40 +00:00
Philip Withnall
54317c9118 tests: Run /gsettings/keyfile test in a temporary directory
Don’t pollute the build directory with files generated by running the
test.

Note that there are still other tests in the gsettings.c test suite
which use the build directory, but fixing them is a bit more involved
than I have time for right now. This is a step in the right direction.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-04 12:28:37 +00:00
Matthias Clasen
5e4da714f0 keyfile settings: Use tighter permissions
When creating directories, create them with 700 permissions,
instead of 777.

Closes: #1658
2019-03-04 12:28:37 +00:00
Philip Withnall
c3ac761a18 build: Rename gobjectenumtypes.[ch] to glib-enumtypes.[ch]
To reflect the fact that they contain the GObject types for various
enums defined in libglib.

See https://gitlab.gnome.org/GNOME/glib/merge_requests/481#note_451086.

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

Helps: GNOME/gobject-introspection#267
2019-03-04 11:12:59 +00:00
Patrick Griffis
5967b4501c gthreadedresolver: Remove unused thread pool 2019-02-27 10:41:32 -05:00
Philip Withnall
0d63ee0908 Merge branch 'wip/tingping/socket-client-slow-fix' into 'master'
gsocketclient: Fix critical on cancellation

Closes #1693 and #1653

See merge request GNOME/glib!688
2019-02-27 14:35:53 +00:00
Patrick Griffis
f0fcb68da5 tests: Unmark gsocketclient-slow as flaky
Closes #1653
2019-02-27 09:20:28 -05:00
Patrick Griffis
80af199d7d gsocketclient: Fix critical on cancellation
We need to be more explicit in handling cancellation to avoid
multiple task returns.

Fixes #1693
2019-02-27 09:20:28 -05:00
Tomasz Miąsko
c52021f340 tests: Don't leak check-proxies thread 2019-02-25 14:29:35 +01:00
Philip Withnall
dc6b5f88c4 Merge branch 'update-gvdb' into 'master'
Update gvdb submodule

See merge request GNOME/glib!674
2019-02-25 13:04:08 +00:00
Philip Withnall
2b1bcbc99b Merge remote-tracking branch 'gvdb/master' into update-gvdb 2019-02-25 12:40:10 +00:00
Emmanuele Bassi
78a2dd9632 Merge branch 'threaded-resolver-freebsd' into 'master'
gthreadedresolver: Fix initialisation on FreeBSD

Closes #1697

See merge request GNOME/glib!693
2019-02-25 11:47:56 +00:00
Philip Withnall
6e7e5fff9a gthreadedresolver: Fix initialisation on FreeBSD
res_ninit() requires the __res_state struct passed to it to be
zero-filled on FreeBSD.

Spotted and analysed by Ashish SHUKLA.

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

Fixes #1697
2019-02-25 11:22:45 +00:00
Tomasz Miąsko
f975858e86 gcancellable: Synchronize access to cancelled flag
Synchronize access to cancelled flag of cancellable, which was
previously access without synchronization in g_cancellable_is_cancelled.
Use atomic operations instead of existing global mutex, to avoid
serializing calls to g_cancellable_is_cancelled across all threads.
2019-02-25 00:00:00 +00:00
Tomasz Miąsko
fef1ce37e4 gtask: Separate GTask fields memory locations to avoid data races
Ensure that fields that might be accessed in two different threads,
through conflicting actions are stored in seprate memory locations.
2019-02-22 22:22:07 +01:00
Tomasz Miąsko
6336864171 glocalfilemonitor: Fix data race in local file monitor
Ensure that source is attached to the context before it migth be used
from another thread, since otherwise operation on source are
unsynchronized and not thread-safe.

In particular there was a data race between g_source_attach and
g_source_set_ready_time (used from g_file_monitor_source_handle_event).
2019-02-22 18:09:32 +01:00
Philip Withnall
7321f240f9 glib-compile-resources: Fix a minor leak
Spotted by oss-fuzz using asan.

oss-fuzz#13271

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-22 14:48:25 +00:00
Philip Withnall
07414e17ef tests: Unmark socket-service test as flaky
This essentially reverts commit
cffed58737.

The preceding two commits have fixed the test so it’s no longer flaky.
The following command gives 5000 passes in a row for me:

meson test -C /opt/gnome/build/glib/ socket-service --repeat 5000

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

Fixes: #1679
2019-02-21 18:15:49 +00:00
Philip Withnall
f25c3f2704 tests: Fix unlikely race in socket-service test
It’s occasionally possible for the cancellation of the service to happen
before connection_cb() gets scheduled in the other thread. The
locking/unlocking order of mutex_712570 requires:
 • test_threaded_712570(): lock mutex
 • test_threaded_712570(): start wait loop
 • connection_cb(): lock mutex
 • test_threaded_socket_service_finalize(): unlock mutex
 • test_threaded_712570(): end wait loop
 • test_threaded_712570(): unlock mutex

Fix that by quitting the main loop once connection_cb() has been called
(i.e. once the server thread has received the incoming connection
request), rather than just after the client thread (main thread) has
sent a connection request.

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

Helps: #1679
2019-02-21 18:15:49 +00:00
Philip Withnall
2aea9c84c0 tests: Fix flaky socket-service test caused by GTask scheduling
On about 1 in 3 test runs, the socket-service would fail with the
ref_count assertion in connection_cb() failing (the ref_count would be 3
rather than the expected 2).

This was happening because the GTask from
g_socket_listener_accept_socket_async() now always takes at least one
main context iteration to return a result (whereas before
6f3d57d2ee it might have taken zero), but
the ref_count can drop below 3 before the process of returning a result
starts. During the process of returning a result, the ref_count
temporarily increases again, which is what was breaking the test.

Fix this by waiting for one more main context iteration. This is a bit
of a hack, but the real fix would be to expose the outstanding_accept
boolean from GSocketService as public API (which the test can
interrogate), and that seems too much like exposing internal state.

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

Helps: #1679
2019-02-21 18:14:56 +00:00
Nirbheek Chauhan
2d6c4b289a meson: Add gobjectenumtypes.h to gioenumtypes_dep
Almost everything that needs gioenumtypes.h also needs
gobjectenumtypes.h. Fixes:

ccache cc @gio/win32/gio@win32@@giowin32@sta/gwin32filemonitor.c.obj.rsp
In file included from ../gio/win32/gwin32filemonitor.h:25:0,
                 from ../gio/win32/gwin32filemonitor.c:26:
../glib/glib-object.h:37:10: fatal error: gobject/gobjectenumtypes.h: No such file or directory
 #include <gobject/gobjectenumtypes.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-02-20 22:37:56 +05:30
Nirbheek Chauhan
8e3fc7dfaa gio: Also support modules built with MSVC
GIO modules built with MSVC do not begin with 'lib', but they can
begin with 'gio'. Without this, you can only load GIO modules built
with MSVC that are `name.dll`, not `gioname.dll`.
2019-02-20 21:26:36 +05:30
Felix Potthast
45655b8265 glib-compile-resources: Fixes #1675 2019-02-20 10:38:29 +00:00
Philip Withnall
111f2b79e7 glib-compile-schemas: Fix capitalisation of a command line option help
The other descriptions of command line options start with a capital.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-18 17:21:13 +00:00
Philip Withnall
fd3219aaa1 glib-compile-schemas: Improve translatable strings
Eliminate several cases of splitting sentences between multiple
translatable strings, and remove some newlines from the translatable
strings (they always need to be present, and can confuse translation, so
add them unconditionally afterwards).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-18 17:15:15 +00:00
Philip Withnall
b72b4e2d24 Merge branch 'w32-testsuite-fixes-socket' into 'master'
Socket fixes to W32 test suite

See merge request GNOME/glib!666
2019-02-18 12:54:45 +00:00
Emmanuele Bassi
f011be9c4b Initialize a variable
Compilers get confused when variables are initialized by a function by
taking them as reference in an out argument; this, coupled with the fact
that C does not initialize variables by default, most commonly results
in a "maybe uninitialized" compiler warning.
2019-02-18 09:50:26 +00:00
Michael Catanzaro
eac2b1a1c3 Merge branch 'wip/tingping/socket-cancellation' into 'master'
gsocketclient: Ensure task is always returned on cancel

Closes libsoup#132

See merge request GNOME/glib!647
2019-02-14 18:26:17 +00:00
Christoph Reiter
37f9b613d9 Merge branch 'gdbus-fix-use-after-free' into 'master'
gdbus: Fix a potential use-after-free on connection close. Fixes #1686

Closes #1686

See merge request GNOME/glib!671
2019-02-14 13:36:15 +00:00
Philip Withnall
cca7ab2176 Merge remote-tracking branch 'gvdb/master' into update-gvdb 2019-02-14 13:23:28 +00:00
Christoph Reiter
11309b7940 Revert "tests: Mark gdbus-peer test as flaky". See #1686
This reverts commit 983a40bf34.
2019-02-14 14:20:32 +01:00
Christoph Reiter
067992f8de gdbus: Fix a potential use-after-free on connection close. Fixes #1686
512e9b3b34 added a call to schedule_pending_close() in the read
callback after the reference to the worker is already gone. In case this was
the last reference to the worker this resulted in a use-after-free.

6f3d57d2ee made this more likely to happen because on connection close
the worker cancel action is now async while the reference to the worker
gets dropped right away.

Move the call to schedule_pending_close() before the unref.

Fixes #1686
2019-02-14 14:19:55 +01:00
Dan Nicholson
786753ac21 tests: keyfile writability not affected by file mode for root
When testing as root, changing the permissions of the keyfile will have
no effect on the writability since root bypasses these permissions. See
path_resolution(7). Skip the test in this case.
2019-02-14 11:35:26 +00:00
Philip Withnall
888aa4c5ff tests: Use g_assert_*() rather than g_assert() in GSettings tests
g_assert_*() give more informative error messages, and aren’t compiled
out when building with G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-14 11:35:26 +00:00
Руслан Ижбулатов
c00724d5c9 socket test: Use loopback for connecting, not 0.0.0.0
getsockname() returns the address that the socket was bound to.
If it was bound to INADDR_ANY, getsockname() will stubbornly return INADDR_ANY
(and someport - that one is valid).
Subsequent connection attempts to INADDR_ANY:someport will fail with winsock.
Actually, it doesn't make even sense to connect to INADDR_ANY at all
(where is the socket connecting to? To a random interface of the host?),
so this is just a straight-up change, without platform-specific ifdefing.

Use loopback instead of INADDR_ANY. To ensure that binding and creation
of INADDR_ANY is still tested, use two addresses: bind to INADDR_ANY,
but connect to loopback, with the port number that we got from the bound
address.
2019-02-13 18:22:10 +00:00
Philip Withnall
fbb97b46d8 Merge branch 'gdbus-peer-flaky' into 'master'
tests: Mark gdbus-peer test as flaky

See merge request GNOME/glib!668
2019-02-13 16:53:32 +00:00
Philip Withnall
843a0422ab Merge branch 'w32-mount-sort' into 'master'
GWin32VolumeMonitor: Sort the volumes correctly

See merge request GNOME/glib!669
2019-02-13 16:41:14 +00:00
Jordan Petridis
3e77699c28
gpollableoutputstream: Fix the description of the interface
Looks like this was a copy-paste typo from the Input interface.
2019-02-13 17:52:21 +02:00
Руслан Ижбулатов
0c16230b28 GWin32VolumeMonitor: Sort the volumes correctly
Use a static GQueue to form the GList of mounts by appending (which
is fast, because GQueue tracks the tail pointer of its internal GList),
then return that GList. This way we don't need to form the list
by prepending, which would have made it necessary to reverse it before
returning.

If the list is not ordered correctly, local drives in GTK places sidebar
are shown in reverse order.
2019-02-13 15:27:29 +00:00
Philip Withnall
983a40bf34 tests: Mark gdbus-peer test as flaky
It is occasionally deadlocking. See #1686.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-13 12:04:26 +00:00
Philip Withnall
c5c9b29b9d Merge branch 'w32-testsuite-fixes-general' into 'master'
General fixes to W32 test suite

Closes #875

See merge request GNOME/glib!665
2019-02-13 10:40:11 +00:00
Philip Withnall
0f26836d73 Merge branch 'w32-testsuite-fixes-gsubprocess' into 'master'
GSubprocess fixes for W32 test suite

See merge request GNOME/glib!667
2019-02-13 10:37:22 +00:00
Iain Lane
95899c11d9 Merge branch 'socketclient-slow-install-preload-library' into 'master'
tests: Install the slow-connect-preload.so library and use it

See merge request GNOME/glib!651
2019-02-13 10:00:13 +00:00
Iain Lane
1ecaae6454
installed-tests: Install the slow-connect-preload.so library and use it
The gsocketclient-slow test needs this, otherwise connect() succeeds
immeidately and the test fails, because it is checking that cancellation
works. We weren't installing it for installed tests.
2019-02-13 09:45:08 +00:00
Iain Lane
07a1a8031d
installed tests: Allow tests to set environment variables
It's necessary sometimes for installed tests to be able to run with a
custom environment. For example, the gsocketclient-slow test requires an
LD_PRELOADed library to provide a slow connect() (this is to be added in
a followup commit).

Introduce a variable `@env@` into the installed test template, which we
can override as necessary when generating `.test` files, to run tests
prefixed with `/usr/bin/env <LIST OF VARIABLES>`.

As the only test that requires this currently lives in `gio/tests/`, we
are only hooking this up for that directory right now. If other tests in
future require this treatment, then the support can be extended at that
point.
2019-02-13 09:43:49 +00:00
Руслан Ижбулатов
1cc78bf082 GSubprocess test: Adjust the cwd test to pass on Windows
There's no /tmp directory on Windows.
Use g_get_tmp_dir(), and adjust the test to work with that.
The test *still* checks the basename of the new CWD, it just
doesn't need to be "tmp" anymore.
2019-02-13 08:52:59 +00:00
Руслан Ижбулатов
4bc1aa23a9 GSubprocess test: Add PATH to the envtable that is passed to child
envp in spawn() functions is the *whole* environment table
for the child process. Including PATH. Thus, unless PATH is explicitly
put into that table, the process will be spawned without PATH.
Since on Windows binaries are found via PATH instead of LD_LIBRARY_PATH
or whatever, almost no program (unless installed in WINDIR, maybe)
can run without a PATH. Certainly not test programs - meson
adds bld subdirs to the PATH to make sure that test programs
use uninstalled glib at runtime.
So make sure that PATH is passed along.
2019-02-13 08:52:58 +00:00
Руслан Ижбулатов
01642d6db5 GSubprocess test: Use LINEEND more
Windows \r\n EOLs strike again. The test already knows about LINEEND,
so make it use LINEEND more (instead of swithcing pipes
to binary mode). This also applies to counting the bytes
read.
2019-02-13 08:52:58 +00:00
Руслан Ижбулатов
f150de2139 socket test: Bind Windows UDP sockets before calling recv()
Winsock can't recv() on unbound UDP sockets. Bind the socket
to loopback before trying to receive data on it.
2019-02-13 08:51:31 +00:00
Руслан Ижбулатов
1f5d7eeaa7 socket test: Adjust for Windows-specific sendto() error
With winsock sending messages to NULL results in G_IO_ERROR_NOT_CONNECTED
instead of G_IO_ERROR_FAILED.
MSDN says:
  WSAENOTCONN
  10057
  Socket is not connected.
  A request to send or receive data was disallowed because the socket is not connected
  and (when sending on a datagram socket using sendto) no address was supplied.
So this is a direct mapping of the implementation error.
Covering it up in the wrapper (by converting it to G_IO_ERROR_FAILED)
doesn't seem feasible or needed (no one, except for the testsuite,
really cares which unrecoverable error is returned by sendto()).
2019-02-13 08:51:31 +00:00
Руслан Ижбулатов
00908bc446 network-address test: Disable scope ID tests on Windows
getaddrinfo() in winsock can't understand scope IDs.
There's no obvious way to fix that, short of re-implementing
that function, so disable that part of the test on Windows.
2019-02-13 08:49:42 +00:00
Руслан Ижбулатов
14aae264d4 autoptr test: Use OS-dependent path separator
Since GFile canonicalizes the path it is given, expect the '\\' separator
on Windows.
2019-02-13 08:49:42 +00:00
Руслан Ижбулатов
294d818336 Use OS-dependent separator for G_RESOURCE_OVERLAYS
G_RESOURCE_OVERLAYS is a list of resource-path and filesystem-path pairs.
Since on Windows filesystem paths use ':', this list can't be ':'-separated
there. Fix that by making it ';'-separated on Windows. Make the parser
error clearer (we're not looking for a slash, we're looking for an absolute
path).
2019-02-13 08:49:42 +00:00
Руслан Ижбулатов
ccbadcfb04 GWinHTTPVfs: use URI parser for parsing URIs
If a URI can't be handled by by WinHTTPVfs, it should pass that URI
along to the URI parser of the wrapped Vfs, not to its generic parser.
Theoretically, generic parser should also be able to handle URIs,
but this is subject to Vfs semantics.

In case of Windows, the wrapped Vfs is GLocalVfs, which is *local* and
treats any generic names as either file:// URIs or as filesystem
paths. It only ever treats URIs as URIs when they are passed
to its URI parser. This breaks the testsuite when g-icon GIO test passes
unhandleable sftp:// URI, and expects it to come through unmolested,
yet GLocalVfs, getting that URI as a generic parse name, treats it as
a filesystem path, and then "canonicalizes" it by prepending CWD.

Fix this by making WinHTTPVfs pass any URIs it gets to the URI parser
of the wrapped Vfs. This way unknown URIs remain URI-ish. This seems
like a reasonable things to do, since the URI parser should not be
given anything other than URIs, so there's no reason to try generic
parsing with these strings.

Closes: #875
2019-02-13 08:49:42 +00:00
Michael Catanzaro
df5592f28d Merge branch 'wip/tingping/network-address-fixes' into 'master'
gnetworkaddress: Never end enumeration before resolving completes

Closes #1680

See merge request GNOME/glib!646
2019-02-11 14:22:05 +00:00
Patrick Griffis
085081ea2c gnetworkaddress: Never end enumeration before resolving completes
Previously once the end of addresses was reached it would return
NULL even if it was waiting on a dns response. Now it will keep
waiting so all addresses are received.

Fixes #1680
2019-02-11 08:59:33 -05:00
Patrick Griffis
c83291049e gnetworkaddress: Factor out initializing address list into function 2019-02-11 08:59:31 -05:00
Debarshi Ray
e13b3a9ee5 gio/tests/task: Add comments documenting how the test works
https://gitlab.gnome.org/GNOME/glib/issues/1608
2019-02-11 12:30:23 +01:00
Debarshi Ray
5d1aaf56bb gio/tests/task: Run the worker indefinitely until it's cancelled
Currently, the actual asynchronous work, represented by
asynchronous_cancellation_run_task, was over before the GCancellable
could be triggered. While that doesn't invalidate the purpose of the
test, since it's fundamentally about cancellation, it would be
nicer if the cancellation actually served some purpose instead of
being a mere formality.

https://gitlab.gnome.org/GNOME/glib/issues/1608
2019-02-11 12:12:47 +01:00
Iain Lane
cc12f3f253
gio tests: Install test1.overlay file when building installed tests
This is used as a GResource overlay, so it must be available to the
test.
2019-02-11 10:21:13 +00:00
Philip Withnall
30ccfac9cf gsocketlistener: Fix multiple returns of GTask when accepting sockets
When calling g_socket_listener_accept_socket_async() on a
GSocketListener with multiple sockets, the accept_ready() callback is
called for the first incoming connection on each socket. It will return
success/failure for the entire accept_socket_async() GTask, and then
free the GSources for listening for incoming connections on the other
sockets in the GSocketListener. The GSources are freed when the GTask is
finalised.

However, if incoming connections arrive for multiple sockets within the
same GMainContext iteration, accept_ready() will be called multiple
times, and will call g_task_return_*() multiple times, before the GTask
is finalised. Calling g_task_return_*() multiple times is not allowed.

Propagate the first success/failure, as before, but then ignore all
subsequent incoming connections until the GTask is finalised.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-11 00:25:48 +00:00
Patrick Griffis
4dd1582625 gsocketclient: Ensure task is always returned on cancel
It was possible for the individual connection attempts to be
cancelled without the main task getting returned.

Fixes libsoup#132
2019-02-09 10:30:24 -05:00
Ignazio Pillai
b465cb158b gtask: fix task_wait_time estimation
The wait time is estimated as function of the number of running threads

Fixes #1683
2019-02-08 10:53:26 +01:00
Patrick Griffis
ed57faeeda tests: Use fewer magic numbers in network-address tests 2019-02-07 11:56:22 -05:00
Patrick Griffis
5827cef22d tests: Unmark network-address test as flaky 2019-02-07 11:56:22 -05:00
Patrick Griffis
5b0fdfda6d gnetworkaddress: Fix incorrect error propagation when resolving addresses
Previously this would always error if ipv6 errored after ipv4
succeeded which was incorrect.

This explicitly tests the order of erroring.

Fixes #1644
2019-02-07 11:56:22 -05:00
Debarshi Ray
381af21072 gio/tests/task: Ensure that cancelled tasks are returned asynchronously
Closes https://gitlab.gnome.org/GNOME/glib/issues/1608
2019-02-06 13:30:01 +00:00
Debarshi Ray
6f3d57d2ee gtask: Return cancelled tasks asynchronously
Once cancelled, a GTask's callback should not only be invoked
asynchronously with respect to the creation of the task, but also with
respect to the GCancellable::cancelled handler. This is particularly
relevant in cases where the cancellation happened in the same thread
where the task is running.

Spotted by Dan Winship and Michael Catanzaro.

Closes https://gitlab.gnome.org/GNOME/glib/issues/1608
2019-02-06 13:30:01 +00:00
Philip Withnall
cffed58737 tests: Tag socket-service test as ‘flaky’
It needs investigating and fixing properly, but let’s not let it disrupt
the CI in the meantime.

Follow-up in https://gitlab.gnome.org/GNOME/glib/issues/1679.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-06 12:50:38 +00:00
Chun-wei Fan
bb73a22448 Win32: gio/gsocket.c: Set WSAEWOULDBLOCK on G_POLLABLE_RETURN_WOULD_BLOCK
To make things consistent across the board as that is the WinSock2 error
code that is received by g_socket_send_message_with_timeout() when it
returns G_POLLABLE_RETURN_WOULD_BLOCK.
2019-02-05 11:15:50 +08:00
Philip Withnall
1f7d5b85d7 Merge branch 'trash-portal' into 'master'
Support the trash portal

See merge request GNOME/glib!276
2019-02-04 13:38:03 +00:00
Matthias Clasen
bca4ff7c5e Support the trash portal
When we are in a sandbox, try to trash files via a portal.
It works.
2019-01-31 19:00:19 -05:00
Philip Withnall
6c14e9a14b tests: Fix a minor memory leak in the gsettings test
g_settings_backend_get_default() returns a strong reference.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-30 14:41:15 +00:00
Philip Withnall
caf5103d4b gsettingsbackend: Fix a minor memory leak
This never caused any problems because the default GSettingsBackend is
cached forever by GIOModule anyway.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-30 14:41:15 +00:00
Philip Withnall
f829b65e51 gsettings: Clarify ownership transfer in a few places
I was trying to debug some memory leaks in the gsettings test.
Eventually, it seems that actually they’re caused by the
GMemorySettingsBackend being cached by GIOModule — so this commit makes
no functional changes. It should make the code and documentation a bit
clearer though.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-30 14:41:15 +00:00
Philip Withnall
9d89ed0c54 gkeyfilesettingsbackend: Add a code comment to clarify things
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-30 14:41:15 +00:00
Michael Catanzaro
930883609c Merge branch 'wip/tingping/gsocketclient-criticals' into 'master'
gsocketclient: Fix criticals

Closes #1649 and #1646

See merge request GNOME/glib!627
2019-01-29 20:59:18 +00:00
Patrick Griffis
d553d92d6e gsocketclient: Fix criticals
This ensures the parent GTask is kept alive as long as an enumeration
is running and trying to connect.

Closes #1646
Closes #1649
2019-01-29 14:46:52 -05:00