Commit Graph

22240 Commits

Author SHA1 Message Date
António Fernandes
36e7b48ad5 Revert "gtimezone: Cache timezones based on the identifier they were created by"
This reverts commit 851241f19a.

That commit avoids a performance regression but introduces a behavior regression:
changes to /etc/localtime have no effect for the remaining of the application's
runtime.

With the optimization introduced by the previous commit, we can pass NULL to
g_time_zone_new() repeatedly with no performance drawback, so we no longer have
to workaround this case.

Fixes: #2224
2020-10-15 14:43:46 +01:00
António Fernandes
25e634b26b gtimezone: Cache default timezone indefinitely
We cache GTimeZone instances to avoid expensive construction when the
same id is requested again.

However, if the NULL id is passed to g_time_zone_new(), we always
construct a new instance for the default/fallback timezone.

With the recent introduction of some heavy calculations[1], repeated
instance construction in such cases has visible performance impact in
nautilus list view and other such GtkTreeView consumers.

To avoid this, cache reference to a constructed default timezone and
use it the next time g_time_zone_new() is called with NULL argument,
as long as the default identifier doesn't change. We already did the
same for the local timezone[2].

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2204

Based on idea proposed by Sebastian Keller <skeller@gnome.org>.

[1] 25d950b61f
[2] 551e83662d
2020-10-15 14:43:46 +01:00
António Fernandes
7e59a4c0d5 gtimezone: Set resolved_identifier earlier
We have been passing a &resolved_identifier address around for multiple
functions to set it. Each function may either:

    1.  leaving it for the next function to set, if returning early;
    2.  set it to a duplicate of the passed identifier, if not NULL;
    3.  get a fallback value and set it, otherwise.

This can be simplified by setting it early to either:

    1.  a duplicate of the passed identifier, if not NULL;
    2.  a fallback value, otherwise.

This way we can avoid some unnecessary string duplication and freeing.
Also, on Windows, we avoid calling windows_default_tzname() twice.

But the main motivation for this change is enabling the performance
optimization in the next commit.
2020-10-02 00:02:57 +01:00
António Fernandes
b4138bd4ac gtimezone: Split out fallback timezone identification for unix
When the TZ environment variable is not set, we get the local timezone
identifier by reading specific files.

We are going to need these identifiers earlier, so split this logic into
its own function, in preparation for the next commit.

Based on idea proposed by Sebastian Keller <skeller@gnome.org>.
2020-10-01 21:46:44 +01:00
Philip Withnall
53819d8a37 Merge branch 'list-free-docs' into 'master'
glist: Clarify that g_list_free() and friends only free an entire list

See merge request GNOME/glib!1657
2020-09-23 12:42:07 +00:00
Sebastian Dröge
45758e04b7 Merge branch '2204-timezone-caching' into 'master'
gtimezone: Cache timezones based on the identifier they were created by

Closes #2204

See merge request GNOME/glib!1660
2020-09-23 10:50:11 +00:00
Philip Withnall
cd1b09fe30 Merge branch 'gutils-limit-scope' into 'master'
utils: Limit the scope of the variable `max`

See merge request GNOME/glib!1658
2020-09-23 10:39:45 +00:00
Philip Withnall
851241f19a gtimezone: Cache timezones based on the identifier they were created by
Rather than invalidating the cache by comparing `TZ` to the cached
timezone identifier, key entirely off the value of `TZ` (and a cached
copy of it).

