分包器缓存太多时主动清空数据

This commit is contained in:
ziyue 2021-12-24 17:47:15 +08:00
parent 5832de7ed8
commit 3cba8fca79
2 changed files with 8 additions and 4 deletions

@ -1 +1 @@
Subproject commit 88bc73aa6b7e04e04ca45f4fdbe36d4e359088bf
Subproject commit 8afa63c31522e031c3d4857f0c723ee4e97447fc

View File

@ -19,9 +19,13 @@ static constexpr size_t kMaxCacheSize = 1 * 1024 * 1024;
namespace mediakit {
void HttpRequestSplitter::input(const char *data,size_t len) {
if (remainDataSize() > kMaxCacheSize) {
{
auto size = remainDataSize();
if (size > kMaxCacheSize) {
//缓存太多数据无法处理则上抛异常
throw std::out_of_range("remain data size is too huge:" + to_string(remainDataSize()));
reset();
throw std::out_of_range("remain data size is too huge, now cleared:" + to_string(size));
}
}
const char *ptr = data;
if(!_remain_data.empty()){