aboutsummaryrefslogtreecommitdiff
path: root/gold/descriptors.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2009-02-28 03:05:08 +0000
committerIan Lance Taylor <ian@airs.com>2009-02-28 03:05:08 +0000
commit61edd21fa41ccf31fe391ee320c4812c4d45486a (patch)
treec255bd0ec7a6fad35fcdba6b8b61760626d8fd69 /gold/descriptors.cc
parente29e076ab80ed58ab0343c9910e02df7220233f8 (diff)
downloadfsf-binutils-gdb-61edd21fa41ccf31fe391ee320c4812c4d45486a.zip
fsf-binutils-gdb-61edd21fa41ccf31fe391ee320c4812c4d45486a.tar.gz
fsf-binutils-gdb-61edd21fa41ccf31fe391ee320c4812c4d45486a.tar.bz2
PR 5990
* descriptors.h (Open_descriptor): Add is_on_stack field. * descriptors.cc (Descriptors::open): If the descriptor is on the top of the stack, remove it. Initialize is_on_stack field. (Descriptors::release): Only add pod to stack if it is not on the stack already. (Descriptors::close_some_descriptor): Clear stack_next and is_on_stack fields.
Diffstat (limited to 'gold/descriptors.cc')
-rw-r--r--gold/descriptors.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/gold/descriptors.cc b/gold/descriptors.cc
index 18498ef..862edae 100644
--- a/gold/descriptors.cc
+++ b/gold/descriptors.cc
@@ -75,6 +75,12 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
{
gold_assert(!pod->inuse);
pod->inuse = true;
+ if (descriptor == this->stack_top_)
+ {
+ this->stack_top_ = pod->stack_next;
+ pod->stack_next = -1;
+ pod->is_on_stack = false;
+ }
return descriptor;
}
}
@@ -114,6 +120,7 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
pod->stack_next = -1;
pod->inuse = true;
pod->is_write = (flags & O_ACCMODE) != O_RDONLY;
+ pod->is_on_stack = false;
++this->current_;
if (this->current_ >= this->limit_)
@@ -158,10 +165,11 @@ Descriptors::release(int descriptor, bool permanent)
else
{
pod->inuse = false;
- if (!pod->is_write)
+ if (!pod->is_write && !pod->is_on_stack)
{
pod->stack_next = this->stack_top_;
this->stack_top_ = descriptor;
+ pod->is_on_stack = true;
}
}
}
@@ -193,6 +201,8 @@ Descriptors::close_some_descriptor()
this->stack_top_ = pod->stack_next;
else
this->open_descriptors_[last].stack_next = pod->stack_next;
+ pod->stack_next = -1;
+ pod->is_on_stack = false;
return true;
}
last = i;