In GSocket_Destroy reorder GUI_Destroy and Shutdown when compiling for Darwin.

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
This commit is contained in:
David Elliott
2003-12-24 02:49:07 +00:00
parent f775c30dd9
commit 1c7edd1d3c

View File

@@ -269,12 +269,20 @@ void GSocket_destroy(GSocket *socket)
{
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);
#ifndef __DARWIN__
/* Per-socket GUI-specific cleanup */
_GSocket_GUI_Destroy_Socket(socket);
#endif
/* Destroy private addresses */
if (socket->m_local)
@@ -792,8 +800,11 @@ int GSocket_Read(GSocket *socket, char *buffer, int size)
assert(socket != NULL);
/* When using CFSocket we MUST NOT reenable events until we finish reading */
#ifndef __DARWIN__
/* Reenable INPUT events */
_GSocket_Enable(socket, GSOCK_INPUT);
#endif
if (socket->m_fd == INVALID_SOCKET || socket->m_server)
{
@@ -819,6 +830,11 @@ int GSocket_Read(GSocket *socket, char *buffer, int size)
socket->m_error = GSOCK_IOERR;
}
#ifdef __DARWIN__
/* Reenable INPUT events */
_GSocket_Enable(socket, GSOCK_INPUT);
#endif
return ret;
}