Changeset 58300 in vbox
- Timestamp:
- Oct 18, 2015 7:52:19 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
include/iprt/localipc.h (modified) (2 diffs)
-
include/iprt/mangling.h (modified) (1 diff)
-
src/VBox/Runtime/r3/posix/localipc-posix.cpp (modified) (2 diffs)
-
src/VBox/Runtime/r3/win/localipc-win.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/localipc.h
r58297 r58300 138 138 /** @} */ 139 139 140 141 140 /** 142 141 * Closes the local IPC session. 143 142 * 144 143 * This can be used with sessions created by both RTLocalIpcSessionConnect 145 * and RTLocalIpcServerListen. 144 * and RTLocalIpcServerListen. It will release one cancel pending I/O and 145 * relase one reference (typically the implict reference from the create API). 146 146 * 147 147 * @returns IPRT status code. … … 152 152 */ 153 153 RTDECL(int) RTLocalIpcSessionClose(RTLOCALIPCSESSION hSession); 154 155 /** 156 * Retain a refence to the given session. 157 * 158 * @returns New reference count, UINT32_MAX if the handle is invalid. 159 * @param hSession The session handle. 160 */ 161 RTDECL(uint32_t) RTLocalIpcSessionRetain(RTLOCALIPCSESSION hSession); 162 163 /** 164 * Releases a refence to the given session. 165 * 166 * This differs from RTLocalIpcSessionClose in that it won't cancel any pending 167 * I/O. So, better call RTLocalIpcSessionClose if you want to terminate the 168 * session. 169 * 170 * @returns New reference count, 0 if NIL handle, UINT32_MAX if the handle is 171 * invalid. 172 * @param hSession The session handle. 173 */ 174 RTDECL(uint32_t) RTLocalIpcSessionRelease(RTLOCALIPCSESSION hSession); 175 154 176 155 177 /** -
trunk/include/iprt/mangling.h
r58295 r58300 743 743 # define RTLocalIpcSessionRead RT_MANGLER(RTLocalIpcSessionRead) 744 744 # define RTLocalIpcSessionReadNB RT_MANGLER(RTLocalIpcSessionReadNB) 745 # define RTLocalIpcSessionRetain RT_MANGLER(RTLocalIpcSessionRetain) 746 # define RTLocalIpcSessionRelease RT_MANGLER(RTLocalIpcSessionRelease) 745 747 # define RTLocalIpcSessionWrite RT_MANGLER(RTLocalIpcSessionWrite) 746 748 # define RTLocalIpcSessionFlush RT_MANGLER(RTLocalIpcSessionFlush) -
trunk/src/VBox/Runtime/r3/posix/localipc-posix.cpp
r58297 r58300 557 557 558 558 559 RTDECL(uint32_t) RTLocalIpcSessionRetain(RTLOCALIPCSESSION hSession) 560 { 561 PRTLOCALIPCSESSIONINT pThis = (PRTLOCALIPCSESSIONINT)hSession; 562 AssertPtrReturn(pThis, UINT32_MAX); 563 AssertReturn(pThis->u32Magic == RTLOCALIPCSESSION_MAGIC, UINT32_MAX); 564 565 uint32_t cRefs = ASMAtomicIncU32(&pThis->cRefs); 566 Assert(cRefs < UINT32_MAX / 2 && cRefs); 567 return cRefs; 568 } 569 570 559 571 /** 560 572 * Session instance destructor. … … 590 602 Log(("rtLocalIpcSessionRelease: %u refs left\n", cRefs)); 591 603 return VINF_SUCCESS; 604 } 605 606 607 RTDECL(uint32_t) RTLocalIpcSessionRelease(RTLOCALIPCSESSION hSession) 608 { 609 if (hSession == NIL_RTLOCALIPCSESSION) 610 return 0; 611 612 PRTLOCALIPCSESSIONINT pThis = (PRTLOCALIPCSESSIONINT)hSession; 613 AssertPtrReturn(pThis, UINT32_MAX); 614 AssertReturn(pThis->u32Magic == RTLOCALIPCSESSION_MAGIC, UINT32_MAX); 615 616 uint32_t cRefs = ASMAtomicDecU32(&pThis->cRefs); 617 Assert(cRefs < UINT32_MAX / 2); 618 if (cRefs) 619 Log(("RTLocalIpcSessionRelease: %u refs left\n", cRefs)); 620 else 621 rtLocalIpcSessionDtor(pThis); 622 return cRefs; 592 623 } 593 624 -
trunk/src/VBox/Runtime/r3/win/localipc-win.cpp
r58299 r58300 909 909 910 910 911 RTDECL(uint32_t) RTLocalIpcSessionRetain(RTLOCALIPCSESSION hSession) 912 { 913 PRTLOCALIPCSESSIONINT pThis = (PRTLOCALIPCSESSIONINT)hSession; 914 AssertPtrReturn(pThis, UINT32_MAX); 915 AssertReturn(pThis->u32Magic == RTLOCALIPCSESSION_MAGIC, UINT32_MAX); 916 917 uint32_t cRefs = ASMAtomicIncU32(&pThis->cRefs); 918 Assert(cRefs < UINT32_MAX / 2 && cRefs); 919 return cRefs; 920 } 921 922 911 923 /** 912 924 * Call when the reference count reaches 0. … … 936 948 RTMemFree(pThis); 937 949 return VINF_OBJECT_DESTROYED; 938 }939 940 941 /**942 * Session instance destructor.943 *944 * @returns VINF_OBJECT_DESTROYED945 * @param pThis The server instance.946 */947 DECL_NO_INLINE(static, int) rtLocalIpcSessionDtor(PRTLOCALIPCSESSIONINT pThis)948 {949 RTCritSectEnter(&pThis->CritSect);950 return rtLocalIpcSessionWinDestroy(pThis);951 }952 953 954 /**955 * Releases a reference to the session instance.956 *957 * @returns VINF_SUCCESS or VINF_OBJECT_DESTROYED as appropriate.958 * @param pThis The session instance.959 */960 DECLINLINE(int) rtLocalIpcSessionRelease(PRTLOCALIPCSESSIONINT pThis)961 {962 uint32_t cRefs = ASMAtomicDecU32(&pThis->cRefs);963 Assert(cRefs < UINT32_MAX / 2);964 if (!cRefs)965 return rtLocalIpcSessionDtor(pThis);966 Log(("rtLocalIpcSessionRelease: %u refs left\n", cRefs));967 return VINF_SUCCESS;968 950 } 969 951 … … 983 965 984 966 int rc2 = RTCritSectLeave(&pThis->CritSect); AssertRC(rc2); 985 Log(("rtLocalIpcSessionRelease : %u refs left\n", cRefs));967 Log(("rtLocalIpcSessionReleaseAndUnlock: %u refs left\n", cRefs)); 986 968 return VINF_SUCCESS; 969 } 970 971 972 RTDECL(uint32_t) RTLocalIpcSessionRelease(RTLOCALIPCSESSION hSession) 973 { 974 if (hSession == NIL_RTLOCALIPCSESSION) 975 return 0; 976 977 PRTLOCALIPCSESSIONINT pThis = (PRTLOCALIPCSESSIONINT)hSession; 978 AssertPtrReturn(pThis, UINT32_MAX); 979 AssertReturn(pThis->u32Magic == RTLOCALIPCSESSION_MAGIC, UINT32_MAX); 980 981 uint32_t cRefs = ASMAtomicDecU32(&pThis->cRefs); 982 Assert(cRefs < UINT32_MAX / 2); 983 if (cRefs) 984 Log(("RTLocalIpcSessionRelease: %u refs left\n", cRefs)); 985 else 986 { 987 RTCritSectEnter(&pThis->CritSect); 988 rtLocalIpcSessionWinDestroy(pThis); 989 } 990 return cRefs; 987 991 } 988 992 … … 1002 1006 * Invalidate the instance, cancel all outstanding I/O and drop our reference. 1003 1007 */ 1004 AssertReturn(ASMAtomicCmpXchgU32(&pThis->u32Magic, ~RTLOCALIPCSESSION_MAGIC, RTLOCALIPCSESSION_MAGIC), VERR_WRONG_ORDER);1005 1006 1008 RTCritSectEnter(&pThis->CritSect); 1007 1009 rtLocalIpcWinCancel(pThis);
Note:
See TracChangeset
for help on using the changeset viewer.

