Allow disabling events for blocking sockets in Unix version
It should still be possible to use DoEnableEvents() to disable events
for blocking sockets and this can be useful if a previously non-blocking
socket became blocking due to a SetFlags(wxSOCKET_BLOCK) call, so adjust
the fix of e18c8fd29a
(see #17031) to
avoid calling EnableEvents() for blocking sockets instead of ignoring
them in DoEnableEvents() itself.
Also add an assert checking that we never try enabling events for
blocking sockets as this still doesn't make sense and so shouldn't
happen.
No real changes yet, but this is necessary for the upcoming commits.
See #12886.
This commit is contained in:
@@ -40,6 +40,10 @@ public:
|
|||||||
|
|
||||||
virtual void ReenableEvents(wxSocketEventFlags flags) wxOVERRIDE
|
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
|
// enable the notifications about input/output being available again in
|
||||||
// case they were disabled by OnRead/WriteWaiting()
|
// case they were disabled by OnRead/WriteWaiting()
|
||||||
//
|
//
|
||||||
|
@@ -90,17 +90,18 @@ wxSocketError wxSocketImplUnix::GetLastError() const
|
|||||||
|
|
||||||
void wxSocketImplUnix::DoEnableEvents(int flags, bool enable)
|
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();
|
wxSocketManager * const manager = wxSocketManager::Get();
|
||||||
if (!manager)
|
if (!manager)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( enable )
|
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 )
|
if ( flags & wxSOCKET_INPUT_FLAG )
|
||||||
manager->Install_Callback(this, wxSOCKET_INPUT);
|
manager->Install_Callback(this, wxSOCKET_INPUT);
|
||||||
if ( flags & wxSOCKET_OUTPUT_FLAG )
|
if ( flags & wxSOCKET_OUTPUT_FLAG )
|
||||||
|
Reference in New Issue
Block a user