Permalink
Browse files

Added a method to unregister all callbacks for a socket.

  • Loading branch information...
1 parent ef1ce6e commit 61427d9b8b36b20168bac006171e1489eab4b62f John committed Oct 18, 2012
Showing with 15 additions and 0 deletions.
  1. +14 −0 Socket.c
  2. +1 −0 Socket.h
View
@@ -364,3 +364,17 @@ void SAL_Socket_RegisterReadCallback(SAL_Socket socket, SAL_Socket_ReadCallback
SAL_Mutex_Release(asyncSocketLookupMutex);
}
+
+/**
+ * Unregisters all callbacks for @a socket.
+ *
+ * @param socket The socket to clear all callbacks from
+ */
+void SAL_Socket_UnregisterSocketCallbacks(SAL_Socket socket) {
+ SAL_Mutex_Acquire(&asyncSocketLookupMutex);
+
+ LinkedList_Remove(&asyncSocketList, socket);
+ Lookup_Remove(&asyncSocketLookup, (uint64)socket);
+
+ SAL_Mutex_Release(&asyncSocketLookupMutex);
+}
View
@@ -21,5 +21,6 @@ public void SAL_Socket_Close(SAL_Socket socket);
public uint32 SAL_Socket_Read(SAL_Socket socket, uint8* buffer, uint32 bufferSize);
public boolean SAL_Socket_Write(SAL_Socket socket, const uint8* toWrite, uint32 writeAmount);
public void SAL_Socket_RegisterReadCallback(SAL_Socket socket, SAL_Socket_ReadCallback callback);
+public void SAL_Socket_UnregisterSocketCallbacks(SAL_Socket socket);
#endif

0 comments on commit 61427d9

Please sign in to comment.