]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/gsockmsw.cpp
Update configuration for OpenVMS
[wxWidgets.git] / src / msw / gsockmsw.cpp
index 79969ac301e8b3a776ca764bd99875bb357d3ca7..1975b983a058b3a3dc3f0a99b5bd1dd79b697770 100644 (file)
@@ -38,6 +38,9 @@
 
 #include "wx/gsocket.h"
 #include "wx/apptrait.h"
+#include "wx/link.h"
+
+wxFORCE_LINK_THIS_MODULE(gsockmsw)
 
 extern "C" WXDLLIMPEXP_BASE HINSTANCE wxGetInstance();
 #define INSTANCE wxGetInstance()
@@ -310,10 +313,10 @@ void GSocketMSWManager::Destroy_Socket(GSocket *socket)
 {
   /* Remove the socket from the list */
   EnterCriticalSection(&critical);
-  if ( socket->IsOk() )
-  {
-      const int msgnum = socket->m_msgnumber;
 
+  const int msgnum = socket->m_msgnumber;
+  if ( msgnum )
+  {
       // we need to remove any pending messages for this socket to avoid having
       // them sent to a new socket which could reuse the same message number as
       // soon as we destroy this one
@@ -323,6 +326,7 @@ void GSocketMSWManager::Destroy_Socket(GSocket *socket)
 
       socketList[msgnum - WM_USER] = NULL;
   }
+  //else: the socket has never been created successfully
 
   LeaveCriticalSection(&critical);
 }
@@ -363,7 +367,7 @@ LRESULT CALLBACK _GSocket_Internal_WinProc(HWND hWnd,
      * destroyed) and for safety, check that the m_fd field
      * is what we expect it to be.
      */
-    if ((socket != NULL) && (socket->m_fd == wParam))
+    if ((socket != NULL) && ((WPARAM)socket->m_fd == wParam))
     {
       switch WSAGETSELECTEVENT(lParam)
       {
@@ -383,9 +387,6 @@ LRESULT CALLBACK _GSocket_Internal_WinProc(HWND hWnd,
 
       if (event != -1)
       {
-        cback = socket->m_cbacks[event];
-        data = socket->m_data[event];
-
         if (event == GSOCK_LOST)
           socket->m_detected = GSOCK_LOST_FLAG;
         else
@@ -393,16 +394,10 @@ LRESULT CALLBACK _GSocket_Internal_WinProc(HWND hWnd,
       }
     }
 
-    /* OK, we can now leave the critical section because we have
-     * already obtained the callback address (we make no further
-     * accesses to socket->whatever). However, the app should
-     * be prepared to handle events from a socket that has just
-     * been closed!
-     */
     LeaveCriticalSection(&critical);
 
-    if (cback != NULL)
-      (cback)(socket, event, data);
+    if ( socket )
+        socket->NotifyOnStateChange(event);
 
     return (LRESULT) 0;
   }
@@ -470,6 +465,6 @@ static struct ManagerSetter
         static GSocketMSWManager s_manager;
         wxAppTraits::SetDefaultSocketManager(&s_manager);
     }
-} gsm_managerSetter;
+} gs_managerSetter;
 
 #endif  // wxUSE_SOCKETS