Author: post
Date: 2012-01-22 15:13:57 +0100 (Sun, 22 Jan 2012)
New Revision: 4103
Modified:
trunk/librawstudio/rs-io.c
Log:
Do not wait for IO lock for more than 10 seconds. Safety valve if a thread
hangs, it will not completely lock up Rawstudio.
Modified: trunk/librawstudio/rs-io.c
===================================================================
--- trunk/librawstudio/rs-io.c 2012-01-17 21:39:27 UTC (rev 4102)
+++ trunk/librawstudio/rs-io.c 2012-01-22 14:13:57 UTC (rev 4103)
@@ -284,7 +284,17 @@
void
rs_io_lock(void)
{
- g_static_rec_mutex_lock(&io_lock);
+ if (g_static_rec_mutex_trylock(&io_lock))
+ return;
+
+ /* Each loop tries approx every millisecond, so we wait 10 secs */
+ int tries_left = 10*1000;
+ do {
+ g_usleep(1000);
+ if (--tries_left <= 0)
+ return;
+ } while (FALSE == g_static_rec_mutex_trylock(&io_lock));
+ g_warning("IO Lock was not released after 10 seconds, ignoring IO
lock");
}
/**
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit