From 22161a71ed6cfc01ef486f8b39a5c9cc4a1779ca Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Fri, 1 Nov 2013 15:13:37 -0200 Subject: [PATCH] fix deadlock --- src/twister.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/twister.cpp b/src/twister.cpp index 71feab05..9f427524 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -69,8 +69,10 @@ sha1_hash dhtTargetHash(std::string const &username, std::string const &resource torrent_handle startTorrentUser(std::string const &username) { + bool userInTxDb = usernameExists(username); // keep this outside cs_twister to avoid deadlock + LOCK(cs_twister); - if( !m_userTorrent.count(username) && usernameExists(username) ) { + if( !m_userTorrent.count(username) && userInTxDb ) { sha1_hash ih = dhtTargetHash(username, "tracker", "m"); printf("adding torrent for [%s,tracker]\n", username.c_str());