mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-40232: _PyImport_ReInitLock() can now safely use its lock (GH-20597)
Since _PyImport_ReInitLock() now calls _PyThread_at_fork_reinit() on the import lock, the lock is now in a known state: unlocked. It became safe to acquire it after fork.
This commit is contained in:
		
							parent
							
								
									26881c8fae
								
							
						
					
					
						commit
						45b34a04a5
					
				
					 1 changed files with 1 additions and 5 deletions
				
			
		|  | @ -213,11 +213,7 @@ _PyImport_ReInitLock(void) | ||||||
|     if (import_lock_level > 1) { |     if (import_lock_level > 1) { | ||||||
|         /* Forked as a side effect of import */ |         /* Forked as a side effect of import */ | ||||||
|         unsigned long me = PyThread_get_thread_ident(); |         unsigned long me = PyThread_get_thread_ident(); | ||||||
|         /* The following could fail if the lock is already held, but forking as
 |         PyThread_acquire_lock(import_lock, WAIT_LOCK); | ||||||
|            a side-effect of an import is a) rare, b) nuts, and c) difficult to |  | ||||||
|            do thanks to the lock only being held when doing individual module |  | ||||||
|            locks per import. */ |  | ||||||
|         PyThread_acquire_lock(import_lock, NOWAIT_LOCK); |  | ||||||
|         import_lock_thread = me; |         import_lock_thread = me; | ||||||
|         import_lock_level--; |         import_lock_level--; | ||||||
|     } else { |     } else { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Victor Stinner
						Victor Stinner