Changeset 70483 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jan 7, 2018 9:43:45 PM (7 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/socket.cpp
r70481 r70483 163 163 * This is ZERO if we're currently not subscribing to anything. */ 164 164 uint32_t fSubscribedEvts; 165 /** Saved events which are only posted once. */ 165 /** Saved events which are only posted once and events harvested for 166 * sockets entetered multiple times into to a poll set. */ 166 167 uint32_t fEventsSaved; 168 /** Set if fEventsSaved contains harvested events. */ 169 bool fHavestedEvents; 167 170 /** Set if we're using the polling fallback. */ 168 171 bool fPollFallback; … … 505 508 pThis->fSubscribedEvts = 0; 506 509 pThis->fEventsSaved = 0; 510 pThis->fHavestedEvents = false; 507 511 pThis->fPollFallback = g_uWinSockInitedVersion < MAKEWORD(2, 0) 508 512 || g_pfnWSACreateEvent == NULL … … 686 690 */ 687 691 int aSockets[2] = { -1, -1 }; 688 i nt(socketpair(AF_INET, SOCK_STREAM, IPPROTO_TCP, aSockets) == 0)692 if (socketpair(AF_INET, SOCK_STREAM, IPPROTO_TCP, aSockets) == 0) 689 693 { 690 694 *phServer = aSockets[0]; … … 2821 2825 if (g_pfnWSAEnumNetworkEvents(pThis->hNative, pThis->hEvent, &NetEvts) == 0) 2822 2826 { 2823 if ( (NetEvts.lNetworkEvents & FD_READ) 2824 && (fEvents & RTPOLL_EVT_READ) 2825 && NetEvts.iErrorCode[FD_READ_BIT] == 0) 2827 if ( (NetEvts.lNetworkEvents & FD_READ) 2828 && NetEvts.iErrorCode[FD_READ_BIT] == 0) 2826 2829 fRetEvents |= RTPOLL_EVT_READ; 2827 2830 2828 if ( (NetEvts.lNetworkEvents & FD_WRITE) 2829 && (fEvents & RTPOLL_EVT_WRITE) 2830 && NetEvts.iErrorCode[FD_WRITE_BIT] == 0) 2831 if ( (NetEvts.lNetworkEvents & FD_WRITE) 2832 && NetEvts.iErrorCode[FD_WRITE_BIT] == 0) 2831 2833 fRetEvents |= RTPOLL_EVT_WRITE; 2832 2834 2833 if (fEvents & RTPOLL_EVT_ERROR) 2834 { 2835 if (NetEvts.lNetworkEvents & FD_CLOSE) 2836 fRetEvents |= RTPOLL_EVT_ERROR; 2837 else 2838 for (uint32_t i = 0; i < FD_MAX_EVENTS; i++) 2839 if ( (NetEvts.lNetworkEvents & (1L << i)) 2840 && NetEvts.iErrorCode[i] != 0) 2841 fRetEvents |= RTPOLL_EVT_ERROR; 2842 } 2835 if (NetEvts.lNetworkEvents & FD_CLOSE) 2836 fRetEvents |= RTPOLL_EVT_ERROR; 2837 else 2838 for (uint32_t i = 0; i < FD_MAX_EVENTS; i++) 2839 if ( (NetEvts.lNetworkEvents & (1L << i)) 2840 && NetEvts.iErrorCode[i] != 0) 2841 fRetEvents |= RTPOLL_EVT_ERROR; 2842 2843 pThis->fEventsSaved = fRetEvents |= pThis->fEventsSaved; 2843 2844 } 2844 2845 else … … 3035 3036 * Harvest events and clear the event mask for the next round of polling. 3036 3037 */ 3037 uint32_t fRetEvents = rtSocketPollCheck(pThis, fEvents);3038 uint32_t fRetEvents; 3038 3039 # ifdef RT_OS_WINDOWS 3039 pThis->fPollEvts = 0; 3040 3041 /* 3042 * Save the write event if required. 3043 * It is only posted once and might get lost if the another source in the 3044 * pollset with a higher priority has pending events. 3045 */ 3046 if ( !fHarvestEvents 3047 && fRetEvents) 3048 { 3049 pThis->fEventsSaved = fRetEvents; 3050 fRetEvents = 0; 3051 } 3040 if (!pThis->fPollFallback) 3041 { 3042 if (!pThis->fHavestedEvents) 3043 { 3044 fRetEvents = rtSocketPollCheck(pThis, fEvents); 3045 pThis->fHavestedEvents = true; 3046 } 3047 else 3048 fRetEvents = pThis->fEventsSaved; 3049 if (fHarvestEvents) 3050 fRetEvents &= fEvents; 3051 else 3052 fRetEvents = 0; 3053 pThis->fPollEvts = 0; 3054 } 3055 else 3052 3056 # endif 3053 3054 /* Make the socket blocking again and unlock the handle. */ 3057 { 3058 if (fHarvestEvents) 3059 fRetEvents = rtSocketPollCheck(pThis, fEvents); 3060 else 3061 fRetEvents = 0; 3062 } 3063 3064 /* 3065 * Make the socket blocking again and unlock the handle. 3066 */ 3055 3067 if (pThis->cUsers == 1) 3056 3068 { 3057 3069 # ifdef RT_OS_WINDOWS 3070 pThis->fEventsSaved &= RTPOLL_EVT_ERROR; 3071 pThis->fHavestedEvents = false; 3058 3072 rtSocketPollClearEventAndRestoreBlocking(pThis); 3059 3073 # endif -
trunk/src/VBox/Runtime/testcase/tstRTPoll.cpp
r70481 r70483 194 194 RTTESTI_CHECK(cbRead == sizeof(g_szHello) - 1 && memcmp(achBuf, g_szHello, sizeof(g_szHello) - 1) == 0); 195 195 196 //RTTESTI_CHECK_RC(RTPoll(hSet, 0, NULL, NULL), VERR_TIMEOUT);197 //RTTESTI_CHECK_RC(RTPoll(hSet, 1, NULL, NULL), VERR_TIMEOUT);196 RTTESTI_CHECK_RC(RTPoll(hSet, 0, NULL, NULL), VERR_TIMEOUT); 197 RTTESTI_CHECK_RC(RTPoll(hSet, 1, NULL, NULL), VERR_TIMEOUT); 198 198 } 199 199 … … 229 229 230 230 RTTESTI_CHECK_RC(RTPollSetDestroy(hSet), VINF_SUCCESS); 231 RTLogFlush(NULL);232 231 } 233 232
Note:
See TracChangeset
for help on using the changeset viewer.