mirror of
				https://github.com/simon987/sist2.git
				synced 2025-10-31 16:06:53 +00:00 
			
		
		
		
	thread safety for debug info table
This commit is contained in:
		
							parent
							
								
									3da2c8cae3
								
							
						
					
					
						commit
						dfb8c67490
					
				| @ -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; | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user