diff --git a/src/filewatcher/filewatch.c b/src/filewatcher/filewatch.c index 1f4632e..da8f60c 100644 --- a/src/filewatcher/filewatch.c +++ b/src/filewatcher/filewatch.c @@ -133,17 +133,17 @@ HiloadResult file_watch_add(hiFileWatcherContext *ctx, u32 mask, } if (!has_mask(HI_FILE_PARENT, mask)) { - char *parent = get_parent_folder(path); - hiFileWatch *parent_watch = file_watch_find_by_path(ctx, parent, NULL); + char *parent_name = get_parent_folder(path); + hiFileWatch *parent_watch = file_watch_find_by_path(ctx, parent_name, NULL); if (!parent_watch) { // parent not yet watched - int wd = inotify_add_watch(ctx->fd, parent, params.parent_mask); - hiFileWatch wp = {.wd = wd, .mask = HI_FILE_PARENT, .path = parent}; + int wd = inotify_add_watch(ctx->fd, parent_name, params.parent_mask); + hiFileWatch wp = {.wd = wd, .mask = HI_FILE_PARENT, .path = parent_name}; sc_array_init(&wp.files); sc_array_add(&wp.files, strdup(watch->path)); sc_array_add(&ctx->watches, wp); } else { - free(parent); + free(parent_name); inotify_add_watch(ctx->fd, parent_watch->path, params.parent_mask); { // Make sure we don't add a duplicate if the file is already marked diff --git a/src/filewatcher/filewatcher.c b/src/filewatcher/filewatcher.c index 16c82e0..302ebc9 100644 --- a/src/filewatcher/filewatcher.c +++ b/src/filewatcher/filewatcher.c @@ -304,12 +304,14 @@ int file_watcher_watch(void *arg) { event = (const struct inotify_event *)ptr; hiFileEvent e = file_event_create(event, &ctx->context); - sc_array_add(&ctx->events, e); + if (e.type != HI_FILE_NONE) { + sc_array_add(&ctx->events, e); - if (event->len) { - sc_log_debug("Event created: queue-size: %u, %s %s\n", - sc_array_size(&ctx->events), e.pathname, - hi_file_watch_type_to_str(e.type)); + if (event->len) { + sc_log_debug("Event created: queue-size: %u, %s %s\n", + sc_array_size(&ctx->events), e.pathname, + hi_file_watch_type_to_str(e.type)); + } } } continue; // read again without waiting diff --git a/src/hiload.c b/src/hiload.c index 09063f5..e2160b5 100644 --- a/src/hiload.c +++ b/src/hiload.c @@ -42,6 +42,7 @@ static int gather_module_data_callback(struct dl_phdr_info *info, size_t size, assert(handle); HiModuleData module = {0}; + module.dlhandle = handle; module.address = info->dlpi_addr; log_debugv(" header size: %u\n", size); @@ -216,7 +217,7 @@ int hi_init(unsigned n, const char **enabled_modules) { } HiloadResult re = gather_module_infos(&context.modules); - if (re == HILOAD_OK) { + if (re != HILOAD_OK) { log_error("Failed to gather module infos.\n"); return 1; } diff --git a/src/moduler/moduler.c b/src/moduler/moduler.c index 99208c0..031618d 100644 --- a/src/moduler/moduler.c +++ b/src/moduler/moduler.c @@ -4,7 +4,6 @@ #include "memory.h" #include "moduler/elf.h" #include "types.h" -#include HiloadResult moduler_reload(HiModuleData *module, const struct sc_array_memreg *const memregs) { @@ -22,6 +21,8 @@ HiloadResult moduler_reload(HiModuleData *module, return HILOAD_FAIL; } + /* void *new_handle = dlopen(module->name, RTLD_NOW); */ + /* assert(new_handle != module->dlhandle); */ void *module_address = (void *)module->address; size_t phdrnum = 0; @@ -79,21 +80,19 @@ HiloadResult moduler_reload(HiModuleData *module, ++dyn; } log_debugv("\nstrtab: %p\n" - "symtab: %p\n" - "strsz: %zu\n" - "syment: %zu\n" - "rela: %p\n" - "relasz: %zu\n" - "relaent: %zu\n" - "relacount: %zu\n" - "pltgot: %p\n" - "pltrelsz: %zu\n" - "pltrel: %p\n", - strtab, symtab, strsz, syment, rela, relasz, relaent, relacount, - pltgot, pltrelsz, pltrel); + "symtab: %p\n" + "strsz: %zu\n" + "syment: %zu\n" + "rela: %p\n" + "relasz: %zu\n" + "relaent: %zu\n" + "relacount: %zu\n" + "pltgot: %p\n" + "pltrelsz: %zu\n" + "pltrel: %p\n", + strtab, symtab, strsz, syment, rela, relasz, relaent, + relacount, pltgot, pltrelsz, pltrel); } - - } module->state = HI_MODULE_STATE_CLEAN; diff --git a/src/moduler/moduler.h b/src/moduler/moduler.h index 26fd2f5..4a71ccd 100644 --- a/src/moduler/moduler.h +++ b/src/moduler/moduler.h @@ -15,6 +15,7 @@ enum HiModuleState { typedef struct { const char *name; // Filename if found + void *dlhandle; uptr address; u8 state; } HiModuleData;