Skip to content

Commit de7e81e

Browse files
committed
Build-To-Use: 3.3.0-71
71af00e Fixed BonjourProvider not notifying some peer changes (#2280) CBL-6960: Consider to restore the logs in destructors f35bcc4 Added C4Replicator::Parameters::removeCollection() (#2279) Fixed adding collections to C4Listener. (EE)
2 parents b60da1d + 71af00e commit de7e81e

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed

C/Cpp_include/c4PeerDiscovery.hh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,31 +164,21 @@ class C4PeerDiscovery {
164164
friend class C4Peer;
165165
friend class C4PeerDiscoveryProvider;
166166

167-
/// Reports that browsing has started, stopped or failed.
168-
/// If `state` is false, this method will call `removePeer` on all online peers.
169167
void browseStateChanged(C4PeerDiscoveryProvider*, bool state, C4Error = {});
170168

171-
/// Reports that publishing has started, stopped or failed.
172169
void publishStateChanged(C4PeerDiscoveryProvider*, bool state, C4Error = {});
173170

174-
/// Registers a newly discovered peer with to C4PeerDiscovery's set of peers, and returns it.
175-
/// If there is already a peer with this id, returns the existing one instead of registering the new one.
176-
/// (If you want to avoid creating a redundant peer, you can call \ref C4PeerDiscovery::peerWithID to check.)
177171
fleece::Ref<C4Peer> addPeer(C4Peer*, bool moreComing);
178172

179-
/// Unregisters the peer with this ID.
180173
bool removePeer(std::string_view id, bool moreComing);
181174

182-
/// Notifies observers about an incoming connection from a peer.
183-
/// @note If the connection is not accepted, caller must close the C4Socket.
184-
/// @returns true if the connection was accepted, false if not.
175+
void noMorePeersComing();
176+
185177
bool notifyIncomingConnection(C4Peer*, C4Socket*);
186178

187179
void notifyMetadataChanged(C4Peer*);
188180

189181
private:
190-
void notifyPeerChanges();
191-
192182
std::mutex _mutex;
193183
std::string const _peerGroupID;
194184
C4PeerID const _peerID;
@@ -402,6 +392,8 @@ class C4PeerDiscoveryProvider : public fleece::InstanceCounted {
402392
/// into one `addedPeers` notification.
403393
bool removePeer(std::string_view id, bool moreComing) { return _discovery.removePeer(id, moreComing); }
404394

395+
void noMorePeersComing() { _discovery.noMorePeersComing(); }
396+
405397
/// Notifies observers about an incoming connection from a peer.
406398
/// @note If the connection is not accepted, caller must close the C4Socket.
407399
/// @returns true if the connection was accepted, false if not.

C/Cpp_include/c4Replicator.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ struct C4Replicator
9191
C4ReplicationCollection& addCollection(C4CollectionSpec const&, C4ReplicatorMode pushMode,
9292
C4ReplicatorMode pullMode);
9393

94+
bool removeCollection(C4CollectionSpec const&);
95+
9496
fleece::MutableDict copyOptions() const; ///< Returns copy of options (never null)
9597
void setOptions(fleece::Dict); ///< Updates options Dict
9698
void updateOptions(std::function<void(fleece::MutableDict)> const& callback);

LiteCore/Database/LiveQuerier.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace litecore {
4949

5050
LiveQuerier::~LiveQuerier() {
5151
if ( _query ) _stop();
52-
//logVerbose("Deleted"); // It is not currently safe to log in a Logging destructor
52+
logVerbose("Deleted");
5353
}
5454

5555
std::string LiveQuerier::loggingIdentifier() const { return string(_expression); }

LiteCore/Database/SequenceTracker.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ namespace litecore {
462462
}
463463

464464
CollectionChangeNotifier::~CollectionChangeNotifier() {
465-
//if ( callback ) logInfo("Deleting"); // It is not currently safe to log in a Logging destructor
465+
if ( callback ) logInfo("Deleting");
466466

467467
if ( tracker ) { tracker->removePlaceholder(_placeholder); }
468468
}

LiteCore/Query/SQLiteQuery.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ namespace litecore {
231231
rowCount, recording->data().size, elapsedTime * 1000);
232232
}
233233

234-
~SQLiteQueryEnumerator() override {
235-
//logInfo("Deleted"); // It is not currently safe to log in a Logging destructor
236-
}
234+
~SQLiteQueryEnumerator() override { logInfo("Deleted"); }
237235

238236
int64_t getRowCount() const override {
239237
return _recording->asArray()->count() / 2; // (every other row is a column bitmap)

LiteCore/Storage/DataFile.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ namespace litecore {
161161

162162
for ( auto& i : _keyStores ) { i.second->close(); }
163163
_close(forDelete);
164-
if ( _shared->removeDataFile(this) ) {
165-
//logInfo("Closing database"); // It is not currently safe to log in a Logging destructor
166-
}
164+
if ( _shared->removeDataFile(this) ) { logInfo("Closing database"); }
167165
}
168166

169167
void DataFile::reopen() {

Networking/BLIP/BLIPConnection.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ namespace litecore::blip {
162162

163163
protected:
164164
~BLIPIO() override {
165-
#if 0 // It is not currently safe to log in a Logging destructor
166165
double outboxDepth =
167166
(_countOutboxDepth != 0)
168167
? (static_cast<double>(_totalOutboxDepth) / static_cast<double>(_countOutboxDepth))
@@ -173,7 +172,6 @@ namespace litecore::blip {
173172
_countOutboxDepth, _totalBytesWritten, _numRequestsReceived, _totalBytesRead, _timeOpen.elapsed(),
174173
_maxOutboxDepth, outboxDepth);
175174
logStats();
176-
#endif
177175
}
178176

179177
void onWebSocketGotTLSCertificate(slice certData) override {

Replicator/Worker.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace litecore::repl {
109109
: Worker(&parent->connection(), parent, parent->_options, parent->_db, namePrefix, coll) {}
110110

111111
Worker::~Worker() {
112-
//if ( _importance ) logStats(); // It is not currently safe to log in a Logging destructor
112+
if ( _importance ) logStats();
113113
logDebug("destructing (%p); actorName='%s'", this, actorName().c_str());
114114
}
115115

Replicator/c4Replicator.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ C4ReplicationCollection& C4Replicator::Parameters::addCollection(C4ReplicationCo
202202
return copiedSpec;
203203
}
204204

205+
bool C4Replicator::Parameters::removeCollection(C4CollectionSpec const& spec) {
206+
for ( auto i = _collections.begin(); i != _collections.end(); ++i ) {
207+
if ( i->collection == spec ) {
208+
_collections.erase(i);
209+
this->C4ReplicatorParameters::collections = _collections.data();
210+
collectionCount = _collections.size();
211+
return true;
212+
}
213+
}
214+
return false;
215+
}
216+
205217
MutableDict C4Replicator::Parameters::copyOptions() const {
206218
if ( _options ) return Doc{_options}.asDict().mutableCopy();
207219
else

0 commit comments

Comments
 (0)