about summary refs log tree commit diff
path: root/libio/iofclose.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-07-24 04:22:05 +0000
committerUlrich Drepper <drepper@redhat.com>2001-07-24 04:22:05 +0000
commitbeafb7521f1ce231fa3ac799cdedd361b3469886 (patch)
tree46a7a5d6f8173cf7ce74f5fe99f9b70ceabf88d9 /libio/iofclose.c
parent3afd949152e8d72708f9f430855c6e71595df78b (diff)
downloadglibc-beafb7521f1ce231fa3ac799cdedd361b3469886.tar.gz
glibc-beafb7521f1ce231fa3ac799cdedd361b3469886.tar.xz
glibc-beafb7521f1ce231fa3ac799cdedd361b3469886.zip
Update.
	* libio/iofclose.c (_IO_new_fclose): Unlink descriptor first to
	avoid deadlock.
	* libio/oldiofclose.c (_IO_old_fclose): Likewise.
	* libio/genops.c (_IO_un_link): Get stream lock since it's not
	always done in the caller.
	(_IO_link_in): Likewise.
Diffstat (limited to 'libio/iofclose.c')
-rw-r--r--libio/iofclose.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libio/iofclose.c b/libio/iofclose.c
index bab0558d89..660c118359 100644
--- a/libio/iofclose.c
+++ b/libio/iofclose.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997-1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1993,1995,1997-1999,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
@@ -53,6 +53,10 @@ _IO_new_fclose (fp)
     return _IO_old_fclose (fp);
 #endif
 
+  /* First unlink the stream.  */
+  if (fp->_IO_file_flags & _IO_IS_FILEBUF)
+    _IO_un_link ((struct _IO_FILE_plus *) fp);
+
   _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
   _IO_flockfile (fp);
   if (fp->_IO_file_flags & _IO_IS_FILEBUF)