be slightly stricter on when to load a module
This commit is contained in:
@@ -6,6 +6,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED)
|
set(CMAKE_C_STANDARD_REQUIRED)
|
||||||
|
|
||||||
|
set(BUILD_AUDITOR OFF)
|
||||||
|
set(BUILD_TESTS OFF)
|
||||||
|
|
||||||
# Conditionally define _GNU_SOURCE for Linux systems
|
# Conditionally define _GNU_SOURCE for Linux systems
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
# This checks for Linux (UNIX but not macOS)
|
# This checks for Linux (UNIX but not macOS)
|
||||||
@@ -71,12 +74,15 @@ install(EXPORT hiloadTargets
|
|||||||
|
|
||||||
export(TARGETS hiload FILE hiloadConfig.cmake)
|
export(TARGETS hiload FILE hiloadConfig.cmake)
|
||||||
|
|
||||||
|
|
||||||
|
if (BUILD_AUDITOR)
|
||||||
# Auditor libraries
|
# Auditor libraries
|
||||||
# ###############
|
# ###############
|
||||||
|
|
||||||
# TODO: Move auditor to its own project, possibly even out of this repo.
|
# TODO: Move auditor to its own project, possibly even out of this repo.
|
||||||
# It has only been a side product
|
# It has only been a side product
|
||||||
|
|
||||||
|
|
||||||
add_library(auditor-x86_64 SHARED
|
add_library(auditor-x86_64 SHARED
|
||||||
solib-auditors/auditor-x86_64.c
|
solib-auditors/auditor-x86_64.c
|
||||||
)
|
)
|
||||||
@@ -95,7 +101,13 @@ install(TARGETS auditor-x86_64
|
|||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
)
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
# tests and test projects
|
# tests and test projects
|
||||||
# #######################
|
# #######################
|
||||||
|
|
||||||
|
if (BUILD_TESTS)
|
||||||
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|||||||
15
src/hiload.c
15
src/hiload.c
@@ -1,6 +1,7 @@
|
|||||||
#include "hiload.h"
|
#include "hiload.h"
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "filewatcher/filewatch_type.h"
|
||||||
#include "filewatcher/filewatcher.h"
|
#include "filewatcher/filewatcher.h"
|
||||||
#include "histring.h"
|
#include "histring.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
@@ -178,11 +179,13 @@ static void handle_file_events(FileWatcher *fw, VectorModuleData *modules) {
|
|||||||
log_debug("Event pop: %s – %s\n", event.pathname,
|
log_debug("Event pop: %s – %s\n", event.pathname,
|
||||||
filewatch_type_to_str(event.type));
|
filewatch_type_to_str(event.type));
|
||||||
|
|
||||||
ModuleData *module = module_get(event.pathname, modules);
|
if (event.type == HI_FILE_CHANGE || event.type == HI_FILE_CREATE) {
|
||||||
if (!module) {
|
ModuleData *module = module_get(event.pathname, modules);
|
||||||
log_warn("Watched module: %s not found.\n", event.pathname);
|
if (!module) {
|
||||||
} else {
|
log_warn("Watched module: %s not found.\n", event.pathname);
|
||||||
module->info = modinfo_add(module->info, HI_MODULE_STATE_DIRTY);
|
} else {
|
||||||
|
module->info = modinfo_add(module->info, HI_MODULE_STATE_DIRTY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
event = filewatcher_event_pop(context.filewatcher);
|
event = filewatcher_event_pop(context.filewatcher);
|
||||||
}
|
}
|
||||||
@@ -215,7 +218,7 @@ int hi_init(size_t n, const char **enabled_modules) {
|
|||||||
fprintf(stderr, "Failed to init logger.\n");
|
fprintf(stderr, "Failed to init logger.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
log_set_level("WARNING");
|
log_set_level("DEBUG");
|
||||||
log_set_thread_name("Hiload");
|
log_set_thread_name("Hiload");
|
||||||
|
|
||||||
// Start the filewatcher
|
// Start the filewatcher
|
||||||
|
|||||||
@@ -338,8 +338,7 @@ HiResult moduler_reload(VectorModuleData *modules, size_t modindx) {
|
|||||||
log_debug("Opening patch: %s\n", patch.filename);
|
log_debug("Opening patch: %s\n", patch.filename);
|
||||||
void *new_handle = dlopen(patch.filename, RTLD_LAZY);
|
void *new_handle = dlopen(patch.filename, RTLD_LAZY);
|
||||||
if (!new_handle) {
|
if (!new_handle) {
|
||||||
log_error("Couldn't load: %s\n", dlerror());
|
log_errorv("Couldn't load: %s\n", dlerror());
|
||||||
module->info = modinfo_clear(module->info, HI_MODULE_STATE_DIRTY);
|
|
||||||
return HI_FAIL;
|
return HI_FAIL;
|
||||||
}
|
}
|
||||||
patch.dlhandle = new_handle;
|
patch.dlhandle = new_handle;
|
||||||
|
|||||||
Reference in New Issue
Block a user