summaryrefslogtreecommitdiff
path: root/src/commands.c
diff options
context:
space:
mode:
authorDmitry Goncharov <dgoncharov@users.sf.net>2022-09-12 01:58:52 -0400
committerPaul Smith <psmith@gnu.org>2022-09-12 02:05:18 -0400
commitee861a4e9f523d06d26ed612ad1a93b6ecb408de (patch)
tree43e6d086d6d366bff448675c564ea85d60468c36 /src/commands.c
parentca4234c4b550618df2194e0617c43bb12524f820 (diff)
downloadmake-git-ee861a4e9f523d06d26ed612ad1a93b6ecb408de.tar.gz
[SV 63045] Reload each intact unloaded shared object
If makefile rules do not update an unloaded shared object, load it again. Avoid double loading of the same object if the setup function returns -1. * src/filedef.h (struct file): Add "unloaded" flag. * src/makeint.h (load_file): Take struct file *. (unload_file): Return int. * src/main.c (main): Reload unloaded shared objects if they weren't updated. * src/commands.c (execute_file_commands): Set "unloaded" and reset "loaded" when a shared object is unloaded. * src/read.c (eval): Set "loaded" and reset "unloaded" when a shared object is loaded. Add successfully loaded files to the db. * src/load.c (load_file): Check "loaded" to avoid double loading the same object. Fix a memory leak of string loaded. Return -1, rather than 1, if the object is already loaded. This fixes double loading of the same object when the setup routine returns -1. (load_object): Add a log message. (unload_file): Return an error on dlclose failure. Log a message. * tests/scripts/features/loadapi: Add new tests.
Diffstat (limited to 'src/commands.c')
-rw-r--r--src/commands.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/commands.c b/src/commands.c
index 3dd1953f..e7c0cc87 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -462,10 +462,15 @@ execute_file_commands (struct file *file)
set_file_variables (file, file->stem);
- /* If this is a loaded dynamic object, unload it before remaking.
- Some systems don't support overwriting a loaded object. */
- if (file->loaded)
- unload_file (file->name);
+ /* Some systems don't support overwriting a loaded object so if this one
+ unload it before remaking. Keep its name in .LOADED: it will be rebuilt
+ and loaded again. If rebuilding or loading again fail, then we'll exit
+ anyway and it won't matter. */
+ if (file->loaded && unload_file (file->name) == 0)
+ {
+ file->loaded = 0;
+ file->unloaded = 1;
+ }
/* Start the commands running. */
new_job (file);