This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gold patch RFC]: Release unused external member of thin archive


> Hi Cary, does this patch look correct to you? ?It explicitly unlocks an
> external member of a thin archive if the member is not used. ?That
> avoids locking up the descriptor and possibly eventually running out of
> descriptors. ?I don't have a test case, but it seems like the right
> thing. ?If this looks right to you, I'll commit it.

@@ -853,11 +853,7 @@ Archive::include_member(Symbol_table* sy
       && this->searched_for()
       && obj == NULL
       && unconfigured)
-    {
-      if (obj != NULL)
-	delete obj;
-      return false;
-    }
+    return false;

This was dead code anyway (the if condition explicitly tests for obj == NULL).

@@ -874,7 +870,13 @@ Archive::include_member(Symbol_table* sy
     }

   if (!input_objects->add_object(obj))
-    delete obj;
+    {
+      // If this is an external member of a thin archive, unlock the
+      // file.
+      if (obj->offset() == 0)
+	obj->unlock(this->task_);
+      delete obj;
+    }

This looks good. Why not do this in the Object destructor, though?

-cary


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]