This is necessary to comply with the Apple documentation for CFSocket which
states quite explcitly that the CFSocket must be invalidated prior to close.
Likewise in GSocket_Read don't enable input events until we have finished
reading the data. This is necessary because an input event will be
immediately generated but all the data will have been read by the current
callback which leads to the GSocket code thinking the connection has been
lost and when wxYield recursion is involved will lead to crashes or an assert.
Because we are doing a compile time test only for Darwin this will also
affect wxGTK running on Darwin. It appears possible for the new order to work
on all platforms but more testing would be required.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24997
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
{
assert(socket != NULL);
{
assert(socket != NULL);
+ /* When using CFSocket we MUST invalidate before closing the fd */
+#ifdef __DARWIN__
+ /* Per-socket GUI-specific cleanup */
+ _GSocket_GUI_Destroy_Socket(socket);
+#endif
+
/* Check that the socket is really shutdowned */
if (socket->m_fd != INVALID_SOCKET)
GSocket_Shutdown(socket);
/* Check that the socket is really shutdowned */
if (socket->m_fd != INVALID_SOCKET)
GSocket_Shutdown(socket);
/* Per-socket GUI-specific cleanup */
_GSocket_GUI_Destroy_Socket(socket);
/* Per-socket GUI-specific cleanup */
_GSocket_GUI_Destroy_Socket(socket);
/* Destroy private addresses */
if (socket->m_local)
/* Destroy private addresses */
if (socket->m_local)
+ /* When using CFSocket we MUST NOT reenable events until we finish reading */
+#ifndef __DARWIN__
/* Reenable INPUT events */
_GSocket_Enable(socket, GSOCK_INPUT);
/* Reenable INPUT events */
_GSocket_Enable(socket, GSOCK_INPUT);
if (socket->m_fd == INVALID_SOCKET || socket->m_server)
{
if (socket->m_fd == INVALID_SOCKET || socket->m_server)
{
socket->m_error = GSOCK_IOERR;
}
socket->m_error = GSOCK_IOERR;
}
+#ifdef __DARWIN__
+ /* Reenable INPUT events */
+ _GSocket_Enable(socket, GSOCK_INPUT);
+#endif
+