X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/60b0bd1dd1f1cc5bd9a7c225925ab882783f9e6a..e1cffcd6e37ef0c3e35cc02a67cbf8c6e18f588f:/src/unix/gsocket.cpp diff --git a/src/unix/gsocket.cpp b/src/unix/gsocket.cpp index ac1610a0b8..becd67f59c 100644 --- a/src/unix/gsocket.cpp +++ b/src/unix/gsocket.cpp @@ -159,12 +159,11 @@ int _System soclose(int); #define UNMASK_SIGNAL() } #else + extern "C" { typedef void (*wxSigHandler)(int); } #define MASK_SIGNAL() \ { \ - void (*old_handler)(int); \ - \ - old_handler = signal(SIGPIPE, SIG_IGN); + wxSigHandler old_handler = signal(SIGPIPE, SIG_IGN); #define UNMASK_SIGNAL() \ signal(SIGPIPE, old_handler); \ @@ -717,9 +716,15 @@ GSocketError GSocket::Connect(GSocketStream stream) /* Connect it to the peer address, with a timeout (see below) */ ret = connect(m_fd, m_peer->m_addr, m_peer->m_len); - /* We only call Enable_Events if we know e aren't shutting down the socket */ - - if (m_non_blocking) + /* We only call Enable_Events if we know we aren't shutting down the socket. + * NB: Enable_Events needs to be called whether the socket is blocking or + * non-blocking, it just shouldn't be called prior to knowing there is a + * connection _if_ blocking sockets are being used. + * If connect above returns 0, we are already connected and need to make the + * call to Enable_Events now. + */ + + if (m_non_blocking || ret == 0) { gs_gui_functions->Enable_Events(this); }