This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
gold patch committed: Fix descriptor handling
- From: Ian Lance Taylor <iant at google dot com>
- To: binutils at sourceware dot org
- Date: Fri, 27 Feb 2009 19:06:06 -0800
- Subject: gold patch committed: Fix descriptor handling
I managed to mess up the simple-minded stack of open file descriptors in
gold. I committed this patch to make it slightly less simple-minded.
Ian
2009-02-27 Ian Lance Taylor <iant@google.com>
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.
Index: descriptors.cc
===================================================================
RCS file: /cvs/src/src/gold/descriptors.cc,v
retrieving revision 1.3
diff -p -u -r1.3 descriptors.cc
--- descriptors.cc 15 Jan 2009 01:29:25 -0000 1.3
+++ descriptors.cc 28 Feb 2009 03:01:33 -0000
@@ -75,6 +75,12 @@ Descriptors::open(int descriptor, const
{
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
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, boo
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;
Index: descriptors.h
===================================================================
RCS file: /cvs/src/src/gold/descriptors.h,v
retrieving revision 1.3
diff -p -u -r1.3 descriptors.h
--- descriptors.h 15 Jan 2009 01:29:25 -0000 1.3
+++ descriptors.h 28 Feb 2009 03:01:33 -0000
@@ -69,6 +69,8 @@ class Descriptors
bool inuse;
// Whether this is a write descriptor.
bool is_write;
+ // Whether the descriptor is on the stack.
+ bool is_on_stack;
};
bool