Fix wxSocket::WaitForAccept() in blocking mode.

When wxSocket::WaitForAccept() was called from another thread or on a socket
with wxSOCKET_BLOCK flag it didn't work because it called
wxSocketImpl::Select() with wxSOCKET_CONNECTION_FLAG which was only handled
for the client sockets in this function.

Handle it now for the server ones too, this should allow blocking server
sockets to work again.

Closes #12836.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68492 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-08-02 19:46:40 +00:00
parent d6f2b04c72
commit 9be02147f0

View File

@@ -1297,17 +1297,31 @@ wxSocketEventFlags wxSocketImpl::Select(wxSocketEventFlags flags,
exceptfds; // always want to know about errors
if ( flags & wxSOCKET_INPUT_FLAG )
{
preadfds = &readfds;
if ( flags & wxSOCKET_OUTPUT_FLAG )
pwritefds = &writefds;
// When using non-blocking connect() the client socket becomes connected
// (successfully or not) when it becomes writable but when using
// non-blocking accept() the server socket becomes connected when it
// becomes readable.
if ( flags & wxSOCKET_CONNECTION_FLAG )
{
if ( m_server )
preadfds = &readfds;
else
pwritefds = &writefds;
}
if ( preadfds )
{
wxFD_ZERO(preadfds);
wxFD_SET(m_fd, preadfds);
}
// when using non-blocking connect() the socket becomes connected
// (successfully or not) when it becomes writable
if ( flags & (wxSOCKET_OUTPUT_FLAG | wxSOCKET_CONNECTION_FLAG) )
if ( pwritefds )
{
pwritefds = &writefds;
wxFD_ZERO(pwritefds);
wxFD_SET(m_fd, pwritefds);
}