libnm: make caching of encodings in nm_utils_ssid_to_utf8() thread safe

libnm's data structures are commonly not thread safe (like
NMConnection). However, it must be possible that all operations can
operate on *different* data in a thread safe manner. That means, we need
to take care about our global variables.

nm_utils_ssid_to_utf8() uses a list of encodings, which gets cached.

- replace the GHashTables with a static list. Since it doesn't cost
  anything, make the list sorted and look it up via binary search.
This commit is contained in:
Thomas Haller
2022-01-02 20:43:09 +01:00
parent a5f7f89b04
commit 91653ea784
3 changed files with 249 additions and 139 deletions

View File

@@ -66,4 +66,8 @@ void _nm_team_settings_property_from_dbus_link_watchers(
GVariant *_nm_utils_ip4_dns_to_variant(const char *const *dns, gssize len);
GVariant *_nm_utils_ip6_dns_to_variant(const char *const *dns, gssize len);
const char *const *nmtst_system_encodings_for_lang(const char *lang);
const char *const *nmtst_system_encodings_get_default(void);
const char *const *nmtst_system_encodings_get(void);
#endif