Update.
authorUlrich Drepper <drepper@redhat.com>
Tue, 17 Jul 2001 08:32:35 +0000 (08:32 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 17 Jul 2001 08:32:35 +0000 (08:32 +0000)
2001-07-17  Ulrich Drepper  <drepper@redhat.com>

* inet/rcmd.c (iruserfopen): Disable implicit locking for the stream.
* inet/ruserpass.c (ruserpass): Likewise.
* nss/nsswitch.c (nss_parse_file): Likewise.
* resolv/res_hconf.c (_res_hconf_init): Likewise.
* resolv/res_init.c (__res_vinit): Likewise.
* gmon/bb_exit_func.c (__bb_exit_func): Likewise.
* misc/getpass.c (getpass): Likewise.
* misc/getusershell.c (initshells): Likewise.
* misc/getttyent.c (setttyent): Likewise.
* misc/mntent_r.c (__setmntent): Likewise.
* time/getdate.c (__getdate_r): Likewise.
* time/tzfile.c (__tzfile_read): Likewise.
* iconv/gconv_conf.c (read_conf_file): Likewise.
* intl/localealias.c (read_alias_file): Disable implicit locking
for the stream.  Use _unlocked functions for glibc.
* sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Disable
implicit locking for the stream.
(__get_nprocs_conf): Likewise.
(phys_pages_info): Likewise.

16 files changed:
ChangeLog
gmon/bb_exit_func.c
iconv/gconv_conf.c
inet/rcmd.c
inet/ruserpass.c
intl/localealias.c
misc/getpass.c
misc/getttyent.c
misc/getusershell.c
misc/mntent_r.c
nss/nsswitch.c
resolv/res_hconf.c
resolv/res_init.c
sysdeps/unix/sysv/linux/getsysstats.c
time/getdate.c
time/tzfile.c

index 4588974ae30d7d40ec4b8aa9ba2e97bc1dbad33e..0ae1ff2cad3fe2a7005945a4028df1abe51ff6b1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2001-07-17  Ulrich Drepper  <drepper@redhat.com>
+
+       * inet/rcmd.c (iruserfopen): Disable implicit locking for the stream.
+       * inet/ruserpass.c (ruserpass): Likewise.
+       * nss/nsswitch.c (nss_parse_file): Likewise.
+       * resolv/res_hconf.c (_res_hconf_init): Likewise.
+       * resolv/res_init.c (__res_vinit): Likewise.
+       * gmon/bb_exit_func.c (__bb_exit_func): Likewise.
+       * misc/getpass.c (getpass): Likewise.
+       * misc/getusershell.c (initshells): Likewise.
+       * misc/getttyent.c (setttyent): Likewise.
+       * misc/mntent_r.c (__setmntent): Likewise.
+       * time/getdate.c (__getdate_r): Likewise.
+       * time/tzfile.c (__tzfile_read): Likewise.
+       * iconv/gconv_conf.c (read_conf_file): Likewise.
+       * intl/localealias.c (read_alias_file): Disable implicit locking
+       for the stream.  Use _unlocked functions for glibc.
+       * sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Disable
+       implicit locking for the stream.
+       (__get_nprocs_conf): Likewise.
+       (phys_pages_info): Likewise.
+
 2001-07-16  Ulrich Drepper  <drepper@redhat.com>
 
        * nscd/connections.c: Print messages caused by user application
index 90a67019890e6e78b274f702040e535536639b81..ce61c75d6ebebe0a03321c4e002abd5bc61fb832 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by David Mosberger (davidm@cs.arizona.edu).
 
@@ -25,6 +25,7 @@
 #include <sys/types.h>
 
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <string.h>
 
 #define OUT_NAME       "gmon.out"
@@ -43,6 +44,9 @@ __bb_exit_func (void)
       perror (OUT_NAME);
       return;
     }
+  /* No threads use this stream.  */
+  __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
   memcpy (&ghdr.cookie[0], GMON_MAGIC, 4);
   memcpy (&ghdr.version, &version, sizeof (version));
   fwrite_unlocked (&ghdr, sizeof (ghdr), 1, fp);
