From: Vadim Zeitlin Date: Tue, 20 Jan 2009 23:53:35 +0000 (+0000) Subject: make sure events are enabled in DoWait() before starting to wait for them (closes... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/5ab2f2575d0066dfd8beaf8901a252e346a2f8dc?ds=inline make sure events are enabled in DoWait() before starting to wait for them (closes #10396) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58250 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/socket.cpp b/src/common/socket.cpp index aba83174a4..abe4f83810 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -1328,6 +1328,20 @@ wxSocketBase::DoWait(long timeout, wxSocketEventFlags flags) eventLoop = NULL; } + // Make sure the events we're interested in are enabled before waiting for + // them: this is really necessary here as otherwise this could happen: + // 1. DoRead(wxSOCKET_WAITALL) is called + // 2. There is nothing to read so DoWait(wxSOCKET_INPUT_FLAG) is called + // 3. Some, but not all data appears, wxSocketImplUnix::OnReadWaiting() + // is called and wxSOCKET_INPUT_FLAG events are disabled in it + // 4. Because of wxSOCKET_WAITALL we call DoWait() again but the events + // are still disabled and we block forever + // + // More elegant solution would be nice but for now simply re-enabling the + // events here will do + m_impl->ReenableEvents(flags & (wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG)); + + // Wait until we receive the event we're waiting for or the timeout expires // (but note that we always execute the loop at least once, even if timeout // is 0 as this is used for polling)