This fixes the timezone cache being constantly invalidated if `TZ` is
`NULL` (which will always differ from the identifier of the default
local timezone which is constructed from `g_time_zone_new (NULL)`.

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

Fixes: #2204
2020-09-23 11:28:32 +01:00
Philip Withnall
af0b0e98da Merge branch 'trash-portal-error' into 'master'
trash portal: Handle portal failures

See merge request GNOME/glib!1652
2020-09-23 09:36:32 +00:00
Peter Bloomfield
e64293d56c utils: Limit the scope of the variable max
in g_get_host_name(), and avoid an unused-variable warning when
_SC_HOST_NAME_MAX is not defined.
2020-09-22 16:14:21 -04:00
Stas Solovey
298b712b27 Update Russian translation 2020-09-22 19:46:32 +00:00
Philip Withnall
6248039403 Merge branch 'wip/issue2205' into 'master'
glocalfile: Never require G_LOCAL_FILE_STAT_FIELD_ATIME

Closes #2205 and #2189

See merge request GNOME/glib!1648
2020-09-22 15:51:03 +00:00
Philip Withnall
eb19c328f3 glist: Clarify that g_list_free() and friends only free an entire list
They shouldn’t be used to free a list from part-way through, as that
is confusing and will leave a dangling pointer from the previous list
element.

Spotted by Gary Kramlich in !1653.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-09-22 16:41:55 +01:00
Efstathios Iosifidis
76dfe085e4 Update Greek translation 2020-09-21 20:07:27 +00:00
Juliano de Souza Camargo
940f3ef9c9 Update Portuguese translation 2020-09-21 14:25:27 +00:00
Juliano de Souza Camargo
b2d0d1015c Update Portuguese translation
(cherry picked from commit 82ed2f22de)
2020-09-21 14:06:17 +00:00
Nirbheek Chauhan
7b17c57a38 Merge branch '2019-10-28_Define_G_MSVC_SYMBOL_PREFIX_correctly_for_ARM' into 'master'
Define G_MSVC_SYMBOL_PREFIX correctly for ARM

See merge request GNOME/glib!1187
2020-09-18 18:35:10 +00:00
Wolfgang Stöggl
7e27162874 Define G_MSVC_SYMBOL_PREFIX correctly for ARM32
Symbols on x86 are prefixed with an underscore
but symbols on x64/ARM/ARM64 are not.

Relevant information concerning the prefixes for the architectures
can be found in the vcpkg project [1,2], where arm and arm64 builds
are part of the CI.

Specifically, _WIN64 is defined on Windows ARM64, so this issue is
only visible when building on ARM32.

[1] 08e74979df/ports/glib/fix-arm-builds.patch
[2] https://github.com/microsoft/vcpkg/pull/6116
2020-09-18 23:50:09 +05:30
Ryan Gonzalez
88032cb541 trash portal: Handle portal failures
Previously, only whether or not the D-Bus call itself succeeded was
checked, regardless of the result code from the actual trash operation.
2020-09-15 18:06:56 -05:00
Simon McVittie
642baa50fa glocalfile: Never require G_LOCAL_FILE_STAT_FIELD_ATIME
Some filesystems don't have meaningful access times under at least some
circumstances (see #2189, #2205). In this situation the traditional stat()
and related kernel interfaces have to put something meaningless in the
st_atime field, and have no way to signal that it is meaningless.

However, statx() does have a way to signal that the atime is meaningless:
if the filesystem doesn't provide a useful access time, it will unset
the STATX_ATIME bit (as well as filling in the same meaningless value
for the stx_atime field that stat() would have used, for compatibility).
We don't actually *need* the atime, so never include it in the required
mask. This was already done for one code path in commit 6fc143bb
"gio: Allow no atime from statx" to fix #2189, but other callers were
left unchanged in that commit, and receive the same change here.

It is not actually guaranteed that *any* of the flags in the
returned stx_mask will be set (the only guarantee is that items in
STATX_BASIC_STATS have at least a harmless compatibility value, even if
their corresponding flag is cleared), so it might be better to follow
this up by removing the concept of the required mask entirely. However,
as of Linux 5.8 it looks as though STATX_ATIME is the only flag in
STATX_BASIC_STATS that might be cleared in practice, so this simpler
change fixes the immediate regression.

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2205
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-09-15 10:09:46 +01:00
Philip Withnall
9bc61def1f Merge branch 'fix_warnings' into 'master'
Fix various signedness warnings

See merge request GNOME/glib!1645
2020-09-14 08:30:52 +00:00
Emmanuel Fleury
16773d2702 Fix a signedness problem in glib/tests/date.c
glib/tests/date.c:778:17: error: comparison of integer expressions of
  different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’

  778 |   for (i = 0; i < G_N_ELEMENTS (check_years); i++)
      |                 ^
2020-09-14 10:11:44 +02:00
Emmanuel Fleury
33148e6bc3 Fix a signedness problem in glib/tests/collate.c
glib/tests/collate.c:300:17: error: comparison of integer expressions
  of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’

  300 |   for (i = 0; i < G_N_ELEMENTS (test); i++)
      |                 ^
2020-09-14 10:11:44 +02:00
Emmanuel Fleury
d49586cfa3 Fix signedness error in glib/gspawn.c
glib/gspawn.c:2252:16: error: comparison of integer expressions of
  different signedness: ‘int’ and ‘gsize’ {aka ‘long unsigned int’}

 2252 |   if (argc + 2 > argv_buffer_len)
      |                ^
2020-09-14 10:11:44 +02:00
Emmanuel Fleury
33bfae70ac Fix signedness problem in glib/gutils.c
glib/gutils.c:998:26: error: comparison of integer expressions of
 different signedness: ‘glong’ {aka ‘long int’} and ‘long unsigned int’
  998 |       if (max > 0 && max <= G_MAXSIZE - 1)
      |                          ^~
2020-09-14 10:11:44 +02:00
Rūdolfs Mazurs
b696dccb20 Update Latvian translation 2020-09-13 08:54:05 +00:00
Ask Hjorth Larsen
1d1262e81a Updated Danish translation 2020-09-12 01:11:23 +02:00
Philip Withnall
c3eda78ada Merge branch '2194-winhttp-file-display-name' into 'master'
gwinhttpfile: Set display-name attribute on file info

Closes #2194

See merge request GNOME/glib!1644
2020-09-11 09:49:04 +00:00
Philip Withnall
9d859f001d gutf8: Fix a typo in the docs for g_utf16_to_utf8()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-09-10 14:14:32 +01:00
Philip Withnall
6f9b379c08 gwinhttpfile: Set display-name attribute on file info
It is not allowed to be `NULL` or unset if requested by the file
attribute matcher. Derive it from the basename. This doesn’t handle the
situation of a failed UTF-16 to UTF-8 conversion very well, but will at
least return something.

Note that the `g_filename_display_basename()` function can’t be used as
`GWinHttpFile` provides its URI in UTF-16 rather than in the file system
encoding.

This fixes a crash when using GIMP on Windows. Thanks to lillolollo for
in-depth debugging assistance.

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

Fixes: #2194
2020-09-10 14:14:32 +01:00
Sebastian Dröge
b7c75f78ab Merge branch '2077-pointer-arithmetic' into 'master'
gfileutils: Correct operator precedence to avoid undefined pointer maths

Closes #2077

See merge request GNOME/glib!1526
2020-09-10 11:22:44 +00:00
Philip Withnall
aea8c91837 Merge branch 'wip/2164-dbus-sha1-timeout' into 'master'
gdbusauthmechanismsha1: Use the same timeouts as libdbus

Closes #2164

See merge request GNOME/glib!1641
2020-09-10 11:13:52 +00:00
Philip Withnall
f010a8c983 Merge branch 'coverity-fixes' into 'master'
Minor Coverity fixes

See merge request GNOME/glib!1643
2020-09-10 11:13:01 +00:00
Philip Withnall
c2c12e4292 2.66.0
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-09-10 11:39:49 +01:00
Milo Casagrande
bca2bdd867 Update Italian translation 2020-09-10 09:17:23 +00:00
Goran Vidović
496858c904 Update Croatian translation 2020-09-09 19:28:45 +00:00
Goran Vidović
81fd3fe4d9 Update Croatian translation 2020-09-08 21:17:06 +00:00
Goran Vidović
bd5efc8b0e Update Croatian translation 2020-09-08 16:09:23 +00:00
Philip Withnall
cbf72f0dc9 ci: Add model file for Coverity
This isn’t used in the build at all, it’s just a copy of the model file
which is uploaded in our Coverity configuration. This should be kept up
to date with changes in the file on the Coverity servers.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-09-08 10:34:54 +01:00
Philip Withnall
f19cb44b98 guri: Remove unnecessary NULL pointer check
`uri` is always non-`NULL` by the time the `fail` label is reached, so
drop the `NULL` pointer check. Inline the `fail` code since it’s only
used from two places.

Coverity CID: #1430970
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-09-08 09:59:24 +01:00
Goran Vidović
2effedd75b Update Croatian translation 2020-09-07 21:58:14 +00:00
Balázs Meskó
7fa8d5f746 Update Hungarian translation 2020-09-07 20:09:27 +00:00
Goran Vidović
6f69a79062 Update Croatian translation 2020-09-07 19:08:25 +00:00
Simon McVittie
92183fb703 gdbusauthmechanismsha1: Use the same timeouts as libdbus
For interoperability with libdbus, we want to use compatible timeouts.
In particular, this fixes a spurious failure of the `gdbus-server-auth`
test caused by libdbus and gdbus choosing to expire the key (cookie) at
different times, as diagnosed by Thiago Macieira. Previously, the libdbus
client would decline to use keys older than 7 minutes, but the GDBus
server would not generate a new key until the old key was 10 minutes old.

For completeness, also adjust the other arbitrary timeouts in the
DBUS_COOKIE_SHA1 mechanism to be the same as in libdbus. To make it
easier to align with libdbus, create internal macros with the same names
and values used in dbus-keyring.c.

* maximum time a key can be in the future due to clock skew between
  systems sharing a home directory
  - spec says "a reasonable time in the future"
  - was 1 day
  - now 5 minutes
  - MAX_TIME_TRAVEL_SECONDS

* time to generate a new key if the newest is older
  - spec says "If no recent keys remain, the server may generate a new
    key", but that isn't practical, because in reality we need a grace
    period during which an old key will not be used for new authentication
    attempts but old authentication attempts can continue (in practice both
    libdbus and GDBus implemented this logic)
  - was 10 minutes
  - now 5 minutes
  - NEW_KEY_TIMEOUT_SECONDS

* time to discard old keys
  - spec says "the timeout can be fairly short"
  - was 15 minutes
  - now 7 minutes
  - EXPIRE_KEYS_TIMEOUT_SECONDS

* time allowed for a client using an old key to authenticate, before
  that key gets deleted
  - was at least 5 minutes
  - now at least 2 minutes
  - at least (EXPIRE_KEYS_TIMEOUT_SECONDS - NEW_KEY_TIMEOUT_SECONDS)

Based on a merge request by Philip Withnall.

Fixes: #2164
Thanks: Philip Withnall
Thanks: Thiago Macieira
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-09-07 11:29:06 +01:00
Anders Jonsson
8a3f570e6f Update Swedish translation 2020-09-06 15:09:33 +00:00
Dušan Kazik
91027d4b35 Update Slovak translation 2020-09-06 11:27:49 +00:00
Goran Vidović
8be23b0017 Update Croatian translation 2020-09-05 21:56:16 +00:00
Марко Костић
602edf1b3c Update Serbian translation 2020-09-04 07:13:11 +00:00
Sebastian Dröge
83681d6216 Merge branch '2200-po-makefile-tabs' into 'master'
po: Fix tab indentation in Makefile.in.in

Closes #2200

See merge request GNOME/glib!1640
2020-09-03 09:48:03 +00:00
Philip Withnall
d0b8d671f1 po: Fix tab indentation in Makefile.in.in
This file is still installed for other projects to use.

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

Fixes: #2200
2020-09-03 10:28:59 +01:00