Mercurial > dwindows
comparison gtk/dw.c @ 96:baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 05 Jul 2002 01:32:37 +0000 |
parents | 7c3eef54c98c |
children | cd0e5cf92f6a |
comparison
equal
deleted
inserted
replaced
95:636c37ca7238 | 96:baaf4b04d284 |
---|---|
4307 * Parameters: | 4307 * Parameters: |
4308 * mutex: The handle to the mutex returned by dw_mutex_new(). | 4308 * mutex: The handle to the mutex returned by dw_mutex_new(). |
4309 */ | 4309 */ |
4310 void dw_mutex_lock(HMTX mutex) | 4310 void dw_mutex_lock(HMTX mutex) |
4311 { | 4311 { |
4312 /* If we are being called from an event handler we must release | |
4313 * the GTK mutex so we don't deadlock. | |
4314 */ | |
4315 if(pthread_self() == _dw_thread) | |
4316 gdk_threads_leave(); | |
4317 | |
4312 pthread_mutex_lock(&mutex); | 4318 pthread_mutex_lock(&mutex); |
4319 | |
4320 /* And of course relock it when we have acquired the mutext */ | |
4321 if(pthread_self() == _dw_thread) | |
4322 gdk_threads_enter(); | |
4313 } | 4323 } |
4314 | 4324 |
4315 /* | 4325 /* |
4316 * Reliquishes the access to the semaphore. | 4326 * Reliquishes the access to the semaphore. |
4317 * Parameters: | 4327 * Parameters: |