]> git.saurik.com Git - wxWidgets.git/commitdiff
don't call wxSocketImpl::ReenableEvents() if the socket was closed while reading...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 3 Jul 2009 14:28:02 +0000 (14:28 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 3 Jul 2009 14:28:02 +0000 (14:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61311 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/socket.cpp

index 71cfcc6cce9d11dd35746b98bf5a942e49cacf95..3a9de3950c3d944d34514680210174e4fb321020 100644 (file)
@@ -213,7 +213,11 @@ public:
     {
         m_socket->m_reading = false;
 
-        m_socket->m_impl->ReenableEvents(wxSOCKET_INPUT_FLAG);
+        // connection could have been lost while reading, in this case calling
+        // ReenableEvents() would assert and is not necessary anyhow
+        wxSocketImpl * const impl = m_socket->m_impl;
+        if ( impl && impl->m_fd != INVALID_SOCKET )
+            impl->ReenableEvents(wxSOCKET_INPUT_FLAG);
     }
 
 private:
@@ -231,13 +235,15 @@ public:
         wxASSERT_MSG( !m_socket->m_writing, "write reentrancy?" );
 
         m_socket->m_writing = true;
-
-        m_socket->m_impl->ReenableEvents(wxSOCKET_OUTPUT_FLAG);
     }
 
     ~wxSocketWriteGuard()
     {
         m_socket->m_writing = false;
+
+        wxSocketImpl * const impl = m_socket->m_impl;
+        if ( impl && impl->m_fd != INVALID_SOCKET )
+            impl->ReenableEvents(wxSOCKET_OUTPUT_FLAG);
     }
 
 private: