diff --git a/include/wx/unix/private/sockunix.h b/include/wx/unix/private/sockunix.h index 05d043d354..2e4506bcbc 100644 --- a/include/wx/unix/private/sockunix.h +++ b/include/wx/unix/private/sockunix.h @@ -40,6 +40,10 @@ public: virtual void ReenableEvents(wxSocketEventFlags flags) wxOVERRIDE { + // Events are only ever used for non-blocking sockets. + if ( GetSocketFlags() & wxSOCKET_BLOCK ) + return; + // enable the notifications about input/output being available again in // case they were disabled by OnRead/WriteWaiting() // diff --git a/src/unix/sockunix.cpp b/src/unix/sockunix.cpp index 78542648ef..e1ffee352a 100644 --- a/src/unix/sockunix.cpp +++ b/src/unix/sockunix.cpp @@ -90,17 +90,18 @@ 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; if ( enable ) { + // We should never try to enable events for the blocking sockets, they + // should be usable from the other threads and the events only work for + // the sockets used by the main one. + wxASSERT_MSG( !(GetSocketFlags() & wxSOCKET_BLOCK), + "enabling events for a blocking socket?" ); + if ( flags & wxSOCKET_INPUT_FLAG ) manager->Install_Callback(this, wxSOCKET_INPUT); if ( flags & wxSOCKET_OUTPUT_FLAG )