Skip to content

Commit c454382

Browse files
authored
CBL-7013: Native crash when using LiteCore 3.3.0-80 (#2299)
* CBL-7013: Native crash when using LiteCore 3.3.0-80 I used LiteCore 3.3.0-80 to reproduce the native crash when the following tests are reinstated, - ReplicatorPendingDocIdTest - ReplicatorLocal2LocalTest The issue is specific to LoopbackWebSocket. We need to guard against the case when Replicator::_onConnect comes after it is stopped.
1 parent a12058c commit c454382

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Replicator/Replicator.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,14 @@ namespace litecore::repl {
607607
}
608608

609609
void Replicator::_onConnect() {
610+
// onConnect may come after the replicator is asked to stop. This situation is
611+
// guarded against in WebSocketImpl::onConnect. However, LoopbackWebSocket does
612+
// not go throuth WebSocketImpl. We catch the case here.
613+
if ( _connectionState != Connection::kConnecting ) {
614+
logInfo("Replicator not in connecting state (connectionState=%d); ignoring onConnect.", _connectionState);
615+
return;
616+
}
617+
610618
logInfo("Connected!");
611619

612620
if ( auto socket = connection().webSocket(); socket->role() == websocket::Role::Client ) {

0 commit comments

Comments
 (0)