aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-07-17 08:32:35 +0000
committerUlrich Drepper <drepper@redhat.com>2001-07-17 08:32:35 +0000
commit2706ee382341eb1c2e5f96c7d90f346696dbd0d8 (patch)
treec29690519bcb43604d9e0affa936aa7a2798660a
parent23700036397721389b90ac41571d68df2f26ad67 (diff)
downloadglibc-2706ee382341eb1c2e5f96c7d90f346696dbd0d8.tar
glibc-2706ee382341eb1c2e5f96c7d90f346696dbd0d8.tar.gz
glibc-2706ee382341eb1c2e5f96c7d90f346696dbd0d8.tar.bz2
glibc-2706ee382341eb1c2e5f96c7d90f346696dbd0d8.zip
Update.
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.
-rw-r--r--ChangeLog22
-rw-r--r--gmon/bb_exit_func.c6
-rw-r--r--iconv/gconv_conf.c4
-rw-r--r--inet/rcmd.c4
-rw-r--r--inet/ruserpass.c3
-rw-r--r--intl/localealias.c24
-rw-r--r--misc/getpass.c10
-rw-r--r--misc/getttyent.c6
-rw-r--r--misc/getusershell.c3
-rw-r--r--misc/mntent_r.c11
-rw-r--r--nss/nsswitch.c4
-rw-r--r--resolv/res_hconf.c6
-rw-r--r--resolv/res_init.c3
-rw-r--r--sysdeps/unix/sysv/linux/getsysstats.c8
-rw-r--r--time/getdate.c6
-rw-r--r--time/tzfile.c6
16 files changed, 114 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 4588974ae3..0ae1ff2cad 100644
--- 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
diff --git a/gmon/bb_exit_func.c b/gmon/bb_exit_func.c
index 90a6701989..ce61c75d6e 100644
--- a/gmon/bb_exit_func.c
+++ b/gmon/bb_exit_func.c
@@ -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);
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 3e3fd98da1..9cedbb8406 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -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))
diff --git a/inet/rcmd.c b/inet/rcmd.c
index b240c8d263..de00bfaf13 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -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;
}
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index d610f4240d..020733fc53 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -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, '.');
diff --git a/intl/localealias.c b/intl/localealias.c
index 381264ba03..122b5807f9 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -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;
diff --git a/misc/getpass.c b/misc/getpass.c
index 2af6b989d4..e9bd88903a 100644
--- a/misc/getpass.c
+++ b/misc/getpass.c
@@ -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);
diff --git a/misc/getttyent.c b/misc/getttyent.c
index 3295a6edac..dfc57d5ce8 100644
--- a/misc/getttyent.c
+++ b/misc/getttyent.c
@@ -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);
}
diff --git a/misc/getusershell.c b/misc/getusershell.c
index 5ac08ce7f8..c15b8f664f 100644
--- a/misc/getusershell.c
+++ b/misc/getusershell.c
@@ -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;
diff --git a/misc/mntent_r.c b/misc/mntent_r.c
index e77b06ca13..7d86626fb5 100644
--- a/misc/mntent_r.c
+++ b/misc/mntent_r.c
@@ -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>
@@ -33,7 +34,13 @@
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)
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index f6d3988675..7799281695 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -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;
diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c
index 50e49830f5..ab97e39554 100644
--- a/resolv/res_hconf.c
+++ b/resolv/res_hconf.c
@@ -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;
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 1b14f94e76..bb66b02b6c 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -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 */
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 08d676200d..bf39bd9661 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -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
diff --git a/time/getdate.c b/time/getdate.c
index ad07c8ddca..8ed293cd5f 100644
--- a/time/getdate.c
+++ b/time/getdate.c
@@ -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
diff --git a/time/tzfile.c b/time/tzfile.c
index d99707e71e..5c2b28d582 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -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;