From e4026300955d257c521d3b1cb71d19e2ccc71e32 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 8 Dec 2019 21:34:52 +0100 Subject: [PATCH] attempt to fix thread race between rsEvents and TokenQueue --- libretroshare/src/gxstunnel/p3gxstunnel.cc | 2 ++ libretroshare/src/services/p3msgservice.cc | 7 +++---- retroshare-gui/src/gui/NewsFeed.cpp | 3 +++ retroshare-gui/src/util/TokenQueue.cpp | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.cc b/libretroshare/src/gxstunnel/p3gxstunnel.cc index 0a1a45024..08ca943a6 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -1296,7 +1296,9 @@ bool p3GxsTunnelService::locked_sendEncryptedTunnelData(RsGxsTunnelItem *item) } if(it->second.status != RS_GXS_TUNNEL_STATUS_CAN_TALK) { +#ifdef DEBUG_GXS_TUNNEL std::cerr << "(EE) Cannot talk to tunnel id " << tunnel_id << ". Tunnel status is: " << it->second.status << std::endl; +#endif return false; } diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index ebf2ce496..20697f2d6 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -404,11 +404,10 @@ int p3MsgService::checkOutgoingMessages() mit->second->msgFlags |= RS_MSG_FLAGS_ROUTED; } } +#ifdef DEBUG_DISTANT_MSG else - { - Dbg3() << __PRETTY_FUNCTION__ << " Delaying until available..." - << std::endl; - } + Dbg3() << __PRETTY_FUNCTION__ << " Delaying until available..." << std::endl; +#endif } /* clean up */ diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 8a87c2ea3..b4f582db5 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -1103,6 +1103,7 @@ void NewsFeed::addFeedItem(FeedItem *item) { static const int MAX_FEEDITEM_COUNT = 500 ; + std::cerr << "Adding feed item thread " << pthread_self() << std::endl; item->setAttribute(Qt::WA_DeleteOnClose, true); // costly, but not really a problem here @@ -1125,6 +1126,7 @@ void NewsFeed::addFeedItemIfUnique(FeedItem *item, bool replace) { FeedItem *feedItem = ui->feedWidget->findFeedItem(item->uniqueIdentifier()); + std::cerr << "Adding feed item thread " << pthread_self() << std::endl; if (feedItem) { if (!replace) @@ -1143,6 +1145,7 @@ void NewsFeed::remUniqueFeedItem(FeedItem *item) { FeedItem *feedItem = ui->feedWidget->findFeedItem(item->uniqueIdentifier()); + std::cerr << "Adding feed item thread " << pthread_self() << std::endl; if (feedItem) { delete item; diff --git a/retroshare-gui/src/util/TokenQueue.cpp b/retroshare-gui/src/util/TokenQueue.cpp index ac66d5c3c..4fad53fc5 100644 --- a/retroshare-gui/src/util/TokenQueue.cpp +++ b/retroshare-gui/src/util/TokenQueue.cpp @@ -34,7 +34,7 @@ TokenQueue::TokenQueue(RsTokenService *service, TokenResponse *resp) { mTrigger = new RsProtectedTimer(this); mTrigger->setSingleShot(true); - connect(mTrigger, SIGNAL(timeout()), this, SLOT(pollRequests())); + connect(mTrigger, SIGNAL(timeout()), this, SLOT(pollRequests()),Qt::QueuedConnection); } bool TokenQueue::requestGroupInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, std::list& ids, uint32_t usertype)