diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2022-10-27 19:02:25 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2022-10-27 19:02:25 +0200 |
| commit | 9289b29504660641d1abc0ded29fc2c04eca70ba (patch) | |
| tree | 6f628ce27eaee7f6ed1e85657cd8648a802dcbbb /src | |
| parent | de115b87df9eab6887c736cb93013aae7c53103c (diff) | |
| download | box64-9289b29504660641d1abc0ded29fc2c04eca70ba.tar.gz box64-9289b29504660641d1abc0ded29fc2c04eca70ba.zip | |
Try to get a cleaner exit
Diffstat (limited to 'src')
| -rwxr-xr-x | src/librarian/library.c | 5 | ||||
| -rwxr-xr-x | src/librarian/library_private.h | 1 | ||||
| -rwxr-xr-x | src/main.c | 2 |
3 files changed, 8 insertions, 0 deletions
diff --git a/src/librarian/library.c b/src/librarian/library.c index 9598a994..951407a9 100755 --- a/src/librarian/library.c +++ b/src/librarian/library.c @@ -358,6 +358,7 @@ library_t *NewLibrary(const char* path, box64context_t* context) lib->name = Path2Name(path); lib->nbdot = NbDot(lib->name); lib->type = LIB_UNNKNOW; + lib->refcnt = 1; printf_log(LOG_DEBUG, "Simplified name is \"%s\"\n", lib->name); if(box64_nopulse) { if(strstr(lib->name, "libpulse.so")==lib->name || strstr(lib->name, "libpulse-simple.so")==lib->name) { @@ -514,6 +515,9 @@ void Free1Library(library_t **lib, x64emu_t* emu) { if(!(*lib)) return; + if(--(*lib)->refcnt) + return; + if((*lib)->type==LIB_EMULATED && emu) { elfheader_t *elf_header = (*lib)->e.elf; RunElfFini(elf_header, emu); @@ -1006,6 +1010,7 @@ static int is_neededlib_present(needed_libs_t* needed, library_t* lib) void add_neededlib(needed_libs_t* needed, library_t* lib) { + ++lib->refcnt; if(!needed) return; if(is_neededlib_present(needed, lib)) diff --git a/src/librarian/library_private.h b/src/librarian/library_private.h index 3015c55e..021e78b6 100755 --- a/src/librarian/library_private.h +++ b/src/librarian/library_private.h @@ -73,6 +73,7 @@ typedef struct library_s { }; // private lib data needed_libs_t needed; needed_libs_t dependedby; // used to free library + int refcnt; // refcounting the lib lib_t *maplib; // local maplib, for dlopen'd library with LOCAL binding (most of the dlopen) kh_bridgemap_t *gbridgemap; // global symbol bridgemap kh_bridgemap_t *wbridgemap; // weak symbol bridgemap diff --git a/src/main.c b/src/main.c index dcd5d92c..858c6ec9 100755 --- a/src/main.c +++ b/src/main.c @@ -988,6 +988,7 @@ void endBox64() #endif FreeLibrarian(&my_context->local_maplib, emu); // unload all libs FreeLibrarian(&my_context->maplib, emu); // unload all libs + #if 0 // waiting for all thread except this one to finish int this_thread = GetTID(); int pid = getpid(); @@ -1025,6 +1026,7 @@ void endBox64() closedir(proc_dir); } } + #endif // all done, free context FreeBox64Context(&my_context); if(libGL) { |