From: VMware, Inc <> Date: Thu, 24 Feb 2011 22:55:09 +0000 (-0800) Subject: Fix closing of open handles for searches on "Shared Folders". X-Git-Tag: 2011.02.23-368700~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=420d3ab90b2a558da43bcf520be883b8a6066449;p=thirdparty%2Fopen-vm-tools.git Fix closing of open handles for searches on "Shared Folders". 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 --- diff --git a/open-vm-tools/lib/hgfsServer/hgfsServer.c b/open-vm-tools/lib/hgfsServer/hgfsServer.c index af28c2c67..4efa4cdd9 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c @@ -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));