# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1299781803 0 # Node ID 2f21ee9d7c7b6919d953c3b5ab3ee8167b8e9026 # Parent bd909322f40d417eed8b65c9d905204e1ab141f8 Experimental change for locking on the main thread... will be committing dw_main_* updates momentarily to go along with this. diff -r bd909322f40d -r 2f21ee9d7c7b mac/dw.m --- a/mac/dw.m Thu Mar 10 02:34:14 2011 +0000 +++ b/mac/dw.m Thu Mar 10 18:30:03 2011 +0000 @@ -6466,19 +6466,23 @@ */ void dw_mutex_lock(HMTX mutex) { - DWTID saved = (DWTID)-1; - + /* We need to handle locks from the main thread differently... + * since we can't stop message processing... otherwise we + * will deadlock... so try to acquire the lock and continue + * processing messages in between tries. + */ if(DWThread == pthread_self()) { - saved = DWThread; - DWThread = (DWTID)-1; pthread_mutex_unlock(DWRunMutex); + while(pthread_mutex_trylock(mutex) != 0) + { + dw_main_iteration(); + } + pthread_mutex_lock(DWRunMutex); } - pthread_mutex_lock(mutex); - if(saved != (DWTID)-1) + else { - DWThread = saved; - pthread_mutex_lock(DWRunMutex); + pthread_mutex_lock(mutex); } }