From 8539dd503ae7342b9bb0347459d3936a10636cba Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 4 May 2021 19:49:47 +0200 Subject: [PATCH] fixed deadlock caused by wrong order in mutex lock --- libretroshare/src/gxs/rsgxsnettunnel.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsnettunnel.cc b/libretroshare/src/gxs/rsgxsnettunnel.cc index 380491c5d..9b7a3089a 100644 --- a/libretroshare/src/gxs/rsgxsnettunnel.cc +++ b/libretroshare/src/gxs/rsgxsnettunnel.cc @@ -1028,12 +1028,18 @@ bool RsGxsNetTunnelService::receiveSearchRequest(unsigned char *search_request_d max_allowed_hits = RS_GXS_NET_TUNNEL_MAX_ALLOWED_HITS_GROUP_SEARCH ; std::list results ; + RsNetworkExchangeService *service = nullptr; - RS_STACK_MUTEX(mGxsNetTunnelMtx); + { + RS_STACK_MUTEX(mGxsNetTunnelMtx); - auto it = mSearchableServices.find(substring_sr->service) ; + auto it = mSearchableServices.find(substring_sr->service) ; - if(it != mSearchableServices.end() && it->second->search(substring_sr->substring_match,results)) + if(it != mSearchableServices.end()) + service = it->second; + } + + if(service != nullptr && service->search(substring_sr->substring_match,results)) { RsGxsNetTunnelTurtleSearchGroupSummaryItem search_result_item ;