mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 08:11:08 +00:00
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.
This commit is contained in:
parent
3afd949152
commit
beafb7521f
@ -1,5 +1,12 @@
|
|||||||
2001-07-23 Ulrich Drepper <drepper@redhat.com>
|
2001-07-23 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
* libio/genops.c (_IO_list_all_stamp): New variable.
|
* libio/genops.c (_IO_list_all_stamp): New variable.
|
||||||
(_IO_un_link): Bump _IO_list_all_stamp after removing from list.
|
(_IO_un_link): Bump _IO_list_all_stamp after removing from list.
|
||||||
(_IO_link): Likewise for insertion.
|
(_IO_link): Likewise for insertion.
|
||||||
|
@ -40,6 +40,17 @@ static _IO_lock_t list_all_lock = _IO_lock_initializer;
|
|||||||
/* Used to signal modifications to the list of FILE decriptors. */
|
/* Used to signal modifications to the list of FILE decriptors. */
|
||||||
static int _IO_list_all_stamp;
|
static int _IO_list_all_stamp;
|
||||||
|
|
||||||
|
|
||||||
|
static _IO_FILE *run_fp;
|
||||||
|
|
||||||
|
static void
|
||||||
|
flush_cleanup (void *not_used)
|
||||||
|
{
|
||||||
|
if (run_fp != NULL)
|
||||||
|
_IO_funlockfile (run_fp);
|
||||||
|
_IO_lock_unlock (list_all_lock);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_IO_un_link (fp)
|
_IO_un_link (fp)
|
||||||
struct _IO_FILE_plus *fp;
|
struct _IO_FILE_plus *fp;
|
||||||
@ -48,7 +59,10 @@ _IO_un_link (fp)
|
|||||||
{
|
{
|
||||||
struct _IO_FILE_plus **f;
|
struct _IO_FILE_plus **f;
|
||||||
#ifdef _IO_MTSAFE_IO
|
#ifdef _IO_MTSAFE_IO
|
||||||
|
_IO_cleanup_region_start_noarg (flush_cleanup);
|
||||||
_IO_lock_lock (list_all_lock);
|
_IO_lock_lock (list_all_lock);
|
||||||
|
run_fp = (_IO_FILE *) fp;
|
||||||
|
_IO_flockfile ((_IO_FILE *) fp);
|
||||||
#endif
|
#endif
|
||||||
for (f = &_IO_list_all; *f; f = (struct _IO_FILE_plus **) &(*f)->file._chain)
|
for (f = &_IO_list_all; *f; f = (struct _IO_FILE_plus **) &(*f)->file._chain)
|
||||||
{
|
{
|
||||||
@ -59,10 +73,13 @@ _IO_un_link (fp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef _IO_MTSAFE_IO
|
|
||||||
_IO_lock_unlock (list_all_lock);
|
|
||||||
#endif
|
|
||||||
fp->file._flags &= ~_IO_LINKED;
|
fp->file._flags &= ~_IO_LINKED;
|
||||||
|
#ifdef _IO_MTSAFE_IO
|
||||||
|
_IO_funlockfile ((_IO_FILE *) fp);
|
||||||
|
run_fp = NULL;
|
||||||
|
_IO_lock_unlock (list_all_lock);
|
||||||
|
_IO_cleanup_region_end (0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,13 +91,19 @@ _IO_link_in (fp)
|
|||||||
{
|
{
|
||||||
fp->file._flags |= _IO_LINKED;
|
fp->file._flags |= _IO_LINKED;
|
||||||
#ifdef _IO_MTSAFE_IO
|
#ifdef _IO_MTSAFE_IO
|
||||||
|
_IO_cleanup_region_start_noarg (flush_cleanup);
|
||||||
_IO_lock_lock (list_all_lock);
|
_IO_lock_lock (list_all_lock);
|
||||||
|
run_fp = (_IO_FILE *) fp;
|
||||||
|
_IO_flockfile ((_IO_FILE *) fp);
|
||||||
#endif
|
#endif
|
||||||
fp->file._chain = (_IO_FILE *) _IO_list_all;
|
fp->file._chain = (_IO_FILE *) _IO_list_all;
|
||||||
_IO_list_all = fp;
|
_IO_list_all = fp;
|
||||||
++_IO_list_all_stamp;
|
++_IO_list_all_stamp;
|
||||||
#ifdef _IO_MTSAFE_IO
|
#ifdef _IO_MTSAFE_IO
|
||||||
|
_IO_funlockfile ((_IO_FILE *) fp);
|
||||||
|
run_fp = NULL;
|
||||||
_IO_lock_unlock (list_all_lock);
|
_IO_lock_unlock (list_all_lock);
|
||||||
|
_IO_cleanup_region_end (0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -756,17 +779,6 @@ _IO_get_column (fp)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static _IO_FILE *run_fp;
|
|
||||||
|
|
||||||
static void
|
|
||||||
flush_cleanup (void *not_used)
|
|
||||||
{
|
|
||||||
if (run_fp != NULL)
|
|
||||||
_IO_funlockfile (run_fp);
|
|
||||||
_IO_lock_unlock (list_all_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
_IO_flush_all ()
|
_IO_flush_all ()
|
||||||
{
|
{
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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);
|
return _IO_old_fclose (fp);
|
||||||
#endif
|
#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_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
|
||||||
_IO_flockfile (fp);
|
_IO_flockfile (fp);
|
||||||
if (fp->_IO_file_flags & _IO_IS_FILEBUF)
|
if (fp->_IO_file_flags & _IO_IS_FILEBUF)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1993,1995,1997,1998,1999,2000 Free Software Foundation, Inc.
|
/* Copyright (C) 1993, 1995, 1997-2000, 2001 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -48,6 +48,10 @@ _IO_old_fclose (fp)
|
|||||||
if (fp->_vtable_offset == 0)
|
if (fp->_vtable_offset == 0)
|
||||||
return _IO_new_fclose (fp);
|
return _IO_new_fclose (fp);
|
||||||
|
|
||||||
|
/* 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 (*) (void *)) _IO_funlockfile, fp);
|
_IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, fp);
|
||||||
_IO_flockfile (fp);
|
_IO_flockfile (fp);
|
||||||
if (fp->_IO_file_flags & _IO_IS_FILEBUF)
|
if (fp->_IO_file_flags & _IO_IS_FILEBUF)
|
||||||
|
Loading…
Reference in New Issue
Block a user