diff --git a/src/friend_server/fsclient.cc b/src/friend_server/fsclient.cc index 1a3a02598..85eb7ffb8 100644 --- a/src/friend_server/fsclient.cc +++ b/src/friend_server/fsclient.cc @@ -201,8 +201,9 @@ bool FsClient::sendItem(const std::string& server_address,uint16_t server_port, uint32_t ss; p.SendItem(item,ss); + time_t now = time(nullptr); - while(true) + while(now > time(nullptr)+15) // wait 15 secs for a response. { p.tick(); // ticks bio diff --git a/src/friend_server/fsmanager.cc b/src/friend_server/fsmanager.cc index a61da563b..cd5f844e9 100644 --- a/src/friend_server/fsmanager.cc +++ b/src/friend_server/fsmanager.cc @@ -36,8 +36,8 @@ void FriendServerManager::stopServer() RsTickingThread::askForStop() ; } } -void FriendServerManager::checkServerAddress_async(const std::string& addr,uint16_t port, uint32_t timeout_ms, - const std::function& callback) + +bool FriendServerManager::checkServerAddress(const std::string& addr,uint16_t port, uint32_t timeout_ms) { uint16_t rs_tor_port; std::string rs_tor_addr; @@ -45,7 +45,7 @@ void FriendServerManager::checkServerAddress_async(const std::string& addr,uint1 rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR,rs_tor_addr,rs_tor_port,flags); - callback(addr,port,FsClient::checkProxyConnection(addr,port,rs_tor_addr,rs_tor_port,timeout_ms)); + return FsClient::checkProxyConnection(addr,port,rs_tor_addr,rs_tor_port,timeout_ms); } void FriendServerManager::setServerAddress(const std::string& addr,uint16_t port) diff --git a/src/friend_server/fsmanager.h b/src/friend_server/fsmanager.h index b8903935d..c85716d2f 100644 --- a/src/friend_server/fsmanager.h +++ b/src/friend_server/fsmanager.h @@ -26,8 +26,7 @@ public: virtual void startServer() override ; virtual void stopServer() override ; - virtual void checkServerAddress_async(const std::string& addr, uint16_t, uint32_t timeout_ms, - const std::function& callback) override ; + virtual bool checkServerAddress(const std::string& addr,uint16_t port, uint32_t timeout_ms) override; virtual void setProfilePassphrase(const std::string& passphrase) override { mCachedPGPPassphrase = passphrase; } virtual void setServerAddress(const std::string&,uint16_t) override ; diff --git a/src/retroshare/rsfriendserver.h b/src/retroshare/rsfriendserver.h index b927ed870..93d09a4cc 100644 --- a/src/retroshare/rsfriendserver.h +++ b/src/retroshare/rsfriendserver.h @@ -27,16 +27,10 @@ public: virtual void stopServer() =0; // Testing system. Since the test can take some time (contacting the proxy, setting the connection, - // getting some ack from the server), the whole test is asynchronous. The callback will be used to - // return the result of the test, recalling the tested address and port. + // getting some ack from the server). The whole test is synchronous and might be blocking for a while. + // Consequently, the client needs to take care to avoid blocking e.g. the UI when calling this. // - virtual void checkServerAddress_async(const std::string& addr, - uint16_t port, - uint32_t timeout_ms, - const std::function& callback - ) =0; + virtual bool checkServerAddress(const std::string& addr,uint16_t port, uint32_t timeout_ms) =0; virtual void setServerAddress(const std::string&,uint16_t) =0; virtual void setFriendsToRequest(uint32_t) =0;