diff libinterp/corefcn/dynamic-ld.cc @ 23554:b075b1629c26

don't use hook function in dynamic_library::dynlib_rep::close function * oct-shlib.h, oct-shlib.cc (dynamic_library::dynlib_rep::function_names): New function. (dynamic_library::dynlib_rep::clear_fcn_names)): New function. (dynamic_library::dynlib_rep::do_close_hook): Delete. (dynamic_library::close): Return list of function names instead of calling close_hook function on each function name. * dynamic-ld.h, dynamic-ld.cc (dynamic_loader::shlibs_list::remove): Return list of removed functions instead of passing close_hook function to the shared-library close function. (dynamic_loader::do_clear): Clear functions removed from dynamically loaded library here.
author John W. Eaton <jwe@octave.org>
date Fri, 02 Jun 2017 09:16:02 -0400
parents 5da300c55e89
children 5cb3a2bb5e1e
line wrap: on
line diff
--- a/libinterp/corefcn/dynamic-ld.cc	Wed Jun 07 02:13:05 2017 -0400
+++ b/libinterp/corefcn/dynamic-ld.cc	Fri Jun 02 09:16:02 2017 -0400
@@ -54,23 +54,24 @@
     lib_list.push_back (shl);
   }
 
-  void
-  dynamic_loader::shlibs_list::remove (dynamic_library& shl,
-                                       dynamic_library::close_hook cl_hook)
+  std::list<std::string>
+  dynamic_loader::shlibs_list::remove (dynamic_library& shl)
   {
+    std::list<std::string> removed_fcns;
+
     for (iterator p = lib_list.begin (); p != lib_list.end (); p++)
       {
         if (*p == shl)
           {
-            // Erase first to avoid potentially invalidating the pointer by the
-            // following hooks.
             lib_list.erase (p);
 
-            shl.close (cl_hook);
+            removed_fcns = shl.close ();
 
             break;
           }
       }
+
+    return removed_fcns;
   }
 
   dynamic_library
@@ -138,10 +139,18 @@
                          "reloading %s clears the following functions:",
                          oct_file.file_name ().c_str ());
 
-        loaded_shlibs.remove (oct_file, do_clear_function);
+        std::list<std::string> removed_fcns = loaded_shlibs.remove (oct_file);
+
+        for (const auto& fcn_name : removed_fcns)
+          do_clear_function (fcn_name);
       }
     else
-      loaded_shlibs.remove (oct_file, symbol_table::clear_dld_function);
+      {
+        std::list<std::string> removed_fcns = loaded_shlibs.remove (oct_file);
+
+        for (const auto& fcn_name : removed_fcns)
+          symbol_table::clear_dld_function (fcn_name);
+      }
   }
 
   octave_function *