index 3e3fd98da11bc07436ed080228fa7a464d9b9cbd..9cedbb840692d97c947c356205221f8f301fb387 100644 (file)
@@ -25,6 +25,7 @@
 #include <search.h>
 #include <stddef.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -358,6 +359,9 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
   if (fp == NULL)
     return;
 
+  /* No threads reading from this stream.  */
+  __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
   /* Process the known entries of the file.  Comments start with `#' and
      end with the end of the line.  Empty lines are ignored.  */
   while (!feof_unlocked (fp))
index b240c8d263c0f9844f9e44a253c36a1cbfe9566a..de00bfaf1332013e2b3833435278f70f58bd7e2a 100644 (file)
@@ -75,6 +75,7 @@ static char sccsid[] = "@(#)rcmd.c    8.3 (Berkeley) 3/26/94";
 #include <pwd.h>
 #include <errno.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <ctype.h>
 #include <string.h>
 #include <libintl.h>
@@ -437,6 +438,9 @@ iruserfopen (const char *file, uid_t okuser)
       return NULL;
     }
 
+  /* No threads use this stream.  */
+  __fsetlocking (res, FSETLOCKING_BYCALLER);
+
   return res;
 }
 
index d610f4240d1cac575d8bc7a65c6ae4b6c655317c..020733fc538170fee275d89e4292301d38cdfc25 100644 (file)
@@ -39,6 +39,7 @@ static char sccsid[] = "@(#)ruserpass.c       8.3 (Berkeley) 4/2/94";
 #include <errno.h>
 #include <netdb.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -119,6 +120,8 @@ ruserpass(host, aname, apass)
                        warn("%s", buf);
                return (0);
        }
+       /* No threads use this stream.  */
+       __fsetlocking (cfile, FSETLOCKING_BYCALLER);
        if (__gethostname(myname, sizeof(myname)) < 0)
                myname[0] = '\0';
        mydomain = __strchrnul(myname, '.');
index 381264ba03504d9206b50bb24e51476ac08f3c6e..122b5807f927e6479af8622e1db90420478c87ac 100644 (file)
@@ -30,6 +30,9 @@
 
 #include <ctype.h>
 #include <stdio.h>
+#if defined _LIBC || defined HAVE___FSETLOCKING
+# include <stdio_ext.h>
+#endif
 #include <sys/types.h>
 
 #ifdef __GNUC__
@@ -88,6 +91,7 @@ void free ();
 #  define mempcpy __mempcpy
 # endif
 # define HAVE_MEMPCPY  1
+# define HAVE___FSETLOCKING    1
 
 /* We need locking here since we can be called from different places.  */
 # include <bits/libc-lock.h>
@@ -99,6 +103,15 @@ __libc_lock_define_initialized (static, lock);
 # define internal_function
 #endif
 
+/* Some optimizations for glibc.  */
+#ifdef _LIBC
+# define FEOF(fp)              feof_unlocked (fp)
+# define FGETS(buf, n, fp)     fgets_unlocked (buf, n, fp)
+#else
+# define FEOF(fp)              feof (fp)
+# define FGETS(buf, n, fp)     fgets (buf, n, fp)
+#endif
+
 /* For those losing systems which don't have `alloca' we have to add
    some additional code emulating it.  */
 #ifdef HAVE_ALLOCA
@@ -228,8 +241,13 @@ read_alias_file (fname, fname_len)
   if (fp == NULL)
     return 0;
 
+#ifdef HAVE___FSETLOCKING
+  /* No threads present.  */
+  __fsetlocking (fp, FSETLOCKING_BYCALLER);
+#endif
+
   added = 0;
