]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix closing of open handles for searches on "Shared Folders".
authorVMware, Inc <>
Thu, 24 Feb 2011 22:55:09 +0000 (14:55 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 24 Feb 2011 22:55:09 +0000 (14:55 -0800)
Our HGFS server callback from the vmdb for UI updates always
force closes any open handles that are not on any shares.

This was done even if no shares had been added or removed.

This had the side-effect of alwasy closing the handles of
searches for the base of the name space i.e. "Shared Folders"
folder. This meant a race where those clients could end up
getting invalid handle returned for a directory read of the
virtual folder. It is better to return possibly stale (unlikely)
shares for that directory read than always fail even if
no shares changed.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/hgfsServer/hgfsServer.c

index af28c2c67acd872db1ca31f3963db08010b0b76b..4efa4cdd9040919b966fd8fc5c20f2bc50cd34fc 100644 (file)
@@ -2165,6 +2165,32 @@ HgfsSearch2SearchHandle(HgfsSearch const *search) // IN
 }
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsSearchIsBaseNameSpace --
+ *
+ *    Check if the search is the base of our name space, i.e. the dirents are
+ *    the shares themselves.
+ *
+ * Results:
+ *    TRUE if the search is the base of the name space, FALSE otherwise.
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static Bool
+HgfsSearchIsBaseNameSpace(HgfsSearch const *search) // IN
+{
+   ASSERT(search);
+
+   return search->type == DIRECTORY_SEARCH_TYPE_BASE;
+}
+
+
 /*
  *-----------------------------------------------------------------------------
  *
@@ -3869,6 +3895,11 @@ HgfsInvalidateSessionObjects(DblLnkLst_Links *shares,  // IN: List of new shares
          continue;
       }
 
+      if (HgfsSearchIsBaseNameSpace(&session->searchArray[i])) {
+         /* Skip search of the base name space. Maybe stale but it is okay. */
+         continue;
+      }
+
       handle = HgfsSearch2SearchHandle(&session->searchArray[i]);
       LOG(4, ("%s: Examining search (%s)\n", __FUNCTION__,
               session->searchArray[i].utf8Dir));