Make the error message in case of a broken thread system a bit more
authorSebastian Wilhelmi <wilhelmi@ira.uka.de>
Fri, 5 Feb 1999 16:41:02 +0000 (16:41 +0000)
committerSebastian Wilhelmi <wilhelmi@src.gnome.org>
Fri, 5 Feb 1999 16:41:02 +0000 (16:41 +0000)
1999-02-05  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

* configure.in: Make the error message in case of a broken thread
system a bit more informative.

* gutils.c (g_get_any_init): Changed the error logic again, now
only leaving the memory doubling loop, when success is reached or
when the user isn't found or when the buffer is 32k big,
additionally now getpwuid will be run, if getpwuid_r didn't work
out properly. A warning is issued however.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
configure.in
glib/gutils.c
gutils.c

index 06a8a4a..938def2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+1999-02-05  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
+
+       * configure.in: Make the error message in case of a broken thread
+       system a bit more informative.
+
+       * gutils.c (g_get_any_init): Changed the error logic again, now
+       only leaving the memory doubling loop, when success is reached or
+       when the user isn't found or when the buffer is 32k big,
+       additionally now getpwuid will be run, if getpwuid_r didn't work
+       out properly. A warning is issued however.
+
 Thu Feb 04 20:42:24 1999  Tor Lillqvist  <tml@iki.fi>
 
        * glibconfig.h.win32 config.h.win32: Update GLIB_MICRO_VERSION.
index 06a8a4a..938def2 100644 (file)
@@ -1,3 +1,14 @@
+1999-02-05  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
+
+       * configure.in: Make the error message in case of a broken thread
+       system a bit more informative.
+
+       * gutils.c (g_get_any_init): Changed the error logic again, now
+       only leaving the memory doubling loop, when success is reached or
+       when the user isn't found or when the buffer is 32k big,
+       additionally now getpwuid will be run, if getpwuid_r didn't work
+       out properly. A warning is issued however.
+
 Thu Feb 04 20:42:24 1999  Tor Lillqvist  <tml@iki.fi>
 
        * glibconfig.h.win32 config.h.win32: Update GLIB_MICRO_VERSION.
index 06a8a4a..938def2 100644 (file)
@@ -1,3 +1,14 @@
+1999-02-05  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
+
+       * configure.in: Make the error message in case of a broken thread
+       system a bit more informative.
+
+       * gutils.c (g_get_any_init): Changed the error logic again, now
+       only leaving the memory doubling loop, when success is reached or
+       when the user isn't found or when the buffer is 32k big,
+       additionally now getpwuid will be run, if getpwuid_r didn't work
+       out properly. A warning is issued however.
+
 Thu Feb 04 20:42:24 1999  Tor Lillqvist  <tml@iki.fi>
 
        * glibconfig.h.win32 config.h.win32: Update GLIB_MICRO_VERSION.
index 06a8a4a..938def2 100644 (file)
@@ -1,3 +1,14 @@
+1999-02-05  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
+
+       * configure.in: Make the error message in case of a broken thread
+       system a bit more informative.
+
+       * gutils.c (g_get_any_init): Changed the error logic again, now
+       only leaving the memory doubling loop, when success is reached or
+       when the user isn't found or when the buffer is 32k big,
+       additionally now getpwuid will be run, if getpwuid_r didn't work
+       out properly. A warning is issued however.
+
 Thu Feb 04 20:42:24 1999  Tor Lillqvist  <tml@iki.fi>
 
        * glibconfig.h.win32 config.h.win32: Update GLIB_MICRO_VERSION.
index 06a8a4a..938def2 100644 (file)
@@ -1,3 +1,14 @@
+1999-02-05  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
+
+       * configure.in: Make the error message in case of a broken thread
+       system a bit more informative.
+
+       * gutils.c (g_get_any_init): Changed the error logic again, now
+       only leaving the memory doubling loop, when success is reached or
+       when the user isn't found or when the buffer is 32k big,
+       additionally now getpwuid will be run, if getpwuid_r didn't work
+       out properly. A warning is issued however.
+
 Thu Feb 04 20:42:24 1999  Tor Lillqvist  <tml@iki.fi>
 
        * glibconfig.h.win32 config.h.win32: Update GLIB_MICRO_VERSION.
index 06a8a4a..938def2 100644 (file)
@@ -1,3 +1,14 @@
+1999-02-05  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
+
+       * configure.in: Make the error message in case of a broken thread
+       system a bit more informative.
+
+       * gutils.c (g_get_any_init): Changed the error logic again, now
+       only leaving the memory doubling loop, when success is reached or
+       when the user isn't found or when the buffer is 32k big,
+       additionally now getpwuid will be run, if getpwuid_r didn't work
+       out properly. A warning is issued however.
+
 Thu Feb 04 20:42:24 1999  Tor Lillqvist  <tml@iki.fi>
 
        * glibconfig.h.win32 config.h.win32: Update GLIB_MICRO_VERSION.
index 06a8a4a..938def2 100644 (file)
@@ -1,3 +1,14 @@
+1999-02-05  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
+
+       * configure.in: Make the error message in case of a broken thread
+       system a bit more informative.
+
+       * gutils.c (g_get_any_init): Changed the error logic again, now
+       only leaving the memory doubling loop, when success is reached or
+       when the user isn't found or when the buffer is 32k big,
+       additionally now getpwuid will be run, if getpwuid_r didn't work
+       out properly. A warning is issued however.
+
 Thu Feb 04 20:42:24 1999  Tor Lillqvist  <tml@iki.fi>
 
        * glibconfig.h.win32 config.h.win32: Update GLIB_MICRO_VERSION.