-  while (!feof (fp))
+  while (!FEOF (fp))
     {
       /* It is a reasonable approach to use a fix buffer here because
         a) we are only interested in the first two fields
@@ -241,7 +259,7 @@ read_alias_file (fname, fname_len)
       char *value;
       char *cp;
 
-      if (fgets (buf, sizeof buf, fp) == NULL)
+      if (FGETS (buf, sizeof buf, fp) == NULL)
        /* EOF reached.  */
        break;
 
@@ -251,7 +269,7 @@ read_alias_file (fname, fname_len)
        {
          char altbuf[BUFSIZ];
          do
-           if (fgets (altbuf, sizeof altbuf, fp) == NULL)
+           if (FGETS (altbuf, sizeof altbuf, fp) == NULL)
              /* Make sure the inner loop will be left.  The outer loop
                 will exit at the `feof' test.  */
              break;
index 2af6b989d4742cfcb0addffc9feb65777c9215dc..e9bd88903a14a6b18673af6acea01aa0fb81f6ba 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,93,94,95,96,97,98,99 Free Software Foundation, Inc.
+/* Copyright (C) 1992,93,94,95,96,97,98,99,2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,6 +17,7 @@
    02111-1307 USA.  */
 
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <termios.h>
 #include <unistd.h>
 
@@ -55,7 +56,12 @@ getpass (prompt)
       out = stderr;
     }
   else
-    out = in;
+    {
+      /* We do the locking ourselves.  */
+      __fsetlocking (tf, FSETLOCKING_BYCALLER);
+
+      out = in;
+    }
 
   flockfile (out);
 
index 3295a6edac1ef19f62fed7e3ecbe33b617fc468b..dfc57d5ce880c6f7c5a1a1f48c79075e6b5bd7f9 100644 (file)
@@ -33,6 +33,7 @@ static char sccsid[] = "@(#)getttyent.c       8.1 (Berkeley) 6/4/93";
 
 #include <ttyent.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <ctype.h>
 #include <string.h>
 
@@ -190,8 +191,11 @@ setttyent()
        if (tf) {
                (void)rewind(tf);
                return (1);
-       } else if ((tf = fopen(_PATH_TTYS, "r")))
+       } else if ((tf = fopen(_PATH_TTYS, "r"))) {
+               /* We do the locking ourselves.  */
+               __fsetlocking (tf, FSETLOCKING_BYCALLER);
                return (1);
+       }
        return (0);
 }
 
index 5ac08ce7f87085b643b6377c0c62a56a567024b3..c15b8f664fed8748af951193ac9b87198a0071cb 100644 (file)
@@ -35,6 +35,7 @@ static char sccsid[] = "@(#)getusershell.c    8.1 (Berkeley) 6/4/93";
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -116,6 +117,8 @@ initshells()
                strings = NULL;
                return (char **) okshells;
        }
+       /* No threads using this stream.  */
+       __fsetlocking (fp, FSETLOCKING_BYCALLER);
        sp = shells;
        cp = strings;
        flen = statb.st_size;
index e77b06ca1340f949491173737d82e71c27770091..7d86626fb505f54014937c1effd06a76eadf24ef 100644 (file)
@@ -1,5 +1,5 @@
 /* Utilities for reading/writing fstab, mtab, etc.
-   Copyright (C) 1995,1996,1997,1998,1999,2000 Free Software Foundation, Inc.
+   Copyright (C) 1995-2000, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -20,6 +20,7 @@
 #include <alloca.h>
 #include <mntent.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <string.h>
 #include <sys/types.h>
 
 FILE *
 __setmntent (const char *file, const char *mode)
 {
-  return fopen (file, mode);
+  FILE *result = fopen (file, mode);
+
+  if (result != NULL)
+    /* We do the locking ourselves.  */
+    __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
+  return result;
 }
 weak_alias (__setmntent, setmntent)
 
index f6d398867574b876dda50827184cb7e0bf80923e..77992816957e0bcfe0356afcb6e1a9c5b1ba08c6 100644 (file)
@@ -24,6 +24,7 @@
 #include <bits/libc-lock.h>
 #include <search.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -427,6 +428,9 @@ nss_parse_file (const char *fname)
   if (fp == NULL)
     return NULL;
 
