Clear the error faster

This commit is contained in:
Vinnie Falco
2017-07-20 08:15:27 -07:00
parent fc09a4cad1
commit 4d393f4c2a
28 changed files with 117 additions and 116 deletions
@@ -227,7 +227,7 @@ read_some(MutableBufferSequence const& buffers,
}
else
{
ec = {};
ec.assign(0, ec.category());
}
auto bytes_transferred =
buffer_copy(buffers, sb_.data());
+8 -8
View File
@@ -112,7 +112,7 @@ struct buffer_body
void
init(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
boost::optional<
@@ -128,13 +128,13 @@ struct buffer_body
}
else
{
ec = {};
ec.assign(0, ec.category());
}
return boost::none;
}
if(body_.data)
{
ec = {};
ec.assign(0, ec.category());
toggle_ = true;
return {{const_buffers_type{
body_.data, body_.size}, body_.more}};
@@ -142,14 +142,14 @@ struct buffer_body
if(body_.more)
ec = error::need_buffer;
else
ec = {};
ec.assign(0, ec.category());
return boost::none;
}
void
finish(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
};
#endif
@@ -173,7 +173,7 @@ struct buffer_body
void
init(boost::optional<std::uint64_t>, error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
template<class ConstBufferSequence>
@@ -189,7 +189,7 @@ struct buffer_body
ec = error::need_buffer;
return;
}
ec = {};
ec.assign(0, ec.category());
auto const bytes_transferred =
buffer_copy(boost::asio::buffer(
body_.data, body_.size), buffers);
@@ -201,7 +201,7 @@ struct buffer_body
void
finish(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
};
#endif
+8 -8
View File
@@ -389,14 +389,14 @@ protected:
{
if(it == last)
{
ec = {};
ec.assign(0, ec.category());
return nullptr;
}
if(*it == '\r')
{
if(++it == last)
{
ec = {};
ec.assign(0, ec.category());
return nullptr;
}
if(*it != '\n')
@@ -404,7 +404,7 @@ protected:
ec = error::bad_line_ending;
return nullptr;
}
ec = {};
ec.assign(0, ec.category());
return ++it;
}
// VFALCO Should we handle the legacy case
@@ -425,14 +425,14 @@ protected:
{
if(it == last)
{
ec = {};
ec.assign(0, ec.category());
return nullptr;
}
if(*it == '\r')
{
if(++it == last)
{
ec = {};
ec.assign(0, ec.category());
return nullptr;
}
if(*it != '\n')
@@ -442,7 +442,7 @@ protected:
}
if(++it == last)
{
ec = {};
ec.assign(0, ec.category());
return nullptr;
}
if(*it != '\r')
@@ -452,7 +452,7 @@ protected:
}
if(++it == last)
{
ec = {};
ec.assign(0, ec.category());
return nullptr;
}
if(*it != '\n')
@@ -460,7 +460,7 @@ protected:
ec = error::bad_line_ending;
return nullptr;
}
ec = {};
ec.assign(0, ec.category());
return ++it;
}
// VFALCO Should we handle the legacy case
+6 -6
View File
@@ -61,20 +61,20 @@ struct basic_dynamic_body
void
init(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
return {{body_.data(), false}};
}
void
finish(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
};
#endif
@@ -100,7 +100,7 @@ struct basic_dynamic_body
init(boost::optional<
std::uint64_t> const&, error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
template<class ConstBufferSequence>
@@ -122,14 +122,14 @@ struct basic_dynamic_body
ec = error::buffer_overflow;
return;
}
ec = {};
ec.assign(0, ec.category());
body_.commit(buffer_copy(*b, buffers));
}
void
finish(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
};
#endif
+5 -5
View File
@@ -64,20 +64,20 @@ struct empty_body
void
init(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
return boost::none;
}
void
finish(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
};
#endif
@@ -98,7 +98,7 @@ struct empty_body
init(boost::optional<std::uint64_t> const&,
error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
template<class ConstBufferSequence>
@@ -112,7 +112,7 @@ struct empty_body
void
finish(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
};
#endif
+8 -8
View File
@@ -94,7 +94,7 @@ put(ConstBufferSequence const& buffers,
auto const last = buffers.end();
if(p == last)
{
ec = {};
ec.assign(0, ec.category());
return 0;
}
if(std::next(p) == last)
@@ -198,7 +198,7 @@ loop:
break;
case state::complete:
ec = {};
ec.assign(0, ec.category());
goto done;
}
if(p < p1 && ! is_done() && eager())
@@ -228,7 +228,7 @@ put_eof(error_code& ec)
ec = error::partial_message;
return;
}
ec = {};
ec.assign(0, ec.category());
return;
}
impl().on_complete(ec);
@@ -793,7 +793,7 @@ do_field(field f,
continue;
}
}
ec = {};
ec.assign(0, ec.category());
return;
}
@@ -832,7 +832,7 @@ do_field(field f,
return;
}
ec = {};
ec.assign(0, ec.category());
len_ = v;
f_ |= flagContentLength;
return;
@@ -855,7 +855,7 @@ do_field(field f,
return;
}
ec = {};
ec.assign(0, ec.category());
auto const v = token_list{value};
auto const p = std::find_if(v.begin(), v.end(),
[&](typename token_list::value_type const& s)
@@ -874,12 +874,12 @@ do_field(field f,
// Upgrade
if(f == field::upgrade)
{
ec = {};
ec.assign(0, ec.category());
f_ |= flagUpgrade;
return;
}
ec = {};
ec.assign(0, ec.category());
}
} // http
+4 -4
View File
@@ -121,7 +121,7 @@ operator()(error_code ec, std::size_t bytes_transferred)
if(p_.got_some())
{
// caller sees EOF on next read
ec = {};
ec.assign(0, ec.category());
p_.put_eof(ec);
if(ec)
goto upcall;
@@ -139,7 +139,7 @@ operator()(error_code ec, std::size_t bytes_transferred)
b_.consume(p_.put(b_.data(), ec));
if(! ec || ec != http::error::need_more)
goto do_upcall;
ec = {};
ec.assign(0, ec.category());
do_read:
try
@@ -570,7 +570,7 @@ read_header(
parser.eager(false);
if(parser.is_header_done())
{
ec = {};
ec.assign(0, ec.category());
return;
}
do
@@ -649,7 +649,7 @@ read(
parser.eager(true);
if(parser.is_done())
{
ec = {};
ec.assign(0, ec.category());
return;
}
do
+7 -7
View File
@@ -56,7 +56,7 @@ class write_some_op
operator()(error_code& ec,
ConstBufferSequence const& buffer)
{
ec = {};
ec.assign(0, ec.category());
invoked = true;
return op_.s_.async_write_some(
buffer, std::move(op_));
@@ -213,7 +213,7 @@ class write_op
operator()(error_code& ec,
ConstBufferSequence const& buffer)
{
ec = {};
ec.assign(0, ec.category());
invoked = true;
return op_.s_.async_write_some(
buffer, std::move(op_));
@@ -537,7 +537,7 @@ write_some(SyncWriteStream& stream, serializer<
detail::write_some_lambda<SyncWriteStream> f{stream};
if(sr.is_done())
{
ec = {};
ec.assign(0, ec.category());
return;
}
sr.get(ec, f);
@@ -609,7 +609,7 @@ write_header(SyncWriteStream& stream, serializer<
sr.split(true);
if(sr.is_header_done())
{
ec = {};
ec.assign(0, ec.category());
return;
}
detail::write_lambda<SyncWriteStream> f{stream};
@@ -680,7 +680,7 @@ write(SyncWriteStream& stream, serializer<
sr.split(false);
if(sr.is_done())
{
ec = {};
ec.assign(0, ec.category());
return;
}
detail::write_lambda<SyncWriteStream> f{stream};
@@ -808,7 +808,7 @@ public:
operator()(error_code& ec,
ConstBufferSequence const& buffers) const
{
ec = {};
ec.assign(0, ec.category());
if(os_.fail())
return;
std::size_t bytes_transferred = 0;
@@ -868,7 +868,7 @@ operator<<(std::ostream& os,
if(os.fail())
break;
if(ec == error::end_of_stream)
ec = {};
ec.assign(0, ec.category());
if(ec)
{
os.setstate(std::ios::failbit);
+6 -6
View File
@@ -185,7 +185,7 @@ private:
on_request(verb method, string_view method_str,
string_view target, int version, error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
m_.target(target);
if(method != verb::unknown)
m_.method(method);
@@ -199,7 +199,7 @@ private:
string_view reason,
int version, error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
m_.result(code);
m_.version = version;
m_.reason(reason);
@@ -209,14 +209,14 @@ private:
on_field(field name, string_view name_string,
string_view value, error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
m_.insert(name, name_string, value);
}
void
on_header(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
void
@@ -239,7 +239,7 @@ private:
on_chunk(std::uint64_t,
string_view, error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
void
@@ -248,7 +248,7 @@ private:
if(wr_)
wr_->finish(ec);
else
ec = {};
ec.assign(0, ec.category());
}
};
+6 -6
View File
@@ -63,13 +63,13 @@ struct string_body
void
init(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
return {{const_buffers_type{
body_.data(), body_.size()}, false}};
}
@@ -77,7 +77,7 @@ struct string_body
void
finish(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
};
#endif
@@ -111,7 +111,7 @@ struct string_body
errc::not_enough_memory);
return;
}
ec = {};
ec.assign(0, ec.category());
body_.reserve(static_cast<
std::size_t>(*content_length));
}
@@ -135,7 +135,7 @@ struct string_body
ec = error::buffer_overflow;
return;
}
ec = {};
ec.assign(0, ec.category());
buffer_copy(boost::asio::buffer(
&body_[0] + len, n), buffers);
}
@@ -143,7 +143,7 @@ struct string_body
void
finish(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
};
#endif
+3 -3
View File
@@ -64,20 +64,20 @@ struct string_view_body
void
init(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
return {{{body_.data(), body_.size()}, false}};
}
void
finish(error_code& ec)
{
ec = {};
ec.assign(0, ec.category());
}
};
#endif
@@ -378,7 +378,7 @@ inflate(
if( ec == zlib::error::need_buffers ||
ec == zlib::error::end_of_stream)
{
ec = {};
ec.assign(0, ec.category());
break;
}
if(ec)
@@ -420,7 +420,7 @@ deflate(
return false;
BOOST_ASSERT(zs.avail_out == 0);
BOOST_ASSERT(zs.total_out == buffer_size(out));
ec = {};
ec.assign(0, ec.category());
break;
}
if(zs.avail_out == 0)
@@ -444,7 +444,7 @@ deflate(
zo.write(zs, zlib::Flush::block, ec);
BOOST_ASSERT(! ec || ec == zlib::error::need_buffers);
if(ec == zlib::error::need_buffers)
ec = {};
ec.assign(0, ec.category());
if(ec)
return false;
if(zs.avail_out >= 6)
@@ -459,7 +459,7 @@ deflate(
}
}
}
ec = {};
ec.assign(0, ec.category());
out = buffer(
buffer_cast<void*>(out), zs.total_out);
return true;
+3 -3
View File
@@ -178,7 +178,7 @@ operator()(error_code ec,
{
// Rationale:
// http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error
ec = {};
ec.assign(0, ec.category());
}
if(! ec)
{
@@ -960,7 +960,7 @@ do_close:
{
// Rationale:
// http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error
ec = {};
ec.assign(0, ec.category());
}
failed_ = ec != 0;
if(failed_)
@@ -975,7 +975,7 @@ do_close:
if(ec == boost::asio::error::eof)
{
// (See above)
ec = {};
ec.assign(0, ec.category());
}
}
if(! ec)
+1 -1
View File
@@ -302,7 +302,7 @@ do_response(http::header<false> const& res,
ec = error::handshake_failed;
return;
}
ec = {};
ec.assign(0, ec.category());
detail::pmd_offer offer;
pmd_read(offer, res);
// VFALCO see if offer satisfies pmd_config_,
+1 -1
View File
@@ -997,7 +997,7 @@ doParams(z_params& zs, int level, Strategy strategy, error_code& ec)
// Flush the last buffer:
doWrite(zs, Flush::block, ec);
if(ec == error::need_buffers && pending_ == 0)
ec = {};
ec.assign(0, ec.category());
}
if(level_ != level)
{