VirtualBox

Changeset 66736 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
May 2, 2017 12:01:39 AM (8 years ago)
Author:
vboxsync
Message:

iso9660vfs,fatvfs: reference count fix

Location:
trunk/src/VBox/Runtime/common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/fs/fatvfs.cpp

    r66733 r66736  
    35693569
    35703570        /* Root also retains the whole file system. */
    3571         if (!pDir->Core.pParentDir)
     3571        if (pDir->Core.pVol->pRootDir == pDir)
    35723572        {
    35733573            Assert(pDir->Core.pVol);
     
    36023602    if (RTListIsEmpty(&pDir->OpenChildren))
    36033603    {
     3604        bool const fIsRootDir = pDir->Core.pVol->pRootDir == pDir;
     3605
    36043606        uint32_t cRefs = RTVfsDirRelease(pDir->hVfsSelf);
    36053607        Assert(cRefs != UINT32_MAX); NOREF(cRefs);
     
    36083610           holds a reference to the root directory, it will remain valid after
    36093611           the above release. */
    3610         if (!pDir->Core.pParentDir)
     3612        if (fIsRootDir)
    36113613        {
    36123614            Assert(cRefs > 0);
    36133615            Assert(pDir->Core.pVol);
    36143616            Assert(pDir->Core.pVol == pChild->pVol);
    3615             cRefs = RTVfsRetain(pDir->Core.pVol->hVfsSelf);
     3617            cRefs = RTVfsRelease(pDir->Core.pVol->hVfsSelf);
    36163618            Assert(cRefs != UINT32_MAX); NOREF(cRefs);
    36173619        }
  • trunk/src/VBox/Runtime/common/fs/iso9660vfs.cpp

    r66735 r66736  
    291291{
    292292    PRTFSISO9660FILE pThis = (PRTFSISO9660FILE)pvThis;
     293    LogFlow(("rtFsIso9660File_Close(%p)\n", pThis));
    293294    return rtFsIso9660Obj_Close(&pThis->Core);
    294295}
     
    777778{
    778779    PRTFSISO9660DIR pThis = (PRTFSISO9660DIR)pvThis;
     780    LogFlow(("rtFsIso9660Dir_Close(%p)\n", pThis));
    779781    if (pThis->pbDir)
    780782    {
     
    10351037
    10361038        /* Root also retains the whole file system. */
    1037         if (!pDir->Core.pParentDir)
     1039        if (pDir->Core.pVol->pRootDir == pDir)
    10381040        {
    10391041            Assert(pDir->Core.pVol);
     
    10411043            cRefs = RTVfsRetain(pDir->Core.pVol->hVfsSelf);
    10421044            Assert(cRefs != UINT32_MAX); NOREF(cRefs);
     1045            LogFlow(("rtFsIso9660Dir_AddOpenChild(%p,%p) retains volume (%d)\n", pDir, pChild, cRefs));
    10431046        }
    1044     }
     1047        else
     1048            LogFlow(("rtFsIso9660Dir_AddOpenChild(%p,%p) retains parent only (%d)\n", pDir, pChild, cRefs));
     1049    }
     1050    else
     1051        LogFlow(("rtFsIso9660Dir_AddOpenChild(%p,%p) retains nothing\n", pDir, pChild));
    10451052    RTListAppend(&pDir->OpenChildren, &pChild->Entry);
    10461053    pChild->pParentDir = pDir;
     
    10681075    if (RTListIsEmpty(&pDir->OpenChildren))
    10691076    {
     1077        bool const fIsRootDir = pDir->Core.pVol->pRootDir == pDir;
     1078
    10701079        uint32_t cRefs = RTVfsDirRelease(pDir->hVfsSelf);
    10711080        Assert(cRefs != UINT32_MAX); NOREF(cRefs);
     
    10741083           holds a reference to the root directory, it will remain valid after
    10751084           the above release. */
    1076         if (!pDir->Core.pParentDir)
     1085        if (fIsRootDir)
    10771086        {
    10781087            Assert(cRefs > 0);
    10791088            Assert(pDir->Core.pVol);
    10801089            Assert(pDir->Core.pVol == pChild->pVol);
    1081             cRefs = RTVfsRetain(pDir->Core.pVol->hVfsSelf);
     1090            cRefs = RTVfsRelease(pDir->Core.pVol->hVfsSelf);
    10821091            Assert(cRefs != UINT32_MAX); NOREF(cRefs);
     1092            LogFlow(("rtFsIso9660Dir_RemoveOpenChild(%p,%p) releases volume (%d)\n", pDir, pChild, cRefs));
    10831093        }
    1084     }
     1094        else
     1095            LogFlow(("rtFsIso9660Dir_RemoveOpenChild(%p,%p) releases parent only (%d)\n", pDir, pChild, cRefs));
     1096    }
     1097    else
     1098        LogFlow(("rtFsIso9660Dir_RemoveOpenChild(%p,%p) releases nothing\n", pDir, pChild));
    10851099}
    10861100
     
    12271241{
    12281242    PRTFSISO9660VOL pThis = (PRTFSISO9660VOL)pvThis;
     1243    LogFlow(("rtFsIso9660Vol_Close(%p)\n", pThis));
    12291244
    12301245    if (pThis->hVfsRootDir != NIL_RTVFSDIR)
     
    12641279    {
    12651280        *phVfsDir = pThis->hVfsRootDir;
     1281        LogFlow(("rtFsIso9660Vol_OpenRoot -> %p\n", *phVfsDir));
    12661282        return VINF_SUCCESS;
    12671283    }
     
    16171633 * @param   hVfsSelf        The FAT VFS handle (no reference consumed).
    16181634 * @param   hVfsBacking     The file backing the alleged FAT file system.
    1619  *                          Reference is consumed (via rtFsIso9660Vol_Destroy).
     1635 *                          Reference is consumed (via rtFsIso9660Vol_Close).
    16201636 * @param   fFlags          Flags, MBZ.
    16211637 * @param   pErrInfo        Where to return additional error info.  Can be NULL.
  • trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp

    r66652 r66736  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#define LOG_GROUP RTLOGGROUP_FS
    3132#include <iprt/vfs.h>
    3233#include <iprt/vfslowlevel.h>
     
    3536#include <iprt/err.h>
    3637#include <iprt/file.h>
     38#include <iprt/log.h>
    3739#include <iprt/mem.h>
    3840#include <iprt/param.h>
     
    19051907    AssertPtrReturn(pThis, UINT32_MAX);
    19061908    AssertReturn(pThis->uMagic == RTVFSDIR_MAGIC, UINT32_MAX);
    1907     return rtVfsObjRetain(&pThis->Base);
     1909    uint32_t cRefs = rtVfsObjRetain(&pThis->Base);
     1910    LogFlow(("RTVfsDirRetain(%p/%p) -> %#x\n", pThis, pThis->Base.pvThis));
     1911    return cRefs;
    19081912}
    19091913
     
    19161920    AssertPtrReturn(pThis, UINT32_MAX);
    19171921    AssertReturn(pThis->uMagic == RTVFSDIR_MAGIC, UINT32_MAX);
    1918     return rtVfsObjRelease(&pThis->Base);
     1922#ifdef LOG_ENABLED
     1923    void *pvThis = pThis->Base.pvThis;
     1924#endif
     1925    uint32_t cRefs = rtVfsObjRelease(&pThis->Base);
     1926    LogFlow(("RTVfsDirRelease(%p/%p) -> %#x\n", pThis, pvThis));
     1927    return cRefs;
    19191928}
    19201929
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette