summaryrefslogtreecommitdiff
path: root/gold/descriptors.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gold/descriptors.cc')
-rw-r--r--gold/descriptors.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/gold/descriptors.cc b/gold/descriptors.cc
index 75a7a869c59..73c03bf4a45 100644
--- a/gold/descriptors.cc
+++ b/gold/descriptors.cc
@@ -115,7 +115,9 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
pod->inuse = true;
pod->is_write = (flags & O_ACCMODE) != O_RDONLY;
- ++this->current_;
+ if (!pod->is_claimed)
+ ++this->current_;
+ pod->is_claimed = false;
if (this->current_ >= this->limit_)
this->close_some_descriptor();
@@ -166,6 +168,24 @@ Descriptors::release(int descriptor, bool permanent)
}
}
+// Claim the file descriptor DESCRIPTOR for a plugin. This effectively
+// removes the descriptor from the pool of linker-managed descriptors,
+// as the plugin will assume responsibility for closing it.
+// The IS_CLAIMED flag allows us to recognize when a file descriptor
+// has been reused after being closed by the plugin.
+
+void
+Descriptors::claim_for_plugin(int descriptor)
+{
+ Hold_lock hl(*this->lock_);
+
+ gold_assert(descriptor >= 0
+ && (static_cast<size_t>(descriptor)
+ < this->open_descriptors_.size()));
+ Open_descriptor* pod = &this->open_descriptors_[descriptor];
+ pod->is_claimed = true;
+}
+
// Close some descriptor. The lock is held when this is called. We
// close the descriptor on the top of the free stack. Note that this
// is the opposite of an LRU algorithm--we close the most recently