]> git.saurik.com Git - wxWidgets.git/commitdiff
don't call OnWriteWaiting() if we lost connection in OnReadWaiting() called just...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 5 Jul 2009 21:42:56 +0000 (21:42 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 5 Jul 2009 21:42:56 +0000 (21:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61336 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/unix/private/sockunix.h
src/gtk/sockgtk.cpp
src/gtk1/sockgtk.cpp
src/motif/sockmot.cpp
src/os2/sockpm.cpp

index a175e322d23c807ea9c2ab80e2165be3c806a493..9ba332b8421fb56bb7bfbb23ec46e190e5740eee 100644 (file)
@@ -204,7 +204,7 @@ public:
 private:
     // these functions map directly to XtAdd/RemoveInput() or
     // gdk_input_add/remove()
 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;
 };
 
     virtual void RemoveInput(int fd) = 0;
 };
 
index 876891cfb0cdc0965eafaa90b6cea094b80a97b9..c8d449cfd86638627b813b39f108f03d8ed3614c 100644 (file)
@@ -28,10 +28,19 @@ void wxSocket_GDK_Input(gpointer data,
                         gint WXUNUSED(source),
                         GdkInputCondition condition)
 {
                         gint WXUNUSED(source),
                         GdkInputCondition condition)
 {
-    wxSocketImpl * const handler = static_cast<wxSocketImpl *>(data);
+    wxSocketImplUnix * const handler = static_cast<wxSocketImplUnix *>(data);
 
     if ( condition & GDK_INPUT_READ )
 
     if ( condition & GDK_INPUT_READ )
+    {
         handler->OnReadWaiting();
         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();
 }
     if ( condition & GDK_INPUT_WRITE )
         handler->OnWriteWaiting();
 }
@@ -40,7 +49,7 @@ void wxSocket_GDK_Input(gpointer data,
 class GTKSocketManager : public wxSocketInputBasedManager
 {
 public:
 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
                (
     {
         return gdk_input_add
                (
index 876891cfb0cdc0965eafaa90b6cea094b80a97b9..c8d449cfd86638627b813b39f108f03d8ed3614c 100644 (file)
@@ -28,10 +28,19 @@ void wxSocket_GDK_Input(gpointer data,
                         gint WXUNUSED(source),
                         GdkInputCondition condition)
 {
                         gint WXUNUSED(source),
                         GdkInputCondition condition)
 {
-    wxSocketImpl * const handler = static_cast<wxSocketImpl *>(data);
+    wxSocketImplUnix * const handler = static_cast<wxSocketImplUnix *>(data);
 
     if ( condition & GDK_INPUT_READ )
 
     if ( condition & GDK_INPUT_READ )
+    {
         handler->OnReadWaiting();
         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();
 }
     if ( condition & GDK_INPUT_WRITE )
         handler->OnWriteWaiting();
 }
@@ -40,7 +49,7 @@ void wxSocket_GDK_Input(gpointer data,
 class GTKSocketManager : public wxSocketInputBasedManager
 {
 public:
 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
                (
     {
         return gdk_input_add
                (
index f38ace8e97ee18a30a564cace392114b30ce3a87..6e347bfe60ee4cc154c7dfd66b03602feb1c8e66 100644 (file)
@@ -23,7 +23,7 @@ extern "C" {
 static void wxSocket_Motif_Input(XtPointer data, int *WXUNUSED(fid),
                                  XtInputId *WXUNUSED(id))
 {
 static void wxSocket_Motif_Input(XtPointer data, int *WXUNUSED(fid),
                                  XtInputId *WXUNUSED(id))
 {
-    wxSocketImpl * const handler = static_cast<wxSocketImpl *>(data);
+    wxSocketImplUnix * const handler = static_cast<wxSocketImplUnix *>(data);
 
     handler->OnReadWaiting();
 }
 
     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))
 {
 static void wxSocket_Motif_Output(XtPointer data, int *WXUNUSED(fid),
                                   XtInputId *WXUNUSED(id))
 {
-    wxSocketImpl * const handler = static_cast<wxSocketImpl *>(data);
+    wxSocketImplUnix * const handler = static_cast<wxSocketImplUnix *>(data);
 
     handler->OnWriteWaiting();
 }
 
     handler->OnWriteWaiting();
 }
@@ -41,7 +41,7 @@ static void wxSocket_Motif_Output(XtPointer data, int *WXUNUSED(fid),
 class MotifSocketManager : public wxSocketInputBasedManager
 {
 public:
 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
                (
     {
         return XtAppAddInput
                (
index 540f647a36c5af8ba5fe752e5538476974a14f0c..2c7d7a209aff00912d5297c40b16c413f791c719 100644 (file)
 
 static void wxSocket_PM_Input(void *data)
 {
 
 static void wxSocket_PM_Input(void *data)
 {
-    wxSocketImpl *handler = static_cast<wxSocketImpl *>(data);
+    wxSocketImplUnix *handler = static_cast<wxSocketImplUnix *>(data);
 
     handler->OnReadWaiting();
 }
 
 static void wxSocket_PM_Output(void *data)
 {
 
     handler->OnReadWaiting();
 }
 
 static void wxSocket_PM_Output(void *data)
 {
-    wxSocketImpl *handler = static_cast<wxSocketImpl *>(data);
+    wxSocketImplUnix *handler = static_cast<wxSocketImplUnix *>(data);
 
     handler->OnWriteWaiting();
 }
 
     handler->OnWriteWaiting();
 }
@@ -38,7 +38,7 @@ static void wxSocket_PM_Output(void *data)
 class PMSocketManager : public wxSocketInputBasedManager
 {
 public:
 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,
     {
       if (d == FD_OUTPUT)
           return wxTheApp->AddSocketHandler(fd, wxSockWriteMask,