changeset 4030:365a0f9e4ed6

Pause hashing until all INFs has been sent to ADC hubs after a share refresh - fixes possible search issues
author eMTee <emtee11@gmail.com>
date Wed, 04 Jun 2025 12:12:05 +0200
parents 86fbc0cb59f2
children 0d7f32465289
files changelog.txt dcpp/Client.cpp dcpp/Client.h dcpp/ClientManager.cpp dcpp/ClientManager.h dcpp/ShareManager.cpp dcpp/typedefs.h
diffstat 7 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/changelog.txt	Tue Jun 03 12:39:42 2025 +0200
+++ b/changelog.txt	Wed Jun 04 12:12:05 2025 +0200
@@ -1,3 +1,4 @@
+* [L#2110291] [ADC] Fix a possible latency in the availability of TTH search results for updated files on hubs with BLOM support (emtee)
 * Ensure that files are always instantly searchable by name after they have been hashed (emtee)
 * [L#2111115] Fix hash pausing so it always works instantly (emtee)
 * Update OpenSSL to version 3.2.4
--- a/dcpp/Client.cpp	Tue Jun 03 12:39:42 2025 +0200
+++ b/dcpp/Client.cpp	Wed Jun 04 12:12:05 2025 +0200
@@ -147,9 +147,9 @@
 	updateActivity();
 }
 
-void Client::info() {
+void Client::info(Holder h) {
 	if(isConnected()) {
-		sock->callAsync([this] { infoImpl(); });
+		sock->callAsync([this, h = std::move(h)] { infoImpl(); });
 	}
 }
 
--- a/dcpp/Client.h	Tue Jun 03 12:39:42 2025 +0200
+++ b/dcpp/Client.h	Wed Jun 04 12:12:05 2025 +0200
@@ -55,7 +55,7 @@
 	virtual void search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken, const StringList& aExtList, const string& aKey) = 0;
 	virtual void password(const string& pwd) = 0;
 	/** Send new information about oneself. Thread-safe. */
-	void info();
+	void info(Holder h = nullptr);
 
 	virtual size_t getUserCount() const = 0;
 	virtual int64_t getAvailable() const = 0;
--- a/dcpp/ClientManager.cpp	Tue Jun 03 12:39:42 2025 +0200
+++ b/dcpp/ClientManager.cpp	Wed Jun 04 12:12:05 2025 +0200
@@ -476,10 +476,10 @@
 	}
 }
 
-void ClientManager::infoUpdated() {
+void ClientManager::infoUpdated(Holder h) {
 	Lock l(cs);
 	for(auto client: clients) {
-		client->info();
+		client->info(h && dynamic_cast<AdcHub*>(client) ? h : nullptr);
 	}
 }
 
--- a/dcpp/ClientManager.h	Tue Jun 03 12:39:42 2025 +0200
+++ b/dcpp/ClientManager.h	Wed Jun 04 12:12:05 2025 +0200
@@ -81,7 +81,7 @@
 
 	void search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken, const string& aKey);
 	void search(StringList& who, int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken, const StringList& aExtList, const string& aKey);
-	void infoUpdated();
+	void infoUpdated(Holder h = nullptr);
 
 	UserPtr getUser(const string& aNick, const string& aHubUrl) noexcept;
 	UserPtr getUser(const CID& cid) noexcept;
--- a/dcpp/ShareManager.cpp	Tue Jun 03 12:39:42 2025 +0200
+++ b/dcpp/ShareManager.cpp	Wed Jun 04 12:12:05 2025 +0200
@@ -45,6 +45,7 @@
 #endif
 
 #include <limits>
+#include <memory>
 
 // define this to 1 to measure the time taken by searches to complete.
 #ifndef DCPP_TIME_SEARCHES
@@ -884,8 +885,10 @@
 	if(dirs.empty())
 		refreshDirs = false;
 
+	std::shared_ptr<HashManager::HashPauser> pauser;
+		
 	if(refreshDirs) {
-		HashManager::HashPauser pauser;
+		pauser = std::make_shared<HashManager::HashPauser>();
 
 		LogManager::getInstance()->message(_("File list refresh initiated"));
 
@@ -926,7 +929,9 @@
 	}
 
 	if(update) {
-		ClientManager::getInstance()->infoUpdated();
+		/* Hold off hashing until all infos have been sent out 
+		   so we properly signal the update to possible bloom requesters. */
+		ClientManager::getInstance()->infoUpdated(std::move(pauser));
 	}
 
 	refreshing.clear();
--- a/dcpp/typedefs.h	Tue Jun 03 12:39:42 2025 +0200
+++ b/dcpp/typedefs.h	Wed Jun 04 12:12:05 2025 +0200
@@ -26,6 +26,7 @@
 #include <unordered_map>
 #include <unordered_set>
 #include <vector>
+#include <memory>
 
 #include <boost/variant.hpp>
 
@@ -89,6 +90,7 @@
 
 typedef unordered_map<string, boost::variant<string, std::function<string ()>>> ParamMap;
 
+typedef std::shared_ptr<void> Holder;
 }
 
 #endif /* TYPEDEFS_H_ */