Skip to content

Commit

Permalink
Fix a nasty issue of replications all ending in crashes due to not im…
Browse files Browse the repository at this point in the history
…plementing the native disposal method
  • Loading branch information
borrrden committed Jan 31, 2018
1 parent 45079f0 commit cc0ab52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Couchbase.Lite/Sync/WebSocketTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static unsafe class WebSocketTransport

public static void RegisterWithC4()
{
SocketFactory.RegisterFactory(DoOpen, DoClose, DoWrite, DoCompleteReceive);
SocketFactory.RegisterFactory(DoOpen, DoClose, DoWrite, DoCompleteReceive, DoDispose);
SocketFactory.SetErrorHandler(DoError);
}

Expand Down Expand Up @@ -84,6 +84,17 @@ private static void DoCompleteReceive(C4Socket* socket, ulong bytecount)
socketWrapper.CompletedReceive(bytecount);
}

private static void DoDispose(C4Socket* socket)
{
var id = (int) socket->nativeHandle;
if (id == 0) {
Log.To.Sync.E(Tag, "DoDispose reached after close");
return;
}

Sockets.Remove(id);
}

private static void DoError(C4Socket* socket, Exception e)
{
Log.To.Sync.E(Tag, "Websocket Error", e);
Expand Down

0 comments on commit cc0ab52

Please sign in to comment.