GNOME Bugzilla – Bug 166852
gnome_vfs_cancellation_cancel should be callable from any thread
Last modified: 2005-02-16 13:28:57 UTC
Please describe the problem: I'm implementing the AWT FileDialog in libgcj using GtkFileChooserDialog. The AWT is multi-threaded by design and as a result it may call gnome_vfs_cancellation_cancel in a thread other than the one gnome-vfs was initialized in. This causes GNOME_VFS_ASSERT_PRIMARY_THREAD to fail, crashing the program. In the context of GTK, this can be reproduced by running a GtkFileChooserDialog in a thread other than the glib main loop and attempting to switch directories. Steps to reproduce: 1. run GtkFileChooserDialog in a thread other than the glib main loop 2. attempt to change directories within the chooser Actual results: the directory should change Expected results: the program crashes with an assertion failure Does this happen every time? yes Other information:
Created attachment 37294 [details] Test program! I am not 100% sure the threading stuff is done correctly!
Created attachment 37295 [details] [review] Proposed patch! If not in the main thread, schedule a call from the main thread via g_idle_add. Tested with the program above!
Created attachment 37299 [details] [review] Second try! I added GNOME_VFS_ASSERT_PRIMARY_THREAD back to really make sure that we call gnome_vfs_cancellation_cancel_internal from the main thread!
Comment on attachment 37299 [details] [review] Second try! Can't commit there might be races with this patch. We better make cancellation threadsafe!
The latest version of gnome-vfs has this sort of fixed. It allows cancellation from multiple threads, but requires some work from the app to handle a possible race. I've also fixed this race in the gnome-vfs file selector backend.