GNOME Bugzilla – Bug 520767
unfortunate race condition ...
Last modified: 2008-03-07 03:08:08 UTC
I get two async threads of execution entering (gtkfilesystemgnomevfs.c): gtk_file_system_gnome_vfs_get_folder concurrently with different 'types' fields; both are for the same URI, neither is in the hash initially: fprintf (stderr, "folder '%s' not in hash - working ... (0x%x)\n", uri, types); ... folder 'davs://localhost:8443/ssfs/files/library/liferay.com/Workspaces' not in hash - working ... (0x7f) folder 'davs://localhost:8443/ssfs/files/library/liferay.com/Workspaces' not in hash - working ... (0x3) That means that by the time we get to: get_folder_complete_operation: we need this patch: Index: file-chooser/gtkfilesystemgnomevfs.c =================================================================== --- file-chooser/gtkfilesystemgnomevfs.c (revision 5554) +++ file-chooser/gtkfilesystemgnomevfs.c (working copy) @@ -1087,6 +1087,8 @@ /* returned this cached folder */ g_object_ref (folder_vfs); + folder_vfs->types |= types; + (* op_data->callback) (GTK_FILE_SYSTEM_HANDLE (op_data->handle), GTK_FILE_FOLDER (folder_vfs), NULL, op_data->callback_data); To get correct types. OTOH - this took a while to find & is somewhat fragile. I would prefer to see this code shared with the code incorporating this comment: /* We don't have to initiate a reload to make up for the added * types, since gnome-vfs loads all file info we need by * default (and get_options() explicitly requests the mime type). */ but that needs to be done on HEAD I guess.
Created attachment 106752 [details] [review] libgnomeui-bgo520767-get-folder-race-condition.diff Thanks for tracking this down, Michael. This is the patch that I commited to trunk. Fix race condition when getting folders 2008-03-06 Federico Mena Quintero <federico@novell.com> * file-chooser/gtkfilesystemgnomevfs.c (get_folder_complete_operation): Patch from Michael Meeks <michael.meeks@novell.com> for http://bugzilla.gnome.org/show_bug.cgi?id=520767 - fix a race condition when two threads request the same folder and it's not loaded yet --- the last one to get the folder wouldn't get all the GtkFileInfoType flags it requested.