[glib] Add thread-safety warnings to the g_setenv() and g_unsetenv() docs
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add thread-safety warnings to the g_setenv() and g_unsetenv() docs
- Date: Tue, 27 Sep 2011 14:30:55 +0000 (UTC)
commit 51166d0127d6d77ae7e4782887a76462858fdd91
Author: Dan Winship <danw gnome org>
Date: Mon Sep 26 14:17:43 2011 -0400
Add thread-safety warnings to the g_setenv() and g_unsetenv() docs
https://bugzilla.gnome.org/show_bug.cgi?id=659326
glib/gutils.c | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/glib/gutils.c b/glib/gutils.c
index c7f2763..12ad096 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -1331,6 +1331,16 @@ _g_getenv_nomalloc (const gchar *variable,
* Note that on some systems, when variables are overwritten, the memory
* used for the previous variables and its value isn't reclaimed.
*
+ * <warning><para>
+ * Environment variable handling in UNIX is not thread-safe, and your
+ * program may crash if one thread calls g_setenv() while another
+ * thread is calling getenv(). (And note that many functions, such as
+ * gettext(), call getenv() internally.) This function is only safe to
+ * use at the very start of your program, before creating any other
+ * threads (or creating objects that create worker threads of their
+ * own).
+ * </para></warning>
+ *
* Returns: %FALSE if the environment variable couldn't be set.
*
* Since: 2.4
@@ -1430,8 +1440,16 @@ extern char **environ;
*
* Note that on some systems, when variables are overwritten, the memory
* used for the previous variables and its value isn't reclaimed.
- * Furthermore, this function can't be guaranteed to operate in a
- * threadsafe way.
+ *
+ * <warning><para>
+ * Environment variable handling in UNIX is not thread-safe, and your
+ * program may crash if one thread calls g_unsetenv() while another
+ * thread is calling getenv(). (And note that many functions, such as
+ * gettext(), call getenv() internally.) This function is only safe to
+ * use at the very start of your program, before creating any other
+ * threads (or creating objects that create worker threads of their
+ * own).
+ * </para></warning>
*
* Since: 2.4
**/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]