Comment 236 for bug 1512120

pgkos.bugzilla basically did, what I proposed at comment #95 half a year ago: He identified the critical sections and implemented synchronization to prevent the race condition. And that's exactly the right way to fix this bug! If pgkos.bugzilla determined the CS right, the rest should be a child's play.

However, Simon is right, too: pgkos.bugzilla's implementation slowdowns the execution of Thunar or may even make it hang. This is because the patch allows only one thread to execute thunar_folder_monitor() concurrently.

This problem is well-known as the "Readers-Writers-Problem". The solution is simple and described in detail here [0, pp.69].

Basically an int and another mutex is needed inside thunar/thunar-folder.c, to better orchestrate entry into thunar_folder_monitor() and thus re-enable parallel execution of it.

I am sure we are only a small step away from getting this annoying bug finally fixed =)

[0] http://greenteapress.com/semaphores/LittleBookOfSemaphores.pdf