|
|
|
@ -521,7 +521,7 @@ void PosixEndpointImpl::UpdateRcvLowat() { |
|
|
|
|
void PosixEndpointImpl::MaybeMakeReadSlices() { |
|
|
|
|
static const int kBigAlloc = 64 * 1024; |
|
|
|
|
static const int kSmallAlloc = 8 * 1024; |
|
|
|
|
if (incoming_buffer_->Length() < static_cast<size_t>(min_progress_size_)) { |
|
|
|
|
if (incoming_buffer_->Length() < std::max<size_t>(min_progress_size_, 1)) { |
|
|
|
|
size_t allocate_length = min_progress_size_; |
|
|
|
|
const size_t target_length = static_cast<size_t>(target_length_); |
|
|
|
|
// If memory pressure is low and we think there will be more than
|
|
|
|
@ -531,8 +531,8 @@ void PosixEndpointImpl::MaybeMakeReadSlices() { |
|
|
|
|
if (low_memory_pressure && target_length > allocate_length) { |
|
|
|
|
allocate_length = target_length; |
|
|
|
|
} |
|
|
|
|
int extra_wanted = |
|
|
|
|
allocate_length - static_cast<int>(incoming_buffer_->Length()); |
|
|
|
|
int extra_wanted = std::max<int>( |
|
|
|
|
1, allocate_length - static_cast<int>(incoming_buffer_->Length())); |
|
|
|
|
if (extra_wanted >= |
|
|
|
|
(low_memory_pressure ? kSmallAlloc * 3 / 2 : kBigAlloc)) { |
|
|
|
|
while (extra_wanted > 0) { |
|
|
|
|