+  /* No threads use this stream.  */
+  __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
   result = (name_database *) malloc (sizeof (name_database));
   if (result == NULL)
     return NULL;
index 50e49830f524ae91bf268caa60d2e6456b597ba8..ab97e39554cdb8cf36975ae8c9ddb1233b4f29e0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1993,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by David Mosberger (davidm@azstarnet.com).
 
@@ -33,6 +33,7 @@
 #include <ctype.h>
 #include <memory.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
 #include <net/if.h>
@@ -338,6 +339,9 @@ _res_hconf_init (void)
     _res_hconf.service[_res_hconf.num_services++] = SERVICE_BIND;
   else
     {
+      /* No threads using this stream.  */
+      __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
       while (fgets_unlocked (buf, sizeof (buf), fp))
        {
          ++line_num;
index 1b14f94e762e0b8d99ecfa870e6cb1ee800d8e70..bb66b02b6c16c822a58e6d09f34b2a524b5dd749 100644 (file)
@@ -81,6 +81,7 @@ static const char rcsid[] = "$BINDId: res_init.c,v 8.16 2000/05/09 07:10:12 vixi
 #include <ctype.h>
 #include <resolv.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -226,6 +227,8 @@ __res_vinit(res_state statp, int preinit) {
         line[sizeof(name) - 1] == '\t'))
 
        if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
+               /* No threads use this stream.  */
+               __fsetlocking (fp, FSETLOCKING_BYCALLER);
            /* read the config file */
            while (fgets_unlocked(buf, sizeof(buf), fp) != NULL) {
                /* skip comments */
index 08d676200df87c3e0eeb1efd732dd178fc4398ef..bf39bd9661d839caf5c2b4a592973e6e3cc267f2 100644 (file)
@@ -24,6 +24,7 @@
 #include <mntent.h>
 #include <paths.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -151,6 +152,8 @@ __get_nprocs ()
       fp = fopen (proc_cpuinfo, "r");
       if (fp != NULL)
        {
+         /* No threads use this stream.  */
+         __fsetlocking (fp, FSETLOCKING_BYCALLER);
          GET_NPROCS_PARSER (fp, buffer, result);
          fclose (fp);
        }
@@ -186,6 +189,8 @@ __get_nprocs_conf ()
       fp = fopen (proc_cpuinfo, "r");
       if (fp != NULL)
        {
+         /* No threads use this stream.  */
+         __fsetlocking (fp, FSETLOCKING_BYCALLER);
          GET_NPROCS_CONF_PARSER (fp, buffer, result);
          fclose (fp);
        }
@@ -224,6 +229,9 @@ phys_pages_info (const char *format)
       fp = fopen (proc_meminfo, "r");
       if (fp != NULL)
        {
+         /* No threads use this stream.  */
+         __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
          result = 0;
          /* Read all lines and count the lines starting with the
             string "processor".  We don't have to fear extremely long
index ad07c8ddca11ddf768b9fd699ec229a9002e15b1..8ed293cd5f34429a8d0e43cc32394bb5e815ecd2 100644 (file)
@@ -1,5 +1,5 @@
 /* Convert a string representation of time to a time value.
-   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
 
@@ -20,6 +20,7 @@
 
 #include <limits.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -132,6 +133,9 @@ __getdate_r (const char *string, struct tm *tp)
   if (fp == NULL)
     return 2;
 
+  /* No threads reading this stream.  */
+  __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
   line = NULL;
   len = 0;
   do
index d99707e71e41f57b779d300be8c5630162b5eaf6..5c2b28d582bf485920bf5a669b2f6d5041d9d968 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,93,95,96,97,98,99,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993, 1995-2000, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,6 +19,7 @@
 #include <assert.h>
 #include <limits.h>
 #include <stdio.h>
+#include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -150,6 +151,9 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
   if (f == NULL)
     return;
 
+  /* No threads reading this stream.  */
+  __fsetlocking (f, FSETLOCKING_BYCALLER);
+
   if (fread_unlocked ((void *) &tzhead, sizeof (tzhead), 1, f) != 1)
     goto lose;