]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/corefoundation/gsockosx.cpp
Make sizing logic clearer, at the expense of a few duplicated lines.
[wxWidgets.git] / src / mac / corefoundation / gsockosx.cpp
index 9e057ad1f48c215661b529743910197dc9f4e04f..afbf5514777811a1cf255598009b8a3a0ce47771 100644 (file)
@@ -1,12 +1,12 @@
 /* -------------------------------------------------------------------------
  * Project: GSocket (Generic Socket) for WX
- * Name:    gsockosx.c
+ * Name:    src/mac/corefoundation/gsockosx.c
  * Purpose: GSocket: Mac OS X mach-o part
  * CVSID:   $Id$
  * Mac code by Brian Victor, February 2002.  Email comments to bhv1@psu.edu
  * ------------------------------------------------------------------------- */
 
-#include "wx/setup.h"
+#include "wx/wxprec.h"
 
 #if wxUSE_SOCKETS
 
@@ -28,8 +28,8 @@ struct MacGSocketData
 // We will store the main loop's reference when Initialize is called
 static CFRunLoopRef s_mainRunLoop = NULL;
 
-void Mac_Socket_Callback(CFSocketRef s, CFSocketCallBackType callbackType,
-                         CFDataRef address, const void* data, void* info)
+void Mac_Socket_Callback(CFSocketRef WXUNUSED(s), CFSocketCallBackType callbackType,
+                         CFDataRef WXUNUSED(address), const void* data, void* info)
 {
   GSocket* socket = (GSocket*)info;
   struct MacGSocketData* macdata;
@@ -75,7 +75,7 @@ struct MacGSocketData* _GSocket_Get_Mac_Socket(GSocket *socket)
   cont.info = socket;
 
   CFSocketRef cf = CFSocketCreateWithNative(NULL, socket->m_fd,
-                       ALL_CALLBACK_TYPES, Mac_Socket_Callback, &cont);
+                   ALL_CALLBACK_TYPES, Mac_Socket_Callback, &cont);
   CFRunLoopSourceRef source = CFSocketCreateRunLoopSource(NULL, cf, 0);
   assert(source);
   socket->m_gui_dependent = (char*)data;
@@ -206,6 +206,9 @@ void GSocketGUIFunctionsTableConcrete::Disable_Events(GSocket *socket)
     /* CFSocketInvalidate does CFRunLoopRemoveSource anyway */
     CFRunLoopRemoveSource(s_mainRunLoop, data->source, kCFRunLoopCommonModes);
     CFSocketInvalidate(data->socket);
+
+    // CFSocketInvalidate has closed the socket so we want to make sure GSocket knows this
+    socket->m_fd = -1 /*INVALID_SOCKET*/;
 }
 
 #endif // wxUSE_SOCKETS