Skip to content

Commit 71af00e

Browse files
authored
Fixed BonjourProvider not notifying some peer changes (#2280)
Actual fix is in EE repo. Sometimes BonjourProvider would pass on the `moreComing` flag when adding/removing a peer, but its next event it got with moreComing=false didn't trigger any calls to PeerDiscovery, leaving the latter hanging. Added `noMorePeersComing()` method for this situation.
1 parent 9c8d2f3 commit 71af00e

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
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.

0 commit comments

Comments
 (0)