diff --git a/devel/glib2/Makefile b/devel/glib2/Makefile index f65479d8f53..0e2692a6f7b 100644 --- a/devel/glib2/Makefile +++ b/devel/glib2/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.313 2019/11/01 19:33:14 ajacoutot Exp $ +# $OpenBSD: Makefile,v 1.314 2019/11/02 11:07:42 ajacoutot Exp $ # Everything is a Freaking GLib/GTK+ problem CFLAGS += -g @@ -9,6 +9,7 @@ COMMENT= general-purpose utility library GNOME_PROJECT= glib GNOME_VERSION= 2.62.2 PKGNAME= ${DISTNAME:S/glib/glib2/} +REVISION= 0 CATEGORIES= devel diff --git a/devel/glib2/patches/patch-glib_gtimezone_c b/devel/glib2/patches/patch-glib_gtimezone_c new file mode 100644 index 00000000000..49a360f0d75 --- /dev/null +++ b/devel/glib2/patches/patch-glib_gtimezone_c @@ -0,0 +1,74 @@ +$OpenBSD: patch-glib_gtimezone_c,v 1.1 2019/11/02 11:07:42 ajacoutot Exp $ + +From 551e83662de9815d161a82c760cfa77995905740 Mon Sep 17 00:00:00 2001 +From: rim +Date: Fri, 25 Oct 2019 17:27:49 +0000 +Subject: [PATCH] gtimezone: Cache UTC and local TZ indefinitely + +Index: glib/gtimezone.c +--- glib/gtimezone.c.orig ++++ glib/gtimezone.c +@@ -37,6 +37,7 @@ + #include "gslice.h" + #include "gdatetime.h" + #include "gdate.h" ++#include "genviron.h" + + #ifdef G_OS_WIN32 + +@@ -196,6 +197,8 @@ struct _GTimeZone + + G_LOCK_DEFINE_STATIC (time_zones); + static GHashTable/**/ *time_zones; ++G_LOCK_DEFINE_STATIC (tz_local); ++static GTimeZone *tz_local = NULL; + + #define MIN_TZYEAR 1916 /* Daylight Savings started in WWI */ + #define MAX_TZYEAR 2999 /* And it's not likely ever to go away, but +@@ -1656,10 +1659,20 @@ g_time_zone_new (const gchar *identifier) + * + * Since: 2.26 + **/ ++static gpointer ++g_time_zone_utc_init (gpointer data) ++{ ++ return g_time_zone_new ("UTC"); ++} ++ + GTimeZone * + g_time_zone_new_utc (void) + { +- return g_time_zone_new ("UTC"); ++ static GOnce utc_once = G_ONCE_INIT; ++ ++ g_once (&utc_once, g_time_zone_utc_init, NULL); ++ ++ return g_time_zone_ref ((GTimeZone *)utc_once.retval); + } + + /** +@@ -1682,7 +1695,23 @@ g_time_zone_new_utc (void) + GTimeZone * + g_time_zone_new_local (void) + { +- return g_time_zone_new (getenv ("TZ")); ++ const gchar *tzenv = g_getenv ("TZ"); ++ GTimeZone *tz; ++ ++ G_LOCK (tz_local); ++ ++ /* Is time zone changed and must be flushed? */ ++ if (tz_local && g_strcmp0 (g_time_zone_get_identifier (tz_local), tzenv)) ++ g_clear_pointer (&tz_local, g_time_zone_unref); ++ ++ if (tz_local == NULL) ++ tz_local = g_time_zone_new (tzenv); ++ ++ tz = g_time_zone_ref (tz_local); ++ ++ G_UNLOCK (tz_local); ++ ++ return tz; + } + + /**