Skip to content

Commit

Permalink
Fix cache cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuehlma committed Apr 24, 2020
1 parent 5c289be commit 4159792
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/TeleBoy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ bool TeleBoy::Login(string u, string p)

for (int i = 0; i < 3; ++i)
{
updateThreads.emplace_back(new UpdateThread(this));
updateThreads.emplace_back(new UpdateThread(i, this));
}

LoadChannels();
Expand Down
20 changes: 13 additions & 7 deletions src/UpdateThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <time.h>
#include "client.h"
#include "TeleBoy.h"
#include "Cache.h"

using namespace ADDON;

Expand All @@ -11,8 +12,9 @@ std::queue<EpgQueueEntry> UpdateThread::loadEpgQueue;
time_t UpdateThread::nextRecordingsUpdate;
P8PLATFORM::CMutex UpdateThread::mutex;

UpdateThread::UpdateThread(void *teleboy) :
CThread()
UpdateThread::UpdateThread(int threadIdx, void *teleboy) :
CThread(),
m_threadIdx(threadIdx)
{
this->teleboy = teleboy;
time(&UpdateThread::nextRecordingsUpdate);
Expand Down Expand Up @@ -69,14 +71,18 @@ void* UpdateThread::Process()
{
continue;
}

if (m_threadIdx == 0) {
Cache::Cleanup();
}

if (!loadEpgQueue.empty())
while (!loadEpgQueue.empty())
{
if (!mutex.Lock())
{
XBMC->Log(LOG_ERROR,
"UpdateThread::Process : Could not lock mutex for epg queue");
continue;
break;
}
if (!loadEpgQueue.empty())
{
Expand All @@ -91,7 +97,7 @@ void* UpdateThread::Process()
mutex.Unlock();
}
}

time_t currentTime;
time(&currentTime);

Expand All @@ -114,12 +120,12 @@ void* UpdateThread::Process()
}
else
{
mutex.Unlock();
mutex.Unlock();
}
}
}

XBMC->Log(LOG_DEBUG, "Update thread stopped.");
return 0;
return nullptr;
}

7 changes: 4 additions & 3 deletions src/UpdateThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ struct EpgQueueEntry
class UpdateThread: public P8PLATFORM::CThread
{
public:
UpdateThread(void *teleboy);
~UpdateThread();
UpdateThread(int threadIdx, void *teleboy);
~UpdateThread() override;
static void SetNextRecordingUpdate(time_t nextRecordingsUpdate);
static void LoadEpg(int uniqueChannelId, time_t startTime, time_t endTime);
void* Process();
void* Process() override;

private:
void *teleboy;
int m_threadIdx;
static std::queue<EpgQueueEntry> loadEpgQueue;
static time_t nextRecordingsUpdate;
static P8PLATFORM::CMutex mutex;
Expand Down

0 comments on commit 4159792

Please sign in to comment.