After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 520767 - unfortunate race condition ...
unfortunate race condition ...
Status: RESOLVED FIXED
Product: libgnomeui
Classification: Deprecated
Component: file-chooser
2.21.x
Other Linux
: Normal major
: future
Assigned To: Federico Mena Quintero
Federico Mena Quintero
Depends on:
Blocks:
 
 
Reported: 2008-03-06 15:17 UTC by Michael Meeks
Modified: 2008-03-07 03:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libgnomeui-bgo520767-get-folder-race-condition.diff (1.05 KB, patch)
2008-03-07 03:07 UTC, Federico Mena Quintero
committed Details | Review

Description Michael Meeks 2008-03-06 15:17:00 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.
Comment 1 Federico Mena Quintero 2008-03-07 03:07:51 UTC
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.