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.
This commit is contained in:
Ulrich Drepper 2001-07-17 08:32:35 +00:00
parent 2370003639
commit 2706ee3823
16 changed files with 114 additions and 12 deletions

View File

@ -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

View 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);

View 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))

View 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;
}

View 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, '.');

View 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;

View 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);

View 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);
}

View 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;

View 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>
@ -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)

View 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;

View 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;

View 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 */

View 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

View 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

View 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;