Changeset 86415 in vbox
- Timestamp:
- Oct 2, 2020 11:50:21 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/handle.h
r86414 r86415 57 57 * @param fLeaveOpen Whether closing the returned handle should leave the 58 58 * native standard handle open or not. 59 * Note! This currently only works with pipe! 59 * Note! This currently only works with pipes and 60 * sockets! 60 61 * @param ph Pointer to the generic handle. This will contain 61 62 * the most appropriate IPRT handle on success. -
trunk/src/VBox/Runtime/include/internal/socket.h
r82968 r86415 56 56 #ifndef IPRT_INTERNAL_SOCKET_POLLING_ONLY 57 57 DECLHIDDEN(int) rtSocketResolverError(void); 58 DECLHIDDEN(int) rtSocketCreateForNative(RTSOCKETINT **ppSocket, RTSOCKETNATIVE hNative );58 DECLHIDDEN(int) rtSocketCreateForNative(RTSOCKETINT **ppSocket, RTSOCKETNATIVE hNative, bool fLeaveOpen); 59 59 DECLHIDDEN(int) rtSocketCreate(PRTSOCKET phSocket, int iDomain, int iType, int iProtocol); 60 60 DECLHIDDEN(int) rtSocketCreateTcpPair(RTSOCKET *phServer, RTSOCKET *phClient); -
trunk/src/VBox/Runtime/r3/posix/RTHandleGetStandard-posix.cpp
r86414 r86415 120 120 121 121 case RTHANDLETYPE_SOCKET: 122 /** @todo fLeaveOpen */ 123 rc = rtSocketCreateForNative(&h.u.hSocket, fd); 122 rc = rtSocketCreateForNative(&h.u.hSocket, fd, fLeaveOpen); 124 123 break; 125 124 -
trunk/src/VBox/Runtime/r3/socket.cpp
r82968 r86415 149 149 * currently. */ 150 150 bool fBlocking; 151 /** Whether to leave the native socket open rather than closing it (for 152 * RTHandleGetStandard). */ 153 bool fLeaveOpen; 151 154 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) 152 155 /** The pollset currently polling this socket. This is NIL if no one is … … 496 499 * @param ppSocket Where to return the IPRT socket handle. 497 500 * @param hNative The native handle. 498 */ 499 DECLHIDDEN(int) rtSocketCreateForNative(RTSOCKETINT **ppSocket, RTSOCKETNATIVE hNative) 501 * @param fLeaveOpen Whether to leave the native socket handle open when 502 * closed. 503 */ 504 DECLHIDDEN(int) rtSocketCreateForNative(RTSOCKETINT **ppSocket, RTSOCKETNATIVE hNative, bool fLeaveOpen) 500 505 { 501 506 RTSOCKETINT *pThis = (RTSOCKETINT *)RTMemPoolAlloc(RTMEMPOOL_DEFAULT, sizeof(*pThis)); … … 506 511 pThis->hNative = hNative; 507 512 pThis->fClosed = false; 513 pThis->fLeaveOpen = fLeaveOpen; 508 514 pThis->fBlocking = true; 509 515 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) … … 539 545 #endif 540 546 AssertPtrReturn(phSocket, VERR_INVALID_POINTER); 541 return rtSocketCreateForNative(phSocket, uNative );547 return rtSocketCreateForNative(phSocket, uNative, false /*fLeaveOpen*/); 542 548 } 543 549 … … 579 585 * Wrap it. 580 586 */ 581 int rc = rtSocketCreateForNative(phSocket, hNative );587 int rc = rtSocketCreateForNative(phSocket, hNative, false /*fLeaveOpen*/); 582 588 if (RT_FAILURE(rc)) 583 589 { … … 724 730 if (RT_SUCCESS(rc)) 725 731 { 726 rc = rtSocketCreateForNative(phServer, hServer );732 rc = rtSocketCreateForNative(phServer, hServer, false /*fLeaveOpen*/); 727 733 if (RT_SUCCESS(rc)) 728 734 { 729 rc = rtSocketCreateForNative(phClient, hClient );735 rc = rtSocketCreateForNative(phClient, hClient, false /*fLeaveOpen*/); 730 736 if (RT_SUCCESS(rc)) 731 737 return VINF_SUCCESS; … … 806 812 pThis->hNative = NIL_RTSOCKETNATIVE; 807 813 808 #ifdef RT_OS_WINDOWS 809 AssertReturn(g_pfnclosesocket, VERR_NET_NOT_UNSUPPORTED); 810 if (g_pfnclosesocket(hNative)) 814 if (!pThis->fLeaveOpen) 815 { 816 #ifdef RT_OS_WINDOWS 817 AssertReturn(g_pfnclosesocket, VERR_NET_NOT_UNSUPPORTED); 818 if (g_pfnclosesocket(hNative)) 811 819 #else 812 if (close(hNative))813 #endif 814 {815 rc = rtSocketError();816 #ifdef RT_OS_WINDOWS 817 AssertMsgFailed(("closesocket(%p) -> %Rrc\n", (uintptr_t)hNative, rc));820 if (close(hNative)) 821 #endif 822 { 823 rc = rtSocketError(); 824 #ifdef RT_OS_WINDOWS 825 AssertMsgFailed(("closesocket(%p) -> %Rrc\n", (uintptr_t)hNative, rc)); 818 826 #else 819 AssertMsgFailed(("close(%d) -> %Rrc\n", hNative, rc)); 820 #endif 827 AssertMsgFailed(("close(%d) -> %Rrc\n", hNative, rc)); 828 #endif 829 } 821 830 } 822 831 } … … 2299 2308 * Wrap the client socket. 2300 2309 */ 2301 rc = rtSocketCreateForNative(phClient, hNativeClient );2310 rc = rtSocketCreateForNative(phClient, hNativeClient, false /*fLeaveOpen*/); 2302 2311 if (RT_FAILURE(rc)) 2303 2312 { -
trunk/src/VBox/Runtime/r3/win/RTHandleGetStandard-win.cpp
r86414 r86415 114 114 115 115 case RTHANDLETYPE_SOCKET: 116 /** @todo fLeaveOpen */ 117 rc = rtSocketCreateForNative(&h.u.hSocket, (RTHCUINTPTR)hNative); 116 rc = rtSocketCreateForNative(&h.u.hSocket, (RTHCUINTPTR)hNative, fLeaveOpen); 118 117 break; 119 118
Note:
See TracChangeset
for help on using the changeset viewer.