Skip to content

Commit

Permalink
Merge pull request #309 from deplinenoise/crash-no-dag
Browse files Browse the repository at this point in the history
Avoid crashing when there is no DAG data.
  • Loading branch information
deplinenoise authored May 2, 2018
2 parents 6d34607 + 26e84d8 commit 27c3c3f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/DigestCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace t2
{

void DigestCacheInit(DigestCache* self, size_t heap_size, const char* filename)
void DigestCacheInit(DigestCache* self, size_t heap_size)
{
ReadWriteLockInit(&self->m_Lock);

Expand All @@ -21,7 +21,10 @@ void DigestCacheInit(DigestCache* self, size_t heap_size, const char* filename)
HashTableInit(&self->m_Table, &self->m_Heap);

self->m_AccessTime = time(nullptr);
}

void DigestCacheOpen(DigestCache* self, const char* filename)
{
MmapFileMap(&self->m_StateFile, filename);
if (MmapFileValid(&self->m_StateFile))
{
Expand Down
3 changes: 2 additions & 1 deletion src/DigestCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ namespace t2
uint64_t m_AccessTime;
};

void DigestCacheInit(DigestCache* self, size_t heap_size, const char* filename);
void DigestCacheInit(DigestCache* self, size_t heap_size);
void DigestCacheOpen(DigestCache* self, const char* filename);

void DigestCacheDestroy(DigestCache* self);

Expand Down
4 changes: 3 additions & 1 deletion src/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ bool DriverInitData(Driver* self)
{
ProfilerScope prof_scope("Tundra InitData", 0);

DigestCacheInit(&self->m_DigestCache, MB(128));

if (!DriverPrepareDag(self, s_DagFileName))
return false;

DigestCacheInit(&self->m_DigestCache, MB(128), self->m_DagData->m_DigestCacheFileName);
DigestCacheOpen(&self->m_DigestCache, self->m_DagData->m_DigestCacheFileName);

LoadFrozenData<StateData>(self->m_DagData->m_StateFileName, &self->m_StateFile, &self->m_StateData);

Expand Down

0 comments on commit 27c3c3f

Please sign in to comment.