Changeset 34030 in vbox for trunk/src/VBox
- Timestamp:
- Nov 12, 2010 2:37:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp
r34029 r34030 760 760 761 761 /** 762 * Write locks the object.763 *764 * @param pThis The object to lock.765 */766 DECLINLINE(void) rtVfsObjWriteLock(RTVFSOBJINTERNAL *pThis)767 {768 RTVfsLockAcquireWrite(pThis->hLock);769 }770 771 772 /**773 * Undoing the effects of rtVfsObjWriteLock.774 *775 * @param pThis The object to lock.776 */777 DECLINLINE(void) rtVfsObjWriteUnlock(RTVFSOBJINTERNAL *pThis)778 {779 RTVfsLockReleaseWrite(pThis->hLock);780 }781 782 /**783 * Read locks the object.784 *785 * @param pThis The object to lock.786 */787 DECLINLINE(void) rtVfsObjReadLock(RTVFSOBJINTERNAL *pThis)788 {789 RTVfsLockAcquireRead(pThis->hLock);790 }791 792 793 /**794 * Undoing the effects of rtVfsObjReadLock.795 *796 * @param pThis The object to lock.797 */798 DECLINLINE(void) rtVfsObjReadUnlock(RTVFSOBJINTERNAL *pThis)799 {800 RTVfsLockReleaseRead(pThis->hLock);801 }802 803 804 805 /**806 762 * Internal object retainer that asserts sanity in strict builds. 807 763 * … … 840 796 * Invalidate the object. 841 797 */ 842 rtVfsObjWriteLock(pThis);/* paranoia */798 RTVfsLockAcquireWrite(pThis->hLock); /* paranoia */ 843 799 void *pvToFree = NULL; 844 800 switch (enmType) … … 887 843 } 888 844 ASMAtomicWriteU32(&pThis->uMagic, RTVFSOBJ_MAGIC_DEAD); 889 rtVfsObjWriteUnlock(pThis);845 RTVfsLockReleaseWrite(pThis->hLock); 890 846 891 847 /* … … 1128 1084 AssertReturn(pThis->uMagic == RTVFSOBJ_MAGIC, VERR_INVALID_HANDLE); 1129 1085 1130 rtVfsObjReadLock(pThis);1086 RTVfsLockAcquireRead(pThis->hLock); 1131 1087 int rc = pThis->pOps->pfnQueryInfo(pThis->pvThis, pObjInfo, enmAddAttr); 1132 rtVfsObjReadUnlock(pThis);1088 RTVfsLockReleaseRead(pThis->hLock); 1133 1089 return rc; 1134 1090 } … … 1412 1368 /** @todo Union mounts, traversal optimization methods, races, ++ */ 1413 1369 RTVFSDIRINTERNAL *pCurDir; 1414 rtVfsObjReadLock(&pThis->Base);1370 RTVfsLockAcquireRead(pThis->Base.hLock); 1415 1371 int rc = pThis->pOps->pfnOpenRoot(pThis->Base.pvThis, &pCurDir); 1416 rtVfsObjReadUnlock(&pThis->Base);1372 RTVfsLockReleaseRead(pThis->Base.hLock); 1417 1373 if (RT_FAILURE(rc)) 1418 1374 return rc; … … 1447 1403 if (fFinal) 1448 1404 { 1449 rtVfsObjReadLock(&pCurDir->Base);1405 RTVfsLockAcquireRead(pCurDir->Base.hLock); 1450 1406 rc = pCurDir->pOps->pfnTraversalOpen(pCurDir->Base.pvThis, pszEntry, NULL, &hSymlink, NULL); 1451 rtVfsObjReadUnlock(&pCurDir->Base);1407 RTVfsLockReleaseRead(pCurDir->Base.hLock); 1452 1408 *pszEntryEnd = '\0'; 1453 1409 if (rc == VERR_PATH_NOT_FOUND) … … 1464 1420 else 1465 1421 { 1466 rtVfsObjReadLock(&pCurDir->Base);1422 RTVfsLockAcquireRead(pCurDir->Base.hLock); 1467 1423 rc = pCurDir->pOps->pfnTraversalOpen(pCurDir->Base.pvThis, pszEntry, &hDir, &hSymlink, &hVfsMnt); 1468 rtVfsObjReadUnlock(&pCurDir->Base);1424 RTVfsLockReleaseRead(pCurDir->Base.hLock); 1469 1425 *pszEntryEnd = '/'; 1470 1426 if (RT_FAILURE(rc)) … … 1515 1471 /* Must restart from the root (optimize this). */ 1516 1472 RTVfsDirRelease(pCurDir); 1517 rtVfsObjReadLock(&pThis->Base);1473 RTVfsLockAcquireRead(pThis->Base.hLock); 1518 1474 rc = pThis->pOps->pfnOpenRoot(pThis->Base.pvThis, &pCurDir); 1519 rtVfsObjReadUnlock(&pThis->Base);1475 RTVfsLockReleaseRead(pThis->Base.hLock); 1520 1476 if (RT_FAILURE(rc)) 1521 1477 { … … 1532 1488 */ 1533 1489 RTVfsDirRelease(pCurDir); 1534 rtVfsObjReadLock(&hVfsMnt->Base);1490 RTVfsLockAcquireRead(hVfsMnt->Base.hLock); 1535 1491 rc = pThis->pOps->pfnOpenRoot(hVfsMnt->Base.pvThis, &pCurDir); 1536 rtVfsObjReadUnlock(&hVfsMnt->Base);1492 RTVfsLockReleaseRead(hVfsMnt->Base.hLock); 1537 1493 if (RT_FAILURE(rc)) 1538 1494 { … … 1758 1714 AssertReturn(pThis->uMagic == RTVFSSYMLINK_MAGIC, VERR_INVALID_HANDLE); 1759 1715 1760 rtVfsObjWriteLock(&pThis->Base);1716 RTVfsLockAcquireWrite(pThis->Base.hLock); 1761 1717 int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, pszTarget, cbTarget); 1762 rtVfsObjWriteUnlock(&pThis->Base);1718 RTVfsLockReleaseWrite(pThis->Base.hLock); 1763 1719 1764 1720 return rc; … … 1877 1833 RTSgBufInit(&SgBuf, &Seg, 1); 1878 1834 1879 rtVfsObjWriteLock(&pThis->Base);1835 RTVfsLockAcquireWrite(pThis->Base.hLock); 1880 1836 int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbRead); 1881 rtVfsObjWriteUnlock(&pThis->Base);1837 RTVfsLockReleaseWrite(pThis->Base.hLock); 1882 1838 return rc; 1883 1839 } … … 1898 1854 RTSgBufInit(&SgBuf, &Seg, 1); 1899 1855 1900 rtVfsObjWriteLock(&pThis->Base);1856 RTVfsLockAcquireWrite(pThis->Base.hLock); 1901 1857 int rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbWritten); 1902 rtVfsObjWriteUnlock(&pThis->Base);1858 RTVfsLockReleaseWrite(pThis->Base.hLock); 1903 1859 return rc; 1904 1860 } … … 1916 1872 AssertReturn(fBlocking || pcbRead, VERR_INVALID_PARAMETER); 1917 1873 1918 rtVfsObjWriteLock(&pThis->Base);1874 RTVfsLockAcquireWrite(pThis->Base.hLock); 1919 1875 int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, -1 /*off*/, pSgBuf, fBlocking, pcbRead); 1920 rtVfsObjWriteUnlock(&pThis->Base);1876 RTVfsLockReleaseWrite(pThis->Base.hLock); 1921 1877 return rc; 1922 1878 } … … 1934 1890 AssertReturn(fBlocking || pcbWritten, VERR_INVALID_PARAMETER); 1935 1891 1936 rtVfsObjWriteLock(&pThis->Base);1892 RTVfsLockAcquireWrite(pThis->Base.hLock); 1937 1893 int rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, -1 /*off*/, pSgBuf, fBlocking, pcbWritten); 1938 rtVfsObjWriteUnlock(&pThis->Base);1894 RTVfsLockReleaseWrite(pThis->Base.hLock); 1939 1895 return rc; 1940 1896 } … … 1947 1903 AssertReturn(pThis->uMagic == RTVFSIOSTREAM_MAGIC, VERR_INVALID_HANDLE); 1948 1904 1949 rtVfsObjWriteLock(&pThis->Base);1905 RTVfsLockAcquireWrite(pThis->Base.hLock); 1950 1906 int rc = pThis->pOps->pfnFlush(pThis->Base.pvThis); 1951 rtVfsObjWriteUnlock(&pThis->Base);1907 RTVfsLockReleaseWrite(pThis->Base.hLock); 1952 1908 return rc; 1953 1909 } … … 1961 1917 AssertReturn(pThis->uMagic == RTVFSIOSTREAM_MAGIC, VERR_INVALID_HANDLE); 1962 1918 1963 rtVfsObjWriteLock(&pThis->Base);1919 RTVfsLockAcquireWrite(pThis->Base.hLock); 1964 1920 int rc = pThis->pOps->pfnPollOne(pThis->Base.pvThis, fEvents, cMillies, fIntr, pfRetEvents); 1965 rtVfsObjWriteUnlock(&pThis->Base);1921 RTVfsLockReleaseWrite(pThis->Base.hLock); 1966 1922 return rc; 1967 1923 } … … 1975 1931 1976 1932 RTFOFF off; 1977 rtVfsObjReadLock(&pThis->Base);1933 RTVfsLockAcquireRead(pThis->Base.hLock); 1978 1934 int rc = pThis->pOps->pfnTell(pThis->Base.pvThis, &off); 1979 rtVfsObjReadUnlock(&pThis->Base);1935 RTVfsLockReleaseRead(pThis->Base.hLock); 1980 1936 if (RT_FAILURE(rc)) 1981 1937 off = rc; … … 1994 1950 if (pThis->pOps->pfnSkip) 1995 1951 { 1996 rtVfsObjWriteLock(&pThis->Base);1952 RTVfsLockAcquireWrite(pThis->Base.hLock); 1997 1953 rc = pThis->pOps->pfnSkip(pThis->Base.pvThis, cb); 1998 rtVfsObjWriteUnlock(&pThis->Base);1954 RTVfsLockReleaseWrite(pThis->Base.hLock); 1999 1955 } 2000 1956 else … … 2007 1963 { 2008 1964 size_t cbToRead = RT_MIN(cb, _64K); 2009 rtVfsObjWriteLock(&pThis->Base);1965 RTVfsLockAcquireWrite(pThis->Base.hLock); 2010 1966 rc = RTVfsIoStrmRead(hVfsIos, pvBuf, cbToRead, true /*fBlocking*/, NULL); 2011 rtVfsObjWriteUnlock(&pThis->Base);1967 RTVfsLockReleaseWrite(pThis->Base.hLock); 2012 1968 if (RT_FAILURE(rc)) 2013 1969 break; … … 2033 1989 if (pThis->pOps->pfnSkip) 2034 1990 { 2035 rtVfsObjWriteLock(&pThis->Base);1991 RTVfsLockAcquireWrite(pThis->Base.hLock); 2036 1992 rc = pThis->pOps->pfnZeroFill(pThis->Base.pvThis, cb); 2037 rtVfsObjWriteUnlock(&pThis->Base);1993 RTVfsLockReleaseWrite(pThis->Base.hLock); 2038 1994 } 2039 1995 else … … 2046 2002 { 2047 2003 size_t cbToWrite = RT_MIN(cb, _64K); 2048 rtVfsObjWriteLock(&pThis->Base);2004 RTVfsLockAcquireWrite(pThis->Base.hLock); 2049 2005 rc = RTVfsIoStrmWrite(hVfsIos, pvBuf, cbToWrite, true /*fBlocking*/, NULL); 2050 rtVfsObjWriteUnlock(&pThis->Base);2006 RTVfsLockReleaseWrite(pThis->Base.hLock); 2051 2007 if (RT_FAILURE(rc)) 2052 2008 break; … … 2158 2114 2159 2115 /** @todo there is a symlink creation race here. */ 2160 rtVfsObjWriteLock(&pVfsParentDir->Base);2116 RTVfsLockAcquireWrite(pVfsParentDir->Base.hLock); 2161 2117 rc = pVfsParentDir->pOps->pfnOpenFile(pVfsParentDir->Base.pvThis, pszEntryName, fOpen, phVfsFile); 2162 rtVfsObjWriteUnlock(&pVfsParentDir->Base);2118 RTVfsLockReleaseWrite(pVfsParentDir->Base.hLock); 2163 2119 2164 2120 RTVfsDirRelease(pVfsParentDir);
Note:
See TracChangeset
for help on using the changeset viewer.