Index: /trunk/src/VBox/Runtime/r3/socket.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/socket.cpp	(revision 70482)
+++ /trunk/src/VBox/Runtime/r3/socket.cpp	(revision 70483)
@@ -163,6 +163,9 @@
      * This is ZERO if we're currently not subscribing to anything. */
     uint32_t            fSubscribedEvts;
-    /** Saved events which are only posted once. */
+    /** Saved events which are only posted once and events harvested for
+     * sockets entetered multiple times into to a poll set. */
     uint32_t            fEventsSaved;
+    /** Set if fEventsSaved contains harvested events. */
+    bool                fHavestedEvents;
     /** Set if we're using the polling fallback. */
     bool                fPollFallback;
@@ -505,4 +508,5 @@
     pThis->fSubscribedEvts          = 0;
     pThis->fEventsSaved             = 0;
+    pThis->fHavestedEvents          = false;
     pThis->fPollFallback            = g_uWinSockInitedVersion < MAKEWORD(2, 0)
                                    || g_pfnWSACreateEvent == NULL
@@ -686,5 +690,5 @@
      */
     int aSockets[2] = { -1, -1 };
-    int (socketpair(AF_INET, SOCK_STREAM, IPPROTO_TCP, aSockets) == 0)
+    if (socketpair(AF_INET, SOCK_STREAM, IPPROTO_TCP, aSockets) == 0)
     {
         *phServer = aSockets[0];
@@ -2821,24 +2825,21 @@
         if (g_pfnWSAEnumNetworkEvents(pThis->hNative, pThis->hEvent, &NetEvts) == 0)
         {
-            if (    (NetEvts.lNetworkEvents & FD_READ)
-                &&  (fEvents & RTPOLL_EVT_READ)
-                &&  NetEvts.iErrorCode[FD_READ_BIT] == 0)
+            if (   (NetEvts.lNetworkEvents & FD_READ)
+                && NetEvts.iErrorCode[FD_READ_BIT] == 0)
                 fRetEvents |= RTPOLL_EVT_READ;
 
-            if (    (NetEvts.lNetworkEvents & FD_WRITE)
-                &&  (fEvents & RTPOLL_EVT_WRITE)
-                &&  NetEvts.iErrorCode[FD_WRITE_BIT] == 0)
+            if (   (NetEvts.lNetworkEvents & FD_WRITE)
+                && NetEvts.iErrorCode[FD_WRITE_BIT] == 0)
                 fRetEvents |= RTPOLL_EVT_WRITE;
 
-            if (fEvents & RTPOLL_EVT_ERROR)
-            {
-                if (NetEvts.lNetworkEvents & FD_CLOSE)
-                    fRetEvents |= RTPOLL_EVT_ERROR;
-                else
-                    for (uint32_t i = 0; i < FD_MAX_EVENTS; i++)
-                        if (    (NetEvts.lNetworkEvents & (1L << i))
-                            &&  NetEvts.iErrorCode[i] != 0)
-                            fRetEvents |= RTPOLL_EVT_ERROR;
-            }
+            if (NetEvts.lNetworkEvents & FD_CLOSE)
+                fRetEvents |= RTPOLL_EVT_ERROR;
+            else
+                for (uint32_t i = 0; i < FD_MAX_EVENTS; i++)
+                    if (   (NetEvts.lNetworkEvents & (1L << i))
+                        && NetEvts.iErrorCode[i] != 0)
+                        fRetEvents |= RTPOLL_EVT_ERROR;
+
+            pThis->fEventsSaved = fRetEvents |= pThis->fEventsSaved;
         }
         else
@@ -3035,25 +3036,38 @@
      * Harvest events and clear the event mask for the next round of polling.
      */
-    uint32_t fRetEvents = rtSocketPollCheck(pThis, fEvents);
+    uint32_t fRetEvents;
 # ifdef RT_OS_WINDOWS
-    pThis->fPollEvts = 0;
-
-    /*
-     * Save the write event if required.
-     * It is only posted once and might get lost if the another source in the
-     * pollset with a higher priority has pending events.
-     */
-    if (   !fHarvestEvents
-        && fRetEvents)
-    {
-        pThis->fEventsSaved = fRetEvents;
-        fRetEvents = 0;
-    }
+    if (!pThis->fPollFallback)
+    {
+        if (!pThis->fHavestedEvents)
+        {
+            fRetEvents = rtSocketPollCheck(pThis, fEvents);
+            pThis->fHavestedEvents = true;
+        }
+        else
+            fRetEvents = pThis->fEventsSaved;
+        if (fHarvestEvents)
+            fRetEvents &= fEvents;
+        else
+            fRetEvents = 0;
+        pThis->fPollEvts = 0;
+    }
+    else
 # endif
-
-    /* Make the socket blocking again and unlock the handle. */
+    {
+        if (fHarvestEvents)
+            fRetEvents = rtSocketPollCheck(pThis, fEvents);
+        else
+            fRetEvents = 0;
+    }
+
+    /*
+     * Make the socket blocking again and unlock the handle.
+     */
     if (pThis->cUsers == 1)
     {
 # ifdef RT_OS_WINDOWS
+        pThis->fEventsSaved   &= RTPOLL_EVT_ERROR;
+        pThis->fHavestedEvents = false;
         rtSocketPollClearEventAndRestoreBlocking(pThis);
 # endif
Index: /trunk/src/VBox/Runtime/testcase/tstRTPoll.cpp
===================================================================
--- /trunk/src/VBox/Runtime/testcase/tstRTPoll.cpp	(revision 70482)
+++ /trunk/src/VBox/Runtime/testcase/tstRTPoll.cpp	(revision 70483)
@@ -194,6 +194,6 @@
         RTTESTI_CHECK(cbRead == sizeof(g_szHello) - 1 && memcmp(achBuf, g_szHello, sizeof(g_szHello) - 1) == 0);
 
-//        RTTESTI_CHECK_RC(RTPoll(hSet, 0, NULL,  NULL), VERR_TIMEOUT);
-//        RTTESTI_CHECK_RC(RTPoll(hSet, 1, NULL,  NULL), VERR_TIMEOUT);
+        RTTESTI_CHECK_RC(RTPoll(hSet, 0, NULL,  NULL), VERR_TIMEOUT);
+        RTTESTI_CHECK_RC(RTPoll(hSet, 1, NULL,  NULL), VERR_TIMEOUT);
     }
 
@@ -229,5 +229,4 @@
 
     RTTESTI_CHECK_RC(RTPollSetDestroy(hSet), VINF_SUCCESS);
-RTLogFlush(NULL);
 }
 
