From e18c8fd29a10b1b87ea5cff7c5b3a16fe5b32690 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Jul 2015 16:41:08 +0200 Subject: [PATCH] Never use events for blocking sockets under Unix. Events are not needed for this kind of sockets, using wxSOCKET_BLOCK is supposed to ensure that calling socket IO operations blocks until the bytes are read/written without dispatching any events. See #17031. --- include/wx/private/socket.h | 3 +++ src/unix/sockunix.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/include/wx/private/socket.h b/include/wx/private/socket.h index 973b764f7d..362aa61982 100644 --- a/include/wx/private/socket.h +++ b/include/wx/private/socket.h @@ -308,6 +308,9 @@ public: protected: wxSocketImpl(wxSocketBase& wxsocket); + // get the associated socket flags + wxSocketFlags GetSocketFlags() const { return m_wxsocket->GetFlags(); } + // true if we're a listening stream socket bool m_server; diff --git a/src/unix/sockunix.cpp b/src/unix/sockunix.cpp index 96638c0248..78542648ef 100644 --- a/src/unix/sockunix.cpp +++ b/src/unix/sockunix.cpp @@ -90,6 +90,11 @@ wxSocketError wxSocketImplUnix::GetLastError() const void wxSocketImplUnix::DoEnableEvents(int flags, bool enable) { + // No events for blocking sockets, they should be usable from the other + // threads and the events only work for the sockets used by the main one. + if ( GetSocketFlags() & wxSOCKET_BLOCK ) + return; + wxSocketManager * const manager = wxSocketManager::Get(); if (!manager) return;