VirtualBox

Changeset 73618 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 10, 2018 2:16:56 PM (6 years ago)
Author:
vboxsync
Message:

Devices/Serial/DrvTCP: Fixed stalling reads on Windows hosts caused by slightly different behavior of RTPoll() there, also don't let the guest starve if there is data to read by exiting to early if the transmit buffer isn't full

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Serial/DrvTCP.cpp

    r69419 r73618  
    133133        else
    134134        {
     135            /* Always include error event. */
     136            fEvts |= RTPOLL_EVT_ERROR;
     137            rc = RTPollSetEventsChange(pThis->hPollSet, DRVTCP_POLLSET_ID_SOCKET, fEvts);
     138            AssertRC(rc);
     139        }
     140    }
     141
     142    if (RT_SUCCESS(rc))
     143    {
     144        while (RT_SUCCESS(rc))
     145        {
     146            uint32_t fEvtsRecv = 0;
     147            uint32_t idHnd = 0;
     148
    135149            /*
    136              * Just return if the send buffer wasn't full till now and
    137              * the caller wants to check whether writing is possible with
    138              * the event set.
     150             * Just check for data available to be read if the send buffer wasn't full till now and
     151             * the caller wants to check whether writing is possible with the event set.
    139152             *
    140153             * On Windows the write event is only posted after a send operation returned
     
    143156             */
    144157            if (   (fEvts & RTPOLL_EVT_WRITE)
    145                 && !pThis->fXmitBufFull)
    146             {
    147                 *pfEvts = RTPOLL_EVT_WRITE;
    148                 return VINF_SUCCESS;
    149             }
    150 
    151             /* Always include error event. */
    152             fEvts |= RTPOLL_EVT_ERROR;
    153             rc = RTPollSetEventsChange(pThis->hPollSet, DRVTCP_POLLSET_ID_SOCKET, fEvts);
    154             AssertRC(rc);
    155         }
    156     }
    157 
    158     if (RT_SUCCESS(rc))
    159     {
    160         while (RT_SUCCESS(rc))
    161         {
    162             uint32_t fEvtsRecv = 0;
    163             uint32_t idHnd = 0;
     158                && !pThis->fXmitBufFull
     159                && pThis->fTcpSockInPollSet)
     160                cMillies = 0;
    164161
    165162            rc = RTPoll(pThis->hPollSet, cMillies, &fEvtsRecv, &idHnd);
     
    209206                        if (fEvtsRecv & RTPOLL_EVT_WRITE)
    210207                            pThis->fXmitBufFull = false;
     208                        else if (!pThis->fXmitBufFull)
     209                            fEvtsRecv |= RTPOLL_EVT_WRITE;
    211210                        *pfEvts = fEvtsRecv;
    212211                        break;
    213212                    }
    214213                }
     214            }
     215            else if (   rc == VERR_TIMEOUT
     216                     && !pThis->fXmitBufFull)
     217            {
     218                *pfEvts = RTPOLL_EVT_WRITE;
     219                rc = VINF_SUCCESS;
     220                break;
    215221            }
    216222        }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette