Added in Libresapi: Missing mutex locking in TransfersHandler

This commit is contained in:
Konrad 2018-01-01 23:27:46 +01:00
parent 6a61e0a781
commit 9bb6adc036
2 changed files with 6 additions and 2 deletions

View File

@ -8,7 +8,8 @@ namespace resource_api
TransfersHandler::TransfersHandler(StateTokenServer *sts, RsFiles *files, RsPeers *peers,
RsNotify* notify):
mStateTokenServer(sts), mFiles(files), mRsPeers(peers), mLastUpdateTS(0), mNotify(notify)
mStateTokenServer(sts), mFiles(files), mRsPeers(peers), mLastUpdateTS(0), mNotify(notify),
mMtx("TransfersHandler")
{
addResourceHandler("*", this, &TransfersHandler::handleWildcard);
addResourceHandler("downloads", this, &TransfersHandler::handleDownloads);
@ -27,9 +28,9 @@ TransfersHandler::~TransfersHandler()
void TransfersHandler::notifyListChange(int list, int /* type */)
{
//RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
if(list == NOTIFY_LIST_TRANSFERLIST)
{
RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mStateTokenServer->discardToken(mStateToken);
mStateToken = mStateTokenServer->getNewToken();
}

View File

@ -16,6 +16,8 @@ public:
TransfersHandler(StateTokenServer* sts, RsFiles* files, RsPeers *peers, RsNotify* notify);
virtual ~TransfersHandler();
// from NotifyClient
// may be called from foreign thread
virtual void notifyListChange(int list, int type);
// from Tickable
virtual void tick();
@ -30,6 +32,7 @@ private:
RsPeers* mRsPeers;
RsNotify* mNotify;
RsMutex mMtx;
StateToken mStateToken;
time_t mLastUpdateTS;