diff --git a/src/ctx.h b/src/ctx.h index 07ca3c2..d6c14b1 100644 --- a/src/ctx.h +++ b/src/ctx.h @@ -41,6 +41,7 @@ typedef struct { int fast; GHashTable *dbg_current_files; + pthread_mutex_t dbg_current_files_mu; scan_arc_ctx_t arc_ctx; scan_comic_ctx_t comic_ctx; diff --git a/src/main.c b/src/main.c index e1fd9ca..420f97f 100644 --- a/src/main.c +++ b/src/main.c @@ -168,7 +168,8 @@ void initialize_scan_context(scan_args_t *args) { ScanCtx.arc_ctx.passphrase[0] = 0; } - ScanCtx.dbg_current_files = g_hash_table_new(g_int64_hash, g_int64_equal); + ScanCtx.dbg_current_files = g_hash_table_new_full(g_int64_hash, g_int64_equal, NULL, NULL); + pthread_mutex_init(&ScanCtx.dbg_current_files_mu, NULL); // Comic ScanCtx.comic_ctx.log = _log; diff --git a/src/parsing/parse.c b/src/parsing/parse.c index 46bac17..ab0b36c 100644 --- a/src/parsing/parse.c +++ b/src/parsing/parse.c @@ -43,7 +43,9 @@ void fs_reset(struct vfile *f) { void set_dbg_current_file(parse_job_t *job) { unsigned long long pid = (unsigned long long) pthread_self(); + pthread_mutex_lock(&ScanCtx.dbg_current_files_mu); g_hash_table_replace(ScanCtx.dbg_current_files, GINT_TO_POINTER(pid), job); + pthread_mutex_unlock(&ScanCtx.dbg_current_files_mu); } void parse(void *arg) {