mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::resource: Add assertions; fix error.
This commit is contained in:
parent
a8d9c78e12
commit
2b3de2ea69
2 changed files with 17 additions and 3 deletions
|
@ -977,12 +977,23 @@ ircd::resource::response::chunked::finish()
|
|||
ircd::const_buffer
|
||||
ircd::resource::response::chunked::flush(const const_buffer &buf)
|
||||
{
|
||||
const const_buffer wrote
|
||||
assert(size(buf) <= size(this->buf) || empty(this->buf));
|
||||
const size_t wrote
|
||||
{
|
||||
data(buf), write(buf)
|
||||
write(buf, true)
|
||||
};
|
||||
|
||||
return wrote;
|
||||
assert(wrote > 0 || empty(buf));
|
||||
const size_t flushed
|
||||
{
|
||||
std::min(size(buf), wrote)
|
||||
};
|
||||
|
||||
assert(flushed <= size(buf));
|
||||
return const_buffer
|
||||
{
|
||||
data(buf), flushed
|
||||
};
|
||||
}
|
||||
|
||||
size_t
|
||||
|
@ -990,6 +1001,7 @@ ircd::resource::response::chunked::write(const const_buffer &chunk,
|
|||
const bool &ignore_empty)
|
||||
try
|
||||
{
|
||||
assert(size(chunk) <= size(this->buf) || empty(this->buf));
|
||||
size_t ret{0};
|
||||
|
||||
if(!c)
|
||||
|
|
|
@ -408,11 +408,13 @@ ircd::m::sync::flush(data &data,
|
|||
resource::response::chunked &response,
|
||||
const const_buffer &buffer)
|
||||
{
|
||||
assert(size(buffer) <= size(response.buf));
|
||||
const auto wrote
|
||||
{
|
||||
response.flush(buffer)
|
||||
};
|
||||
|
||||
assert(size(wrote) <= size(buffer));
|
||||
if(data.stats)
|
||||
{
|
||||
data.stats->flush_bytes += size(wrote);
|
||||
|
|
Loading…
Reference in a new issue