Skip to content

Commit

Permalink
Thread-safety fix in CBLWebSocketChangeTracker
Browse files Browse the repository at this point in the history
I haven’t seen this cause problems, but fixed it just in case.
  • Loading branch information
snej committed Mar 24, 2014
1 parent 5041a4e commit 3bf91b7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Source/ChangeTracker/CBLWebSocketChangeTracker.m
Expand Up @@ -86,11 +86,13 @@ - (void) stop {
// THESE ARE CALLED ON THE WEBSOCKET'S DISPATCH QUEUE, NOT MY THREAD!!

- (void) webSocketDidOpen: (WebSocket *)ws {
LogTo(ChangeTrackerVerbose, @"%@: WebSocket opened", self);
// Now that the WebSocket is open, send the changes-feed options (the ones that would have
// gone in the POST body if this were HTTP-based.)
if (self.usePOST)
[ws sendBinaryMessage: self.changesFeedPOSTBody];
MYOnThread(_thread, ^{
LogTo(ChangeTrackerVerbose, @"%@: WebSocket opened", self);
// Now that the WebSocket is open, send the changes-feed options (the ones that would have
// gone in the POST body if this were HTTP-based.)
if (self.usePOST)
[ws sendBinaryMessage: self.changesFeedPOSTBody];
});
}

/** Called when a WebSocket receives a textual message from its peer. */
Expand Down

0 comments on commit 3bf91b7

Please sign in to comment.