- Timestamp:
- Jun 19, 2023 4:13:40 PM (18 months ago)
- Location:
- trunk/src/VBox/GuestHost/SharedClipboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-transfers-http.cpp
r100204 r100213 100 100 *********************************************************************************************************************************/ 101 101 102 /** 103 * Locks an HTTP transfer. 104 * 105 * @param pSrvTx HTTP transfer to lock. 106 */ 102 107 DECLINLINE(void) shClHttpTransferLock(PSHCLHTTPSERVERTRANSFER pSrvTx) 103 108 { … … 106 111 } 107 112 113 /** 114 * Unlocks an HTTP transfer. 115 * 116 * @param pSrvTx HTTP transfer to unlock. 117 */ 108 118 DECLINLINE(void) shClHttpTransferUnlock(PSHCLHTTPSERVERTRANSFER pSrvTx) 109 119 { -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-transfers.cpp
r100205 r100213 50 50 51 51 52 /********************************************************************************************************************************* 53 * Transfer List * 54 ********************************************************************************************************************************/ 55 52 56 /** 53 57 * Initializes a transfer list. … … 675 679 return true; 676 680 } 681 682 683 /********************************************************************************************************************************* 684 * Transfer Object * 685 ********************************************************************************************************************************/ 677 686 678 687 /** … … 1027 1036 } 1028 1037 1038 1039 /********************************************************************************************************************************* 1040 * Transfer * 1041 ********************************************************************************************************************************/ 1042 1029 1043 /** 1030 1044 * Creates a clipboard transfer, extended version. … … 1136 1150 ShClTransferReset(pTransfer); 1137 1151 1152 if (RTCritSectIsInitialized(&pTransfer->CritSect)) 1153 RTCritSectDelete(&pTransfer->CritSect); 1154 1138 1155 ShClEventSourceDestroy(&pTransfer->Events); 1139 1156 … … 1176 1193 pTransfer->CallbackCtx.cbUser = pTransfer->Callbacks.cbUser; 1177 1194 1178 int rc = VINF_SUCCESS; 1179 1180 LogRelFunc(("pfnOnInitialized=%p\n", pTransfer->Callbacks.pfnOnInitialized)); 1195 int rc = RTCritSectInit(&pTransfer->CritSect); 1196 AssertRCReturn(rc, rc); 1181 1197 1182 1198 if (pTransfer->Callbacks.pfnOnInitialized) … … 1190 1206 LogFlowFuncLeaveRC(rc); 1191 1207 return rc; 1208 } 1209 1210 /** 1211 * Locks a transfer. 1212 * 1213 * @param pTransfer Transfer to lock. 1214 */ 1215 DECLINLINE(void) shClTransferLock(PSHCLTRANSFER pTransfer) 1216 { 1217 int rc2 = RTCritSectEnter(&pTransfer->CritSect); 1218 AssertRC(rc2); 1219 } 1220 1221 /** 1222 * Unlocks a transfer. 1223 * 1224 * @param pTransfer Transfer to unlock. 1225 */ 1226 DECLINLINE(void) shClTransferUnlock(PSHCLTRANSFER pTransfer) 1227 { 1228 int rc2 = RTCritSectLeave(&pTransfer->CritSect); 1229 AssertRC(rc2); 1192 1230 } 1193 1231 … … 1499 1537 AssertPtrReturn(pTransfer, 0); 1500 1538 1501 LogFlowFunc(("[Transfer %RU32] cRoots=%RU64\n", pTransfer->State.uID, pTransfer->lstRoots.Hdr.cEntries)); 1502 return (uint32_t)pTransfer->lstRoots.Hdr.cEntries; 1539 shClTransferLock(pTransfer); 1540 1541 uint32_t const cRoots = pTransfer->lstRoots.Hdr.cEntries; 1542 1543 shClTransferUnlock(pTransfer); 1544 1545 return cRoots; 1503 1546 } 1504 1547 … … 1507 1550 * 1508 1551 * @param pTransfer Transfer to clear transfer root list for. 1552 * 1553 * @note Caller needs to take critical section. 1509 1554 */ 1510 1555 static void shClTransferRootsReset(PSHCLTRANSFER pTransfer) 1511 1556 { 1512 1557 AssertPtrReturnVoid(pTransfer); 1558 Assert(RTCritSectIsOwner(&pTransfer->CritSect)); 1513 1559 1514 1560 if (pTransfer->pszPathRootAbs) … … 1532 1578 LogFlowFuncEnter(); 1533 1579 1580 shClTransferLock(pTransfer); 1581 1534 1582 shClTransferRootsReset(pTransfer); 1535 1583 … … 1553 1601 RTMemFree(pItObj); 1554 1602 } 1603 1604 shClTransferUnlock(pTransfer); 1555 1605 } 1556 1606 … … 1566 1616 AssertPtrReturn(pTransfer, NULL); 1567 1617 1618 shClTransferLock(pTransfer); 1619 1568 1620 if (uIndex >= pTransfer->lstRoots.Hdr.cEntries) 1621 { 1622 shClTransferUnlock(pTransfer); 1569 1623 return NULL; 1570 1571 return shClTransferListGetEntryById(&pTransfer->lstRoots, uIndex); 1624 } 1625 1626 PCSHCLLISTENTRY pEntry = shClTransferListGetEntryById(&pTransfer->lstRoots, uIndex); 1627 1628 shClTransferUnlock(pTransfer); 1629 1630 return pEntry; 1572 1631 } 1573 1632 … … 1592 1651 rc = VERR_NOT_SUPPORTED; 1593 1652 1653 shClTransferLock(pTransfer); 1654 1594 1655 /* Make sure that we have at least an empty root path set. */ 1595 1656 if ( RT_SUCCESS(rc) … … 1599 1660 rc = VERR_NO_MEMORY; 1600 1661 } 1662 1663 shClTransferUnlock(pTransfer); 1601 1664 1602 1665 LogFlowFuncLeaveRC(rc); … … 1628 1691 int rc = VINF_SUCCESS; 1629 1692 1693 shClTransferLock(pTransfer); 1694 1630 1695 shClTransferRootsReset(pTransfer); 1631 1696 … … 1635 1700 RTCList<RTCString> lstRootEntries = RTCString(pszRoots, cbRoots - 1).split(SHCL_TRANSFER_URI_LIST_SEP_STR); 1636 1701 if (!lstRootEntries.size()) 1702 { 1703 shClTransferUnlock(pTransfer); 1637 1704 return VINF_SUCCESS; 1705 } 1638 1706 1639 1707 for (size_t i = 0; i < lstRootEntries.size(); ++i) … … 1756 1824 } 1757 1825 1826 shClTransferUnlock(pTransfer); 1827 1758 1828 LogFlowFuncLeaveRC(rc); 1759 1829 return rc; … … 1794 1864 AssertPtrReturn(pTransfer, 0); 1795 1865 1796 return pTransfer->State.uID; 1866 shClTransferLock(pTransfer); 1867 1868 SHCLTRANSFERID const uID = pTransfer->State.uID; 1869 1870 shClTransferUnlock(pTransfer); 1871 1872 return uID; 1797 1873 } 1798 1874 … … 1807 1883 AssertPtrReturn(pTransfer, SHCLTRANSFERDIR_UNKNOWN); 1808 1884 1809 LogFlowFunc(("[Transfer %RU32] enmDir=%RU32\n", pTransfer->State.uID, pTransfer->State.enmDir)); 1810 return pTransfer->State.enmDir; 1885 shClTransferLock(pTransfer); 1886 1887 SHCLTRANSFERDIR const enmDir = pTransfer->State.enmDir; 1888 1889 shClTransferUnlock(pTransfer); 1890 1891 return enmDir; 1811 1892 } 1812 1893 … … 1822 1903 { 1823 1904 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 1905 1906 shClTransferLock(pTransfer); 1907 1824 1908 AssertMsgReturn(pTransfer->pszPathRootAbs, ("Transfer has no root path set (yet)\n"), VERR_WRONG_ORDER); 1825 1909 1826 return RTStrCopy(pszPath, cbPath, pTransfer->pszPathRootAbs); 1910 int const rc = RTStrCopy(pszPath, cbPath, pTransfer->pszPathRootAbs); 1911 1912 shClTransferUnlock(pTransfer); 1913 1914 return rc; 1827 1915 } 1828 1916 … … 1837 1925 AssertPtrReturn(pTransfer, SHCLSOURCE_INVALID); 1838 1926 1839 LogFlowFunc(("[Transfer %RU32] enmSource=%RU32\n", pTransfer->State.uID, pTransfer->State.enmSource)); 1840 return pTransfer->State.enmSource; 1927 shClTransferLock(pTransfer); 1928 1929 SHCLSOURCE const enmSource = pTransfer->State.enmSource; 1930 1931 shClTransferUnlock(pTransfer); 1932 1933 return enmSource; 1841 1934 } 1842 1935 … … 1846 1939 * @returns Current transfer status. 1847 1940 * @param pTransfer Clipboard transfer to return status for. 1941 * 1942 * @note Caller needs to take critical section. 1943 */ 1944 DECLINLINE(SHCLTRANSFERSTATUS) shClTransferGetStatusLocked(PSHCLTRANSFER pTransfer) 1945 { 1946 Assert(RTCritSectIsOwner(&pTransfer->CritSect)); 1947 1948 shClTransferLock(pTransfer); 1949 1950 SHCLTRANSFERSTATUS const enmStatus = pTransfer->State.enmStatus; 1951 1952 shClTransferUnlock(pTransfer); 1953 1954 return enmStatus; 1955 } 1956 1957 /** 1958 * Returns the current transfer status. 1959 * 1960 * @returns Current transfer status. 1961 * @param pTransfer Clipboard transfer to return status for. 1848 1962 */ 1849 1963 SHCLTRANSFERSTATUS ShClTransferGetStatus(PSHCLTRANSFER pTransfer) … … 1851 1965 AssertPtrReturn(pTransfer, SHCLTRANSFERSTATUS_NONE); 1852 1966 1853 return pTransfer->State.enmStatus; 1967 shClTransferLock(pTransfer); 1968 1969 SHCLTRANSFERSTATUS const enmSts = shClTransferGetStatusLocked(pTransfer); 1970 1971 shClTransferUnlock(pTransfer); 1972 1973 return enmSts; 1854 1974 } 1855 1975 … … 1889 2009 1890 2010 LogFlowFuncEnter(); 2011 2012 shClTransferLock(pTransfer); 1891 2013 1892 2014 /* Ready to start? */ … … 1902 2024 pTransfer->State.enmStatus = SHCLTRANSFERSTATUS_STARTED; 1903 2025 2026 shClTransferUnlock(pTransfer); 2027 1904 2028 if (pTransfer->Callbacks.pfnOnStarted) 1905 2029 pTransfer->Callbacks.pfnOnStarted(&pTransfer->CallbackCtx); … … 1921 2045 { 1922 2046 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 2047 2048 shClTransferLock(pTransfer); 1923 2049 1924 2050 /* Already marked for stopping? */ … … 1935 2061 if (RT_SUCCESS(rc)) 1936 2062 { 2063 shClTransferUnlock(pTransfer); /* Leave lock while waiting. */ 2064 1937 2065 int rc2 = RTThreadUserWait(pTransfer->Thread.hThread, RT_MS_30SEC /* Timeout in ms */); 1938 2066 AssertRC(rc2); 2067 2068 shClTransferLock(pTransfer); 1939 2069 1940 2070 if (pTransfer->Thread.fStarted) /* Did the thread indicate that it started correctly? */ … … 1946 2076 } 1947 2077 2078 shClTransferUnlock(pTransfer); 2079 1948 2080 LogFlowFuncLeaveRC(rc); 1949 2081 return rc; … … 1961 2093 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 1962 2094 2095 shClTransferLock(pTransfer); 2096 1963 2097 if (pTransfer->Thread.hThread == NIL_RTTHREAD) 2098 { 2099 shClTransferUnlock(pTransfer); 1964 2100 return VINF_SUCCESS; 2101 } 1965 2102 1966 2103 LogFlowFuncEnter(); … … 1969 2106 pTransfer->Thread.fStop = true; 1970 2107 2108 shClTransferUnlock(pTransfer); /* Leave lock while waiting. */ 2109 1971 2110 int rcThread = VERR_WRONG_ORDER; 1972 2111 int rc = RTThreadWait(pTransfer->Thread.hThread, uTimeoutMs, &rcThread); … … 1975 2114 1976 2115 return rc; 2116 } 2117 2118 2119 /********************************************************************************************************************************* 2120 * Transfer Context * 2121 ********************************************************************************************************************************/ 2122 2123 /** 2124 * Locks a transfer context. 2125 * 2126 * @param pTransferCtx Transfer context to lock. 2127 */ 2128 DECLINLINE(void) shClTransferCtxLock(PSHCLTRANSFERCTX pTransferCtx) 2129 { 2130 int rc2 = RTCritSectEnter(&pTransferCtx->CritSect); 2131 AssertRC(rc2); 2132 } 2133 2134 /** 2135 * Unlocks a transfer context. 2136 * 2137 * @param pTransferCtx Transfer context to unlock. 2138 */ 2139 DECLINLINE(void) shClTransferCtxUnlock(PSHCLTRANSFERCTX pTransferCtx) 2140 { 2141 int rc2 = RTCritSectLeave(&pTransferCtx->CritSect); 2142 AssertRC(rc2); 1977 2143 } 1978 2144 … … 2018 2184 LogFlowFunc(("pTransferCtx=%p\n", pTransferCtx)); 2019 2185 2186 shClTransferCtxLock(pTransferCtx); 2187 2188 PSHCLTRANSFER pTransfer, pTransferNext; 2189 RTListForEachSafe(&pTransferCtx->List, pTransfer, pTransferNext, SHCLTRANSFER, Node) 2190 { 2191 ShClTransferDestroy(pTransfer); 2192 2193 shclTransferCtxTransferRemoveAndUnregister(pTransferCtx, pTransfer); 2194 2195 RTMemFree(pTransfer); 2196 pTransfer = NULL; 2197 } 2198 2199 pTransferCtx->cRunning = 0; 2200 pTransferCtx->cTransfers = 0; 2201 2202 shClTransferCtxUnlock(pTransferCtx); 2203 2020 2204 if (RTCritSectIsInitialized(&pTransferCtx->CritSect)) 2021 2205 RTCritSectDelete(&pTransferCtx->CritSect); 2022 2023 PSHCLTRANSFER pTransfer, pTransferNext;2024 RTListForEachSafe(&pTransferCtx->List, pTransfer, pTransferNext, SHCLTRANSFER, Node)2025 {2026 ShClTransferDestroy(pTransfer);2027 2028 shclTransferCtxTransferRemoveAndUnregister(pTransferCtx, pTransfer);2029 2030 RTMemFree(pTransfer);2031 pTransfer = NULL;2032 }2033 2034 pTransferCtx->cRunning = 0;2035 pTransferCtx->cTransfers = 0;2036 2206 } 2037 2207 … … 2044 2214 { 2045 2215 AssertPtrReturnVoid(pTransferCtx); 2216 2217 shClTransferCtxLock(pTransferCtx); 2046 2218 2047 2219 LogFlowFuncEnter(); … … 2054 2226 /** @todo Anything to do here? */ 2055 2227 #endif 2228 2229 shClTransferCtxUnlock(pTransferCtx); 2056 2230 } 2057 2231 … … 2062 2236 * @param pTransferCtx Transfer context to return transfer for. 2063 2237 * @param uID ID of the transfer to return. 2238 * 2239 * @note Caller needs to take critical section. 2064 2240 */ 2065 2241 static PSHCLTRANSFER shClTransferCtxGetTransferByIdInternal(PSHCLTRANSFERCTX pTransferCtx, uint32_t uID) 2066 2242 { 2243 Assert(RTCritSectIsOwner(&pTransferCtx->CritSect)); 2244 2067 2245 PSHCLTRANSFER pTransfer; 2068 2246 RTListForEach(&pTransferCtx->List, pTransfer, SHCLTRANSFER, Node) /** @todo Slow, but works for now. */ … … 2081 2259 * @param pTransferCtx Transfer context to return transfer for. 2082 2260 * @param uIdx Index of the transfer to return. 2261 * 2262 * @note Caller needs to take critical section. 2083 2263 */ 2084 2264 static PSHCLTRANSFER shClTransferCtxGetTransferByIndexInternal(PSHCLTRANSFERCTX pTransferCtx, uint32_t uIdx) 2085 2265 { 2266 Assert(RTCritSectIsOwner(&pTransferCtx->CritSect)); 2267 2086 2268 uint32_t idx = 0; 2087 2269 … … 2106 2288 PSHCLTRANSFER ShClTransferCtxGetTransferById(PSHCLTRANSFERCTX pTransferCtx, uint32_t uID) 2107 2289 { 2108 return shClTransferCtxGetTransferByIdInternal(pTransferCtx, uID); 2290 shClTransferCtxLock(pTransferCtx); 2291 2292 PSHCLTRANSFER const pTransfer = shClTransferCtxGetTransferByIdInternal(pTransferCtx, uID); 2293 2294 shClTransferCtxUnlock(pTransferCtx); 2295 2296 return pTransfer; 2109 2297 } 2110 2298 … … 2118 2306 PSHCLTRANSFER ShClTransferCtxGetTransferByIndex(PSHCLTRANSFERCTX pTransferCtx, uint32_t uIdx) 2119 2307 { 2120 return shClTransferCtxGetTransferByIndexInternal(pTransferCtx, uIdx); 2308 shClTransferCtxLock(pTransferCtx); 2309 2310 PSHCLTRANSFER const pTransfer = shClTransferCtxGetTransferByIndexInternal(pTransferCtx, uIdx); 2311 2312 shClTransferCtxUnlock(pTransferCtx); 2313 2314 return pTransfer; 2121 2315 } 2122 2316 … … 2130 2324 { 2131 2325 AssertPtrReturn(pTransferCtx, 0); 2132 return pTransferCtx->cRunning; 2326 2327 shClTransferCtxLock(pTransferCtx); 2328 2329 uint32_t const cRunning = pTransferCtx->cRunning; 2330 2331 shClTransferCtxUnlock(pTransferCtx); 2332 2333 return cRunning; 2133 2334 } 2134 2335 … … 2142 2343 { 2143 2344 AssertPtrReturn(pTransferCtx, 0); 2144 return pTransferCtx->cTransfers; 2345 2346 shClTransferCtxLock(pTransferCtx); 2347 2348 uint32_t const cTransfers = pTransferCtx->cTransfers; 2349 2350 shClTransferCtxUnlock(pTransferCtx); 2351 2352 return cTransfers; 2145 2353 } 2146 2354 … … 2160 2368 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 2161 2369 /* pidTransfer is optional. */ 2370 2371 shClTransferCtxLock(pTransferCtx); 2162 2372 2163 2373 /* … … 2183 2393 { 2184 2394 LogFunc(("Maximum number of transfers reached (%RU16 transfers)\n", pTransferCtx->cTransfers)); 2395 shClTransferCtxUnlock(pTransferCtx); 2185 2396 return VERR_SHCLPB_MAX_TRANSFERS_REACHED; 2186 2397 } … … 2193 2404 2194 2405 Log2Func(("pTransfer=%p, idTransfer=%RU32 -- now %RU16 transfer(s)\n", pTransfer, idTransfer, pTransferCtx->cTransfers)); 2406 2407 shClTransferCtxUnlock(pTransferCtx); 2195 2408 2196 2409 if (pTransfer->Callbacks.pfnOnRegistered) … … 2216 2429 int ShClTransferCtxTransferRegisterById(PSHCLTRANSFERCTX pTransferCtx, PSHCLTRANSFER pTransfer, SHCLTRANSFERID idTransfer) 2217 2430 { 2218 LogFlowFunc(("cTransfers=%RU16, idTransfer=%RU32\n", pTransferCtx->cTransfers, idTransfer));2431 shClTransferCtxLock(pTransferCtx); 2219 2432 2220 2433 if (pTransferCtx->cTransfers < VBOX_SHCL_MAX_TRANSFERS - 2 /* First and last are not used */) … … 2226 2439 pTransfer->State.uID = idTransfer; 2227 2440 2441 shClTransferCtxUnlock(pTransferCtx); 2442 2228 2443 if (pTransfer->Callbacks.pfnOnRegistered) 2229 2444 pTransfer->Callbacks.pfnOnRegistered(&pTransfer->CallbackCtx, pTransferCtx); 2230 2445 2446 shClTransferCtxLock(pTransferCtx); 2447 2231 2448 pTransferCtx->cTransfers++; 2449 2450 LogFunc(("Registered transfer ID %RU16 -- now %RU16 transfers total\n", idTransfer, pTransferCtx->cTransfers)); 2451 2452 shClTransferCtxUnlock(pTransferCtx); 2232 2453 return VINF_SUCCESS; 2233 2454 } … … 2237 2458 2238 2459 LogFunc(("Maximum number of transfers reached (%RU16 transfers)\n", pTransferCtx->cTransfers)); 2460 2461 shClTransferCtxUnlock(pTransferCtx); 2462 2239 2463 return VERR_SHCLPB_MAX_TRANSFERS_REACHED; 2240 2464 } … … 2245 2469 * @param pTransferCtx Transfer context to remove transfer from. 2246 2470 * @param pTransfer Transfer to remove. 2471 * 2472 * @note Caller needs to take critical section. 2247 2473 */ 2248 2474 static void shclTransferCtxTransferRemoveAndUnregister(PSHCLTRANSFERCTX pTransferCtx, PSHCLTRANSFER pTransfer) 2249 2475 { 2476 Assert(RTCritSectIsOwner(&pTransferCtx->CritSect)); 2477 2250 2478 RTListNodeRemove(&pTransfer->Node); 2251 2479 … … 2255 2483 Assert(pTransferCtx->cTransfers >= pTransferCtx->cRunning); 2256 2484 2485 shClTransferCtxUnlock(pTransferCtx); 2486 2257 2487 if (pTransfer->Callbacks.pfnOnUnregistered) 2258 2488 pTransfer->Callbacks.pfnOnUnregistered(&pTransfer->CallbackCtx, pTransferCtx); 2489 2490 shClTransferCtxLock(pTransferCtx); 2259 2491 2260 2492 LogFlowFunc(("Now %RU32 transfers left\n", pTransferCtx->cTransfers)); … … 2271 2503 int ShClTransferCtxTransferUnregister(PSHCLTRANSFERCTX pTransferCtx, SHCLTRANSFERID idTransfer) 2272 2504 { 2505 AssertPtrReturn(pTransferCtx, VERR_INVALID_POINTER); 2506 AssertReturn(idTransfer, VERR_INVALID_PARAMETER); 2507 2508 shClTransferCtxLock(pTransferCtx); 2509 2273 2510 int rc = VINF_SUCCESS; 2274 2511 AssertMsgStmt(ASMBitTestAndClear(&pTransferCtx->bmTransferIds, idTransfer), ("idTransfer=%#x\n", idTransfer), rc = VERR_NOT_FOUND); … … 2276 2513 LogFlowFunc(("idTransfer=%RU32\n", idTransfer)); 2277 2514 2278 PSHCLTRANSFER pTransfer = shClTransferCtxGetTransferByIdInternal(pTransferCtx, idTransfer); 2279 if (pTransfer) 2280 { 2281 shclTransferCtxTransferRemoveAndUnregister(pTransferCtx, pTransfer); 2282 } 2283 else 2284 rc = VERR_NOT_FOUND; 2515 if (RT_SUCCESS(rc)) 2516 { 2517 PSHCLTRANSFER pTransfer = shClTransferCtxGetTransferByIdInternal(pTransferCtx, idTransfer); 2518 if (pTransfer) 2519 { 2520 shclTransferCtxTransferRemoveAndUnregister(pTransferCtx, pTransfer); 2521 } 2522 else 2523 rc = VERR_NOT_FOUND; 2524 } 2525 2526 shClTransferCtxUnlock(pTransferCtx); 2285 2527 2286 2528 LogFlowFuncLeaveRC(rc); … … 2298 2540 AssertPtrReturnVoid(pTransferCtx); 2299 2541 2542 shClTransferCtxLock(pTransferCtx); 2543 2300 2544 LogFlowFunc(("pTransferCtx=%p, cTransfers=%RU16 cRunning=%RU16\n", 2301 2545 pTransferCtx, pTransferCtx->cTransfers, pTransferCtx->cRunning)); 2302 2546 2303 2547 if (pTransferCtx->cTransfers == 0) 2548 { 2549 shClTransferCtxUnlock(pTransferCtx); 2304 2550 return; 2551 } 2305 2552 2306 2553 /* Remove all transfers which are not in a running state (e.g. only announced). */ … … 2308 2555 RTListForEachSafe(&pTransferCtx->List, pTransfer, pTransferNext, SHCLTRANSFER, Node) 2309 2556 { 2310 if (ShClTransferGetStatus(pTransfer) != SHCLTRANSFERSTATUS_STARTED) 2557 shClTransferLock(pTransfer); 2558 2559 SHCLTRANSFERSTATUS const enmStatus = shClTransferGetStatusLocked(pTransfer); 2560 LogFlowFunc(("\tTransfer #%RU16: %s\n", pTransfer->State.uID, ShClTransferStatusToStr(enmStatus))); 2561 2562 if (enmStatus != SHCLTRANSFERSTATUS_STARTED) 2311 2563 { 2312 2564 shclTransferCtxTransferRemoveAndUnregister(pTransferCtx, pTransfer); 2565 2566 shClTransferUnlock(pTransfer); 2313 2567 2314 2568 ShClTransferDestroy(pTransfer); … … 2317 2571 pTransfer = NULL; 2318 2572 } 2319 } 2573 else 2574 shClTransferUnlock(pTransfer); 2575 } 2576 2577 shClTransferCtxUnlock(pTransferCtx); 2320 2578 } 2321 2579 … … 2330 2588 AssertPtrReturn(pTransferCtx, true); 2331 2589 2590 shClTransferCtxLock(pTransferCtx); 2591 2332 2592 LogFlowFunc(("cRunning=%RU32, cMaxRunning=%RU32\n", pTransferCtx->cRunning, pTransferCtx->cMaxRunning)); 2333 2593 2334 2594 Assert(pTransferCtx->cRunning <= pTransferCtx->cMaxRunning); 2335 return pTransferCtx->cRunning == pTransferCtx->cMaxRunning; 2595 bool const fMaximumReached = pTransferCtx->cRunning == pTransferCtx->cMaxRunning; 2596 2597 shClTransferCtxUnlock(pTransferCtx); 2598 2599 return fMaximumReached; 2336 2600 } 2337 2601
Note:
See TracChangeset
for help on using the changeset viewer.