pull/1777/merge
xzvno 2024-07-05 08:12:55 +02:00 committed by GitHub
commit e8e2e2a787
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View File

@ -347,8 +347,13 @@ void Piece::updateWrCache(WrDiskCache* diskCache, unsigned char* data,
cell->len = len; cell->len = len;
cell->capacity = capacity; cell->capacity = capacity;
bool rv; bool rv;
rv = wrCache_->cacheData(cell); try {
assert(rv); rv = wrCache_->cacheData(cell);
assert(rv);
} catch (RecoverableException& e) {
delete cell;
throw;
}
rv = diskCache->update(wrCache_.get(), len); rv = diskCache->update(wrCache_.get(), len);
assert(rv); assert(rv);
} }

View File

@ -41,6 +41,7 @@
#include "Segment.h" #include "Segment.h"
#include "WrDiskCache.h" #include "WrDiskCache.h"
#include "Piece.h" #include "Piece.h"
#include "DlAbortEx.h"
namespace aria2 { namespace aria2 {
@ -81,8 +82,13 @@ ssize_t SinkStreamFilter::transform(const std::shared_ptr<BinaryStream>& out,
size_t capacity = std::max(len, static_cast<size_t>(4_k)); size_t capacity = std::max(len, static_cast<size_t>(4_k));
auto dataCopy = new unsigned char[capacity]; auto dataCopy = new unsigned char[capacity];
memcpy(dataCopy, inbuf + alen, len); memcpy(dataCopy, inbuf + alen, len);
piece->updateWrCache(wrDiskCache_, dataCopy, 0, len, capacity, try {
segment->getPositionToWrite() + alen); piece->updateWrCache(wrDiskCache_, dataCopy, 0, len, capacity,
segment->getPositionToWrite() + alen);
} catch (RecoverableException& e) {
delete[] dataCopy;
throw;
}
} }
} }
else { else {