1
0
Fork 0

fixed some leaks

This commit is contained in:
jsteemann 2016-08-26 14:29:31 +02:00
parent a31fe62c34
commit 4727c833c8
5 changed files with 23 additions and 21 deletions

View File

@ -876,7 +876,7 @@ int SkiplistIndex::remove(arangodb::Transaction*, TRI_doc_mptr_t const* doc,
}
int SkiplistIndex::unload() {
_skiplistIndex->truncate();
_skiplistIndex->truncate(true);
return TRI_ERROR_NO_ERROR;
}

View File

@ -56,16 +56,6 @@ MMFilesCollection::MMFilesCollection(LogicalCollection* collection)
MMFilesCollection::~MMFilesCollection() {
close();
for (auto& it : _datafiles) {
delete it;
}
for (auto& it : _journals) {
delete it;
}
for (auto& it : _compactors) {
delete it;
}
}
TRI_voc_rid_t MMFilesCollection::revision() const {
@ -83,14 +73,23 @@ int64_t MMFilesCollection::initialCount() const {
int MMFilesCollection::close() {
// close compactor files
closeDatafiles(_compactors);
for (auto& it : _compactors) {
delete it;
}
_compactors.clear();
// close journal files
closeDatafiles(_journals);
for (auto& it : _journals) {
delete it;
}
_journals.clear();
// close datafiles
closeDatafiles(_datafiles);
for (auto& it : _datafiles) {
delete it;
}
_datafiles.clear();
return TRI_ERROR_NO_ERROR;

View File

@ -1856,10 +1856,9 @@ int MMFilesEngine::openCollection(TRI_vocbase_t* vocbase, LogicalCollection* col
filename = newName;
}
TRI_datafile_t* datafile =
TRI_OpenDatafile(filename, ignoreErrors);
std::unique_ptr<TRI_datafile_t> df(TRI_OpenDatafile(filename, ignoreErrors));
if (datafile == nullptr) {
if (df == nullptr) {
LOG_TOPIC(ERR, Logger::DATAFILES) << "cannot open datafile '"
<< filename
<< "': " << TRI_last_error();
@ -1868,7 +1867,8 @@ int MMFilesEngine::openCollection(TRI_vocbase_t* vocbase, LogicalCollection* col
break;
}
all.emplace_back(datafile);
all.emplace_back(df.get());
TRI_datafile_t* datafile = df.release();
// check the document header
char const* ptr = datafile->_data;

View File

@ -1895,7 +1895,7 @@ int TRI_datafile_t::close() {
}
if (_state == TRI_DF_STATE_CLOSED) {
LOG(WARN) << "closing an already closed datafile '" << getName() << "'";
LOG(TRACE) << "closing an already closed datafile '" << getName() << "'";
return TRI_ERROR_NO_ERROR;
}

View File

@ -172,10 +172,10 @@ class SkipList {
//////////////////////////////////////////////////////////////////////////////
~SkipList() {
truncate();
truncate(false);
}
void truncate() {
void truncate(bool createStartNode) {
Node* p;
Node* next;
@ -193,9 +193,12 @@ class SkipList {
_memoryUsed = sizeof(SkipList);
_nrUsed = 0;
_start = allocNode(TRI_SKIPLIST_MAX_HEIGHT);
// Note that this can throw
_end = _start;
if (createStartNode) {
_start = allocNode(TRI_SKIPLIST_MAX_HEIGHT);
// Note that this can throw
_end = _start;
}
}
//////////////////////////////////////////////////////////////////////////////