index 06a8a4a..938def2 100644 (file)
@@ -1,3 +1,14 @@
+1999-02-05  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
+
+       * configure.in: Make the error message in case of a broken thread
+       system a bit more informative.
+
+       * gutils.c (g_get_any_init): Changed the error logic again, now
+       only leaving the memory doubling loop, when success is reached or
+       when the user isn't found or when the buffer is 32k big,
+       additionally now getpwuid will be run, if getpwuid_r didn't work
+       out properly. A warning is issued however.
+
 Thu Feb 04 20:42:24 1999  Tor Lillqvist  <tml@iki.fi>
 
        * glibconfig.h.win32 config.h.win32: Update GLIB_MICRO_VERSION.
index bcd1a0f..196dd0b 100644 (file)
@@ -572,7 +572,9 @@ LIBS_NOT_FOUND_1="I can't find the libraries for the thread implementation
                "
 
 LIBS_NOT_FOUND_2=". Please choose another thread implementation or
-               provide information on your thread implementation."
+               provide information on your thread implementation.
+               You can also use the '--disable-threads' flag for configure 
+               to compile without thread support."
 
 FUNC_NO_GETPWUID_R="the 'g_get_(user_name|real_name|home_dir|tmp_dir)'
                functions will not be MT-safe during their first call because
index 321a131..04771cc 100644 (file)
@@ -448,10 +448,11 @@ g_get_any_init (void)
         guint bufsize = 64;
         gint error;
 
-        do
+        while (1)
           {
             g_free (buffer);
             buffer = g_malloc (bufsize);
+           errno = 0;
 
 #    ifdef HAVE_GETPWUID_R_POSIX
             error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
@@ -461,21 +462,38 @@ g_get_any_init (void)
             error = pw ? 0 : errno;
 #    endif /* !HAVE_GETPWUID_R_POSIX */
 
+           /* Now there are actually only 3 cases to leave the loop:
+              1. pw != NULL -> all went fine.
+              2. pw == NULL && ( error == 0 || error == ENOENT ) 
+                   -> no such user (unlikely in the case of getuid ())
+              3. bufsize > 32k -> the problem can't be of ERANGE type */  
+           if (pw)
+             break;
+
+           if (pw == NULL && ( error == 0 || error == ENOENT))
+             {
+               g_warning ("getpwuid_r(): failed due to: No such user %d.",
+                          getuid ());
+               break;
+             }
+      
+           if (bufsize > 32 * 1024)
+             {
+               g_warning ("getpwuid_r(): failed due to: %s.",
+                          g_strerror (error));
+               break;
+             }
+             
             bufsize *= 2;
-          }
-        while (error == ERANGE);
-
-        if (error)
-          g_warning ("getpwuid_r(): failed due to: %s", g_strerror (error));
-
-#  else /* !HAVE_GETPWUID_R */
-
-        setpwent ();
-        pw = getpwuid (getuid ());
-        endpwent ();
-
+         }
 #  endif /* !HAVE_GETPWUID_R */
-       
+
+       if (!pw)
+         {
+           setpwent ();
+           pw = getpwuid (getuid ());
+           endpwent ();
+         }
        if (pw)
          {
            g_user_name = g_strdup (pw->pw_name);
index 321a131..04771cc 100644 (file)
--- a/gutils.c
+++ b/gutils.c
@@ -448,10 +448,11 @@ g_get_any_init (void)
         guint bufsize = 64;
         gint error;
 
-        do
+        while (1)
           {
             g_free (buffer);
             buffer = g_malloc (bufsize);
+           errno = 0;
 
 #    ifdef HAVE_GETPWUID_R_POSIX
             error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
@@ -461,21 +462,38 @@ g_get_any_init (void)
             error = pw ? 0 : errno;
 #    endif /* !HAVE_GETPWUID_R_POSIX */
 
+           /* Now there are actually only 3 cases to leave the loop:
+              1. pw != NULL -> all went fine.
+              2. pw == NULL && ( error == 0 || error == ENOENT ) 
+                   -> no such user (unlikely in the case of getuid ())
+              3. bufsize > 32k -> the problem can't be of ERANGE type */  
+           if (pw)
+             break;
+
+           if (pw == NULL && ( error == 0 || error == ENOENT))
+             {
+               g_warning ("getpwuid_r(): failed due to: No such user %d.",
+                          getuid ());
+               break;
+             }
+      
+           if (bufsize > 32 * 1024)
+             {
+               g_warning ("getpwuid_r(): failed due to: %s.",
+                          g_strerror (error));
+               break;
+             }
+             
             bufsize *= 2;
-          }
-        while (error == ERANGE);
-
-        if (error)
-          g_warning ("getpwuid_r(): failed due to: %s", g_strerror (error));
-
-#  else /* !HAVE_GETPWUID_R */
-
-        setpwent ();
-        pw = getpwuid (getuid ());
-        endpwent ();
-
+         }
 #  endif /* !HAVE_GETPWUID_R */
-       
+
+       if (!pw)
+         {
+           setpwent ();
+           pw = getpwuid (getuid ());
+           endpwent ();
+         }
        if (pw)
          {
            g_user_name = g_strdup (pw->pw_name);