From: Vadim Zeitlin Date: Sun, 5 Jul 2009 21:42:56 +0000 (+0000) Subject: don't call OnWriteWaiting() if we lost connection in OnReadWaiting() called just... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ee0995b09b0f91ceeaff41129ec7228d389d33ff?ds=inline don't call OnWriteWaiting() if we lost connection in OnReadWaiting() called just before it (closes #10963) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61336 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/unix/private/sockunix.h b/include/wx/unix/private/sockunix.h index a175e322d2..9ba332b842 100644 --- a/include/wx/unix/private/sockunix.h +++ b/include/wx/unix/private/sockunix.h @@ -204,7 +204,7 @@ public: private: // these functions map directly to XtAdd/RemoveInput() or // gdk_input_add/remove() - virtual int AddInput(wxSocketImpl *handler, int fd, SocketDir d) = 0; + virtual int AddInput(wxSocketImplUnix *handler, int fd, SocketDir d) = 0; virtual void RemoveInput(int fd) = 0; }; diff --git a/src/gtk/sockgtk.cpp b/src/gtk/sockgtk.cpp index 876891cfb0..c8d449cfd8 100644 --- a/src/gtk/sockgtk.cpp +++ b/src/gtk/sockgtk.cpp @@ -28,10 +28,19 @@ void wxSocket_GDK_Input(gpointer data, gint WXUNUSED(source), GdkInputCondition condition) { - wxSocketImpl * const handler = static_cast(data); + wxSocketImplUnix * const handler = static_cast(data); if ( condition & GDK_INPUT_READ ) + { handler->OnReadWaiting(); + + // we could have lost connection while reading in which case we + // shouldn't call OnWriteWaiting() as the socket is now closed and it + // would assert + if ( handler->m_fd == INVALID_SOCKET ) + return; + } + if ( condition & GDK_INPUT_WRITE ) handler->OnWriteWaiting(); } @@ -40,7 +49,7 @@ void wxSocket_GDK_Input(gpointer data, class GTKSocketManager : public wxSocketInputBasedManager { public: - virtual int AddInput(wxSocketImpl *handler, int fd, SocketDir d) + virtual int AddInput(wxSocketImplUnix *handler, int fd, SocketDir d) { return gdk_input_add ( diff --git a/src/gtk1/sockgtk.cpp b/src/gtk1/sockgtk.cpp index 876891cfb0..c8d449cfd8 100644 --- a/src/gtk1/sockgtk.cpp +++ b/src/gtk1/sockgtk.cpp @@ -28,10 +28,19 @@ void wxSocket_GDK_Input(gpointer data, gint WXUNUSED(source), GdkInputCondition condition) { - wxSocketImpl * const handler = static_cast(data); + wxSocketImplUnix * const handler = static_cast(data); if ( condition & GDK_INPUT_READ ) + { handler->OnReadWaiting(); + + // we could have lost connection while reading in which case we + // shouldn't call OnWriteWaiting() as the socket is now closed and it + // would assert + if ( handler->m_fd == INVALID_SOCKET ) + return; + } + if ( condition & GDK_INPUT_WRITE ) handler->OnWriteWaiting(); } @@ -40,7 +49,7 @@ void wxSocket_GDK_Input(gpointer data, class GTKSocketManager : public wxSocketInputBasedManager { public: - virtual int AddInput(wxSocketImpl *handler, int fd, SocketDir d) + virtual int AddInput(wxSocketImplUnix *handler, int fd, SocketDir d) { return gdk_input_add ( diff --git a/src/motif/sockmot.cpp b/src/motif/sockmot.cpp index f38ace8e97..6e347bfe60 100644 --- a/src/motif/sockmot.cpp +++ b/src/motif/sockmot.cpp @@ -23,7 +23,7 @@ extern "C" { static void wxSocket_Motif_Input(XtPointer data, int *WXUNUSED(fid), XtInputId *WXUNUSED(id)) { - wxSocketImpl * const handler = static_cast(data); + wxSocketImplUnix * const handler = static_cast(data); handler->OnReadWaiting(); } @@ -31,7 +31,7 @@ static void wxSocket_Motif_Input(XtPointer data, int *WXUNUSED(fid), static void wxSocket_Motif_Output(XtPointer data, int *WXUNUSED(fid), XtInputId *WXUNUSED(id)) { - wxSocketImpl * const handler = static_cast(data); + wxSocketImplUnix * const handler = static_cast(data); handler->OnWriteWaiting(); } @@ -41,7 +41,7 @@ static void wxSocket_Motif_Output(XtPointer data, int *WXUNUSED(fid), class MotifSocketManager : public wxSocketInputBasedManager { public: - virtual int AddInput(wxSocketImpl *handler, int fd, SocketDir d) + virtual int AddInput(wxSocketImplUnix *handler, int fd, SocketDir d) { return XtAppAddInput ( diff --git a/src/os2/sockpm.cpp b/src/os2/sockpm.cpp index 540f647a36..2c7d7a209a 100644 --- a/src/os2/sockpm.cpp +++ b/src/os2/sockpm.cpp @@ -23,14 +23,14 @@ static void wxSocket_PM_Input(void *data) { - wxSocketImpl *handler = static_cast(data); + wxSocketImplUnix *handler = static_cast(data); handler->OnReadWaiting(); } static void wxSocket_PM_Output(void *data) { - wxSocketImpl *handler = static_cast(data); + wxSocketImplUnix *handler = static_cast(data); handler->OnWriteWaiting(); } @@ -38,7 +38,7 @@ static void wxSocket_PM_Output(void *data) class PMSocketManager : public wxSocketInputBasedManager { public: - virtual int AddInput(wxSocketImpl *handler, int fd, SocketDir d) + virtual int AddInput(wxSocketImplUnix *handler, int fd, SocketDir d) { if (d == FD_OUTPUT) return wxTheApp->AddSocketHandler(fd, wxSockWriteMask,