[glib] GTimeZoneMonitor: Revert addition of this class
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GTimeZoneMonitor: Revert addition of this class
- Date: Mon, 22 Aug 2011 15:18:27 +0000 (UTC)
commit 5b68b49b2072c371c72ee96175e3d6a727eb5e8b
Author: Colin Walters <walters verbum org>
Date: Fri Aug 19 03:27:16 2011 -0400
GTimeZoneMonitor: Revert addition of this class
The main rationale for adding it was to avoid having gnome-shell
mmap'ing /etc/localtime once a second. However, we can just as easily
run inotify there, and given no one else was clamoring for a way to
detect when the time zone changes, I don't see a need for public API
here - at least not yet.
In the bigger picture, I just don't believe that the vast majority of
applications are going to go out of their way to instantiate and keep
around a random GTimeZoneMonitor class. And if they do, it's has the
side effect that for other bits of code in the process, local GDateTime
instances may start varying again!
So, if code can't rely on local GDateTime instances being in a
consistent state anyways, let's just do that always. The
documentation now says that this is the case. Applications have
always been able to work in a consistent local time zone by
instantiating a zone and then using it for GDateTime constructors.
We fix the "gnome-shell stats /etc/localtime once a second" issue by
using timerfd (in glib) and inotify (in gnome-shell).
https://bugzilla.gnome.org/show_bug.cgi?id=655129
docs/reference/gio/gio-sections.txt | 13 ---
docs/reference/gio/gio.types | 1 -
docs/reference/glib/glib-sections.txt | 2 -
gio/Makefile.am | 2 -
gio/gio.h | 1 -
gio/gio.symbols | 2 -
gio/gtimezonemonitor.c | 156 ---------------------------------
gio/gtimezonemonitor.h | 47 ----------
glib/glib.symbols | 1 -
glib/gtimezone.c | 66 +-------------
glib/gtimezone.h | 2 -
glib/tests/gdatetime.c | 17 ----
12 files changed, 5 insertions(+), 305 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 7aac558..75f3ac8 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -3253,19 +3253,6 @@ g_tls_console_interaction_get_type
</SECTION>
<SECTION>
-<FILE>gtimezonemonitor</FILE>
-<TITLE>GTimeZoneMonitor</TITLE>
-GTimeZoneMonitor
-g_time_zone_monitor_get
-<SUBSECTION Standard>
-G_IS_TIME_ZONE_MONITOR
-G_TIME_ZONE_MONITOR
-G_TYPE_TIME_ZONE_MONITOR
-<SUBSECTION Private>
-g_time_zone_monitor_get_type
-</SECTION>
-
-<SECTION>
<FILE>gdbusinterface</FILE>
<TITLE>GDBusInterface</TITLE>
GDBusInterface
diff --git a/docs/reference/gio/gio.types b/docs/reference/gio/gio.types
index 685a900..58bff23 100644
--- a/docs/reference/gio/gio.types
+++ b/docs/reference/gio/gio.types
@@ -138,7 +138,6 @@ g_dbus_server_get_type
g_dbus_auth_observer_get_type
g_credentials_get_type
g_unix_credentials_message_get_type
-g_time_zone_monitor_get_type
g_dbus_interface_get_type
g_dbus_interface_skeleton_get_type
g_dbus_object_get_type
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 70baaf3..6ea7401 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -1448,8 +1448,6 @@ g_time_zone_new
g_time_zone_new_local
g_time_zone_new_utc
<SUBSECTION>
-g_time_zone_refresh_local
-<SUBSECTION>
GTimeType
g_time_zone_find_interval
g_time_zone_adjust_time
diff --git a/gio/Makefile.am b/gio/Makefile.am
index b9f96e8..0a127a6 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -377,7 +377,6 @@ libgio_2_0_la_SOURCES = \
gthemedicon.c \
gthreadedresolver.c \
gthreadedresolver.h \
- gtimezonemonitor.c \
gtlsbackend.c \
gtlscertificate.c \
gtlsclientconnection.c \
@@ -534,7 +533,6 @@ gio_headers = \
gtcpwrapperconnection.h \
gthreadedsocketservice.h\
gthemedicon.h \
- gtimezonemonitor.h \
gtlsbackend.h \
gtlscertificate.h \
gtlsclientconnection.h \
diff --git a/gio/gio.h b/gio/gio.h
index 9281dde..f0bc550 100644
--- a/gio/gio.h
+++ b/gio/gio.h
@@ -119,7 +119,6 @@
#include <gio/gtcpwrapperconnection.h>
#include <gio/gthemedicon.h>
#include <gio/gthreadedsocketservice.h>
-#include <gio/gtimezonemonitor.h>
#include <gio/gtlsbackend.h>
#include <gio/gtlscertificate.h>
#include <gio/gtlsclientconnection.h>
diff --git a/gio/gio.symbols b/gio/gio.symbols
index da4ec6c..d6d78a5 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -1493,8 +1493,6 @@ g_tls_password_set_value_full
g_tls_password_set_warning
g_tls_password_get_flags
g_tls_password_get_description
-g_time_zone_monitor_get_type
-g_time_zone_monitor_get
g_dbus_interface_get_info
g_dbus_interface_get_object
g_dbus_interface_get_type
diff --git a/glib/glib.symbols b/glib/glib.symbols
index d063b22..20b3b5a 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -300,7 +300,6 @@ g_date_time_to_unix
g_date_time_to_utc
g_date_time_unref
g_time_zone_new
-g_time_zone_refresh_local
g_time_zone_new_local
g_time_zone_new_utc
g_time_zone_ref
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index 9b2fb07..1c2b26f 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -129,9 +129,6 @@ struct _GTimeZone
gint ref_count;
};
-G_LOCK_DEFINE_STATIC (local_timezone);
-static GTimeZone *local_timezone;
-
G_LOCK_DEFINE_STATIC (time_zones);
static GHashTable/*<string?, GTimeZone>*/ *time_zones;
@@ -155,21 +152,6 @@ again:
if (ref_count == 1)
{
- if G_UNLIKELY (tz == local_timezone)
- {
- g_critical ("The last reference on the local timezone was just "
- "dropped, but GTimeZone itself still owns one. This "
- "means that g_time_zone_unref() was called too many "
- "times. Returning without lowering the refcount.");
-
- /* We don't want to just inc this back again since if there
- * are refcounting bugs in the code then maybe we are already
- * at -1 and inc will just take us back to 0. Set to 1 to be
- * sure.
- */
- return;
- }
-
if (tz->name != NULL)
{
G_LOCK(time_zones);
@@ -468,12 +450,13 @@ g_time_zone_new_utc (void)
/**
* g_time_zone_new_local:
*
- * Creates a #GTimeZone corresponding to local time.
+ * Creates a #GTimeZone corresponding to local time. The local time
+ * zone may change between invocations to this function; for example,
+ * if the system administrator changes it.
*
* This is equivalent to calling g_time_zone_new() with the value of the
* <varname>TZ</varname> environment variable (including the possibility
- * of %NULL). Changes made to <varname>TZ</varname> after the first
- * call to this function may or may not be noticed by future calls.
+ * of %NULL).
*
* You should release the return value by calling g_time_zone_unref()
* when you are done with it.
@@ -485,46 +468,7 @@ g_time_zone_new_utc (void)
GTimeZone *
g_time_zone_new_local (void)
{
- GTimeZone *result;
-
- G_LOCK (local_timezone);
- if (local_timezone == NULL)
- local_timezone = g_time_zone_new (getenv ("TZ"));
-
- result = g_time_zone_ref (local_timezone);
- G_UNLOCK (local_timezone);
-
- return result;
-}
-
-/**
- * g_time_zone_refresh_local:
- *
- * Notifies #GTimeZone that the local timezone may have changed.
- *
- * In response, #GTimeZone will drop its cache of the local time zone.
- * No existing #GTimeZone will be modified and no #GDateTime will change
- * its timezone but future calls to g_time_zone_new_local() will start
- * returning the new timezone.
- *
- * #GTimeZone does no monitoring of the local timezone on its own, which
- * is why you have to call this function to notify it of the change.
- *
- * If you use #GTimeZoneMonitor to watch for changes then this function
- * will automatically be called for you.
- **/
-void
-g_time_zone_refresh_local (void)
-{
- GTimeZone *drop_this_ref = NULL;
-
- G_LOCK (local_timezone);
- drop_this_ref = local_timezone;
- local_timezone = NULL;
- G_UNLOCK (local_timezone);
-
- if (drop_this_ref)
- g_time_zone_unref (drop_this_ref);
+ return g_time_zone_new (getenv ("TZ"));
}
/* Internal helpers {{{1 */
diff --git a/glib/gtimezone.h b/glib/gtimezone.h
index eb7e287..58b0db9 100644
--- a/glib/gtimezone.h
+++ b/glib/gtimezone.h
@@ -54,8 +54,6 @@ typedef enum
G_TIME_TYPE_UNIVERSAL
} GTimeType;
-void g_time_zone_refresh_local (void);
-
GTimeZone * g_time_zone_new (const gchar *identifier);
GTimeZone * g_time_zone_new_utc (void);
GTimeZone * g_time_zone_new_local (void);
diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
index 7f7b481..59412a7 100644
--- a/glib/tests/gdatetime.c
+++ b/glib/tests/gdatetime.c
@@ -1108,22 +1108,6 @@ test_z (void)
g_free (p);
}
-static void
-test_refresh (void)
-{
- GTimeZone *zone;
-
- zone = g_time_zone_new (NULL);
- g_assert (zone != NULL);
- g_time_zone_unref (zone);
-
- g_time_zone_refresh_local ();
-
- zone = g_time_zone_new (NULL);
- g_assert (zone != NULL);
- g_time_zone_unref (zone);
-}
-
gint
main (gint argc,
gchar *argv[])
@@ -1170,7 +1154,6 @@ main (gint argc,
g_test_add_func ("/GDateTime/dst", test_GDateTime_dst);
g_test_add_func ("/GDateTime/test_z", test_z);
g_test_add_func ("/GDateTime/test-all-dates", test_all_dates);
- g_test_add_func ("/GDateTime/refresh", test_refresh);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]