Add asserts to check for file descriptor ring corruption.
This commit is contained in:
parent
4a5135c34e
commit
634b38aa86
@ -6,7 +6,7 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Id: fd.c,v 1.10 1996/12/04 03:05:58 bryanh Exp $
|
||||
* $Id: fd.c,v 1.11 1996/12/27 22:57:51 bryanh Exp $
|
||||
*
|
||||
* NOTES:
|
||||
*
|
||||
@ -169,7 +169,9 @@ static char Sep_char = '\\';
|
||||
* AssertLruRoom - make sure that there is a free fd.
|
||||
*
|
||||
* the Last Recently Used ring is a doubly linked list that begins and
|
||||
* ends on element zero.
|
||||
* ends on element zero. Element zero is special -- it doesn't represent
|
||||
* a file and its "fd" field always == VFD_CLOSED. Element zero is just an
|
||||
* anchor that shows us the beginning/end of the ring.
|
||||
*
|
||||
* example:
|
||||
*
|
||||
@ -373,6 +375,10 @@ AssertLruRoom()
|
||||
FreeFd));
|
||||
|
||||
if (FreeFd <= 0 || nfile >= MAXFILES) {
|
||||
/* We supposedly are using more vfds than we want to be. First
|
||||
assert that there is at least one used vfd in the ring.
|
||||
*/
|
||||
Assert(VfdCache[0].lruMoreRecently ! 0);
|
||||
LruDelete(VfdCache[0].lruMoreRecently);
|
||||
}
|
||||
}
|
||||
@ -521,6 +527,7 @@ FileAccess(File file)
|
||||
void
|
||||
FileInvalidate(File file)
|
||||
{
|
||||
Assert(file > 0);
|
||||
if (!FileIsNotOpen(file)) {
|
||||
LruDelete(file);
|
||||
}
|
||||
@ -879,7 +886,8 @@ void
|
||||
closeAllVfds()
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<SizeVfdCache; i++) {
|
||||
Assert (FileIsNotOpen(0)); /* Make sure ring not corrupted */
|
||||
for (i=1; i<SizeVfdCache; i++) {
|
||||
if (!FileIsNotOpen(i))
|
||||
LruDelete(i);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user