aboutsummaryrefslogtreecommitdiff
path: root/gold/descriptors.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2013-02-11 16:12:59 +0000
committerIan Lance Taylor <ian@airs.com>2013-02-11 16:12:59 +0000
commit20e2a8aa3311d7c765e3fdcaab46dc5a11d266ff (patch)
tree47a9bcec45915e80de381862173b3f76d1e11be5 /gold/descriptors.cc
parent6fe6ded97b0524a0ebae0d3a1773403cb79e3540 (diff)
downloadfsf-binutils-gdb-20e2a8aa3311d7c765e3fdcaab46dc5a11d266ff.zip
fsf-binutils-gdb-20e2a8aa3311d7c765e3fdcaab46dc5a11d266ff.tar.gz
fsf-binutils-gdb-20e2a8aa3311d7c765e3fdcaab46dc5a11d266ff.tar.bz2
* descriptors.cc (Descriptors::close_all): New function.
* descriptors.h (class Descriptors): Declare close_all. (close_all_descriptors): New inline function. * plugin.cc: Include "descriptors.h". (Plugin_manager::cleanup): Call close_all_descriptors.
Diffstat (limited to 'gold/descriptors.cc')
-rw-r--r--gold/descriptors.cc24
1 files changed, 23 insertions, 1 deletions
diff --git a/gold/descriptors.cc b/gold/descriptors.cc
index f3f071e..b7fbaa6 100644
--- a/gold/descriptors.cc
+++ b/gold/descriptors.cc
@@ -1,6 +1,6 @@
// descriptors.cc -- manage file descriptors for gold
-// Copyright 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+// Copyright 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -251,6 +251,28 @@ Descriptors::close_some_descriptor()
return false;
}
+// Close all the descriptors open for reading.
+
+void
+Descriptors::close_all()
+{
+ Hold_optional_lock hl(this->lock_);
+
+ for (size_t i = 0; i < this->open_descriptors_.size(); i++)
+ {
+ Open_descriptor* pod = &this->open_descriptors_[i];
+ if (pod->name != NULL && !pod->inuse && !pod->is_write)
+ {
+ if (::close(i) < 0)
+ gold_warning(_("while closing %s: %s"), pod->name, strerror(errno));
+ pod->name = NULL;
+ pod->stack_next = -1;
+ pod->is_on_stack = false;
+ }
+ }
+ this->stack_top_ = -1;
+}
+
// The single global variable which manages descriptors.
Descriptors descriptors;