Clear the error faster

This commit is contained in:
Vinnie Falco
2017-06-19 16:57:12 -07:00
parent fc09a4cad1
commit 4d393f4c2a
28 changed files with 117 additions and 116 deletions

View File

@@ -5,6 +5,7 @@ Version 62:
* Add server-framework tests * Add server-framework tests
* Doc fixes and tidy * Doc fixes and tidy
* Tidy up namespaces in examples * Tidy up namespaces in examples
* Clear the error faster
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -149,7 +149,7 @@ public:
ec = ec_; ec = ec_;
return true; return true;
} }
ec = {}; ec.assign(0, ec.category());
return false; return false;
} }
}; };

View File

@@ -196,7 +196,7 @@ public:
teardown(websocket::teardown_tag, teardown(websocket::teardown_tag,
stream&, boost::system::error_code& ec) stream&, boost::system::error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
template<class TeardownHandler> template<class TeardownHandler>
@@ -368,7 +368,7 @@ read_some(MutableBufferSequence const& buffers,
std::size_t bytes_transferred; std::size_t bytes_transferred;
if(in_.b.size() > 0) if(in_.b.size() > 0)
{ {
ec = {}; ec.assign(0, ec.category());
bytes_transferred = buffer_copy( bytes_transferred = buffer_copy(
buffers, in_.b.data(), read_max_); buffers, in_.b.data(), read_max_);
in_.b.consume(bytes_transferred); in_.b.consume(bytes_transferred);
@@ -480,7 +480,7 @@ write_some(
else else
out_.cv.notify_all(); out_.cv.notify_all();
++nwrite; ++nwrite;
ec = {}; ec.assign(0, ec.category());
return bytes_transferred; return bytes_transferred;
} }

View File

@@ -73,7 +73,7 @@ public:
buffers, buffer_prefix(read_max_, cb_)); buffers, buffer_prefix(read_max_, cb_));
if(n > 0) if(n > 0)
{ {
ec = {}; ec.assign(0, ec.category());
cb_ = cb_ + n; cb_ = cb_ + n;
} }
else else
@@ -119,7 +119,7 @@ public:
write_some( write_some(
ConstBufferSequence const& buffers, error_code& ec) ConstBufferSequence const& buffers, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
using boost::asio::buffer_size; using boost::asio::buffer_size;
using boost::asio::buffer_cast; using boost::asio::buffer_cast;
auto const n = buffer_size(buffers); auto const n = buffer_size(buffers);
@@ -151,7 +151,7 @@ public:
string_iostream& stream, string_iostream& stream,
boost::system::error_code& ec) boost::system::error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
template<class TeardownHandler> template<class TeardownHandler>

View File

@@ -70,7 +70,7 @@ public:
buffers, cb_, read_max_); buffers, cb_, read_max_);
if(n > 0) if(n > 0)
{ {
ec = {}; ec.assign(0, ec.category());
cb_ = cb_ + n; cb_ = cb_ + n;
} }
else else
@@ -116,7 +116,7 @@ public:
write_some(ConstBufferSequence const& buffers, write_some(ConstBufferSequence const& buffers,
error_code& ec) error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
return boost::asio::buffer_size(buffers); return boost::asio::buffer_size(buffers);
} }
@@ -139,7 +139,7 @@ public:
string_istream& stream, string_istream& stream,
boost::system::error_code& ec) boost::system::error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
template<class TeardownHandler> template<class TeardownHandler>

View File

@@ -93,7 +93,7 @@ public:
write_some( write_some(
ConstBufferSequence const& buffers, error_code& ec) ConstBufferSequence const& buffers, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
using boost::asio::buffer_size; using boost::asio::buffer_size;
using boost::asio::buffer_cast; using boost::asio::buffer_cast;
auto const n = auto const n =
@@ -127,7 +127,7 @@ public:
string_ostream& stream, string_ostream& stream,
boost::system::error_code& ec) boost::system::error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
template<class TeardownHandler> template<class TeardownHandler>

View File

@@ -227,7 +227,7 @@ read_some(MutableBufferSequence const& buffers,
} }
else else
{ {
ec = {}; ec.assign(0, ec.category());
} }
auto bytes_transferred = auto bytes_transferred =
buffer_copy(buffers, sb_.data()); buffer_copy(buffers, sb_.data());

View File

@@ -112,7 +112,7 @@ struct buffer_body
void void
init(error_code& ec) init(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
boost::optional< boost::optional<
@@ -128,13 +128,13 @@ struct buffer_body
} }
else else
{ {
ec = {}; ec.assign(0, ec.category());
} }
return boost::none; return boost::none;
} }
if(body_.data) if(body_.data)
{ {
ec = {}; ec.assign(0, ec.category());
toggle_ = true; toggle_ = true;
return {{const_buffers_type{ return {{const_buffers_type{
body_.data, body_.size}, body_.more}}; body_.data, body_.size}, body_.more}};
@@ -142,14 +142,14 @@ struct buffer_body
if(body_.more) if(body_.more)
ec = error::need_buffer; ec = error::need_buffer;
else else
ec = {}; ec.assign(0, ec.category());
return boost::none; return boost::none;
} }
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };
#endif #endif
@@ -173,7 +173,7 @@ struct buffer_body
void void
init(boost::optional<std::uint64_t>, error_code& ec) init(boost::optional<std::uint64_t>, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
template<class ConstBufferSequence> template<class ConstBufferSequence>
@@ -189,7 +189,7 @@ struct buffer_body
ec = error::need_buffer; ec = error::need_buffer;
return; return;
} }
ec = {}; ec.assign(0, ec.category());
auto const bytes_transferred = auto const bytes_transferred =
buffer_copy(boost::asio::buffer( buffer_copy(boost::asio::buffer(
body_.data, body_.size), buffers); body_.data, body_.size), buffers);
@@ -201,7 +201,7 @@ struct buffer_body
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };
#endif #endif

View File

@@ -389,14 +389,14 @@ protected:
{ {
if(it == last) if(it == last)
{ {
ec = {}; ec.assign(0, ec.category());
return nullptr; return nullptr;
} }
if(*it == '\r') if(*it == '\r')
{ {
if(++it == last) if(++it == last)
{ {
ec = {}; ec.assign(0, ec.category());
return nullptr; return nullptr;
} }
if(*it != '\n') if(*it != '\n')
@@ -404,7 +404,7 @@ protected:
ec = error::bad_line_ending; ec = error::bad_line_ending;
return nullptr; return nullptr;
} }
ec = {}; ec.assign(0, ec.category());
return ++it; return ++it;
} }
// VFALCO Should we handle the legacy case // VFALCO Should we handle the legacy case
@@ -425,14 +425,14 @@ protected:
{ {
if(it == last) if(it == last)
{ {
ec = {}; ec.assign(0, ec.category());
return nullptr; return nullptr;
} }
if(*it == '\r') if(*it == '\r')
{ {
if(++it == last) if(++it == last)
{ {
ec = {}; ec.assign(0, ec.category());
return nullptr; return nullptr;
} }
if(*it != '\n') if(*it != '\n')
@@ -442,7 +442,7 @@ protected:
} }
if(++it == last) if(++it == last)
{ {
ec = {}; ec.assign(0, ec.category());
return nullptr; return nullptr;
} }
if(*it != '\r') if(*it != '\r')
@@ -452,7 +452,7 @@ protected:
} }
if(++it == last) if(++it == last)
{ {
ec = {}; ec.assign(0, ec.category());
return nullptr; return nullptr;
} }
if(*it != '\n') if(*it != '\n')
@@ -460,7 +460,7 @@ protected:
ec = error::bad_line_ending; ec = error::bad_line_ending;
return nullptr; return nullptr;
} }
ec = {}; ec.assign(0, ec.category());
return ++it; return ++it;
} }
// VFALCO Should we handle the legacy case // VFALCO Should we handle the legacy case

View File

@@ -61,20 +61,20 @@ struct basic_dynamic_body
void void
init(error_code& ec) init(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
return {{body_.data(), false}}; return {{body_.data(), false}};
} }
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };
#endif #endif
@@ -100,7 +100,7 @@ struct basic_dynamic_body
init(boost::optional< init(boost::optional<
std::uint64_t> const&, error_code& ec) std::uint64_t> const&, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
template<class ConstBufferSequence> template<class ConstBufferSequence>
@@ -122,14 +122,14 @@ struct basic_dynamic_body
ec = error::buffer_overflow; ec = error::buffer_overflow;
return; return;
} }
ec = {}; ec.assign(0, ec.category());
body_.commit(buffer_copy(*b, buffers)); body_.commit(buffer_copy(*b, buffers));
} }
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };
#endif #endif

View File

@@ -64,20 +64,20 @@ struct empty_body
void void
init(error_code& ec) init(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
return boost::none; return boost::none;
} }
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };
#endif #endif
@@ -98,7 +98,7 @@ struct empty_body
init(boost::optional<std::uint64_t> const&, init(boost::optional<std::uint64_t> const&,
error_code& ec) error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
template<class ConstBufferSequence> template<class ConstBufferSequence>
@@ -112,7 +112,7 @@ struct empty_body
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };
#endif #endif

View File

@@ -94,7 +94,7 @@ put(ConstBufferSequence const& buffers,
auto const last = buffers.end(); auto const last = buffers.end();
if(p == last) if(p == last)
{ {
ec = {}; ec.assign(0, ec.category());
return 0; return 0;
} }
if(std::next(p) == last) if(std::next(p) == last)
@@ -198,7 +198,7 @@ loop:
break; break;
case state::complete: case state::complete:
ec = {}; ec.assign(0, ec.category());
goto done; goto done;
} }
if(p < p1 && ! is_done() && eager()) if(p < p1 && ! is_done() && eager())
@@ -228,7 +228,7 @@ put_eof(error_code& ec)
ec = error::partial_message; ec = error::partial_message;
return; return;
} }
ec = {}; ec.assign(0, ec.category());
return; return;
} }
impl().on_complete(ec); impl().on_complete(ec);
@@ -793,7 +793,7 @@ do_field(field f,
continue; continue;
} }
} }
ec = {}; ec.assign(0, ec.category());
return; return;
} }
@@ -832,7 +832,7 @@ do_field(field f,
return; return;
} }
ec = {}; ec.assign(0, ec.category());
len_ = v; len_ = v;
f_ |= flagContentLength; f_ |= flagContentLength;
return; return;
@@ -855,7 +855,7 @@ do_field(field f,
return; return;
} }
ec = {}; ec.assign(0, ec.category());
auto const v = token_list{value}; auto const v = token_list{value};
auto const p = std::find_if(v.begin(), v.end(), auto const p = std::find_if(v.begin(), v.end(),
[&](typename token_list::value_type const& s) [&](typename token_list::value_type const& s)
@@ -874,12 +874,12 @@ do_field(field f,
// Upgrade // Upgrade
if(f == field::upgrade) if(f == field::upgrade)
{ {
ec = {}; ec.assign(0, ec.category());
f_ |= flagUpgrade; f_ |= flagUpgrade;
return; return;
} }
ec = {}; ec.assign(0, ec.category());
} }
} // http } // http

View File

@@ -121,7 +121,7 @@ operator()(error_code ec, std::size_t bytes_transferred)
if(p_.got_some()) if(p_.got_some())
{ {
// caller sees EOF on next read // caller sees EOF on next read
ec = {}; ec.assign(0, ec.category());
p_.put_eof(ec); p_.put_eof(ec);
if(ec) if(ec)
goto upcall; goto upcall;
@@ -139,7 +139,7 @@ operator()(error_code ec, std::size_t bytes_transferred)
b_.consume(p_.put(b_.data(), ec)); b_.consume(p_.put(b_.data(), ec));
if(! ec || ec != http::error::need_more) if(! ec || ec != http::error::need_more)
goto do_upcall; goto do_upcall;
ec = {}; ec.assign(0, ec.category());
do_read: do_read:
try try
@@ -570,7 +570,7 @@ read_header(
parser.eager(false); parser.eager(false);
if(parser.is_header_done()) if(parser.is_header_done())
{ {
ec = {}; ec.assign(0, ec.category());
return; return;
} }
do do
@@ -649,7 +649,7 @@ read(
parser.eager(true); parser.eager(true);
if(parser.is_done()) if(parser.is_done())
{ {
ec = {}; ec.assign(0, ec.category());
return; return;
} }
do do

View File

@@ -56,7 +56,7 @@ class write_some_op
operator()(error_code& ec, operator()(error_code& ec,
ConstBufferSequence const& buffer) ConstBufferSequence const& buffer)
{ {
ec = {}; ec.assign(0, ec.category());
invoked = true; invoked = true;
return op_.s_.async_write_some( return op_.s_.async_write_some(
buffer, std::move(op_)); buffer, std::move(op_));
@@ -213,7 +213,7 @@ class write_op
operator()(error_code& ec, operator()(error_code& ec,
ConstBufferSequence const& buffer) ConstBufferSequence const& buffer)
{ {
ec = {}; ec.assign(0, ec.category());
invoked = true; invoked = true;
return op_.s_.async_write_some( return op_.s_.async_write_some(
buffer, std::move(op_)); buffer, std::move(op_));
@@ -537,7 +537,7 @@ write_some(SyncWriteStream& stream, serializer<
detail::write_some_lambda<SyncWriteStream> f{stream}; detail::write_some_lambda<SyncWriteStream> f{stream};
if(sr.is_done()) if(sr.is_done())
{ {
ec = {}; ec.assign(0, ec.category());
return; return;
} }
sr.get(ec, f); sr.get(ec, f);
@@ -609,7 +609,7 @@ write_header(SyncWriteStream& stream, serializer<
sr.split(true); sr.split(true);
if(sr.is_header_done()) if(sr.is_header_done())
{ {
ec = {}; ec.assign(0, ec.category());
return; return;
} }
detail::write_lambda<SyncWriteStream> f{stream}; detail::write_lambda<SyncWriteStream> f{stream};
@@ -680,7 +680,7 @@ write(SyncWriteStream& stream, serializer<
sr.split(false); sr.split(false);
if(sr.is_done()) if(sr.is_done())
{ {
ec = {}; ec.assign(0, ec.category());
return; return;
} }
detail::write_lambda<SyncWriteStream> f{stream}; detail::write_lambda<SyncWriteStream> f{stream};
@@ -808,7 +808,7 @@ public:
operator()(error_code& ec, operator()(error_code& ec,
ConstBufferSequence const& buffers) const ConstBufferSequence const& buffers) const
{ {
ec = {}; ec.assign(0, ec.category());
if(os_.fail()) if(os_.fail())
return; return;
std::size_t bytes_transferred = 0; std::size_t bytes_transferred = 0;
@@ -868,7 +868,7 @@ operator<<(std::ostream& os,
if(os.fail()) if(os.fail())
break; break;
if(ec == error::end_of_stream) if(ec == error::end_of_stream)
ec = {}; ec.assign(0, ec.category());
if(ec) if(ec)
{ {
os.setstate(std::ios::failbit); os.setstate(std::ios::failbit);

View File

@@ -185,7 +185,7 @@ private:
on_request(verb method, string_view method_str, on_request(verb method, string_view method_str,
string_view target, int version, error_code& ec) string_view target, int version, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
m_.target(target); m_.target(target);
if(method != verb::unknown) if(method != verb::unknown)
m_.method(method); m_.method(method);
@@ -199,7 +199,7 @@ private:
string_view reason, string_view reason,
int version, error_code& ec) int version, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
m_.result(code); m_.result(code);
m_.version = version; m_.version = version;
m_.reason(reason); m_.reason(reason);
@@ -209,14 +209,14 @@ private:
on_field(field name, string_view name_string, on_field(field name, string_view name_string,
string_view value, error_code& ec) string_view value, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
m_.insert(name, name_string, value); m_.insert(name, name_string, value);
} }
void void
on_header(error_code& ec) on_header(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -239,7 +239,7 @@ private:
on_chunk(std::uint64_t, on_chunk(std::uint64_t,
string_view, error_code& ec) string_view, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -248,7 +248,7 @@ private:
if(wr_) if(wr_)
wr_->finish(ec); wr_->finish(ec);
else else
ec = {}; ec.assign(0, ec.category());
} }
}; };

View File

@@ -63,13 +63,13 @@ struct string_body
void void
init(error_code& ec) init(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
return {{const_buffers_type{ return {{const_buffers_type{
body_.data(), body_.size()}, false}}; body_.data(), body_.size()}, false}};
} }
@@ -77,7 +77,7 @@ struct string_body
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };
#endif #endif
@@ -111,7 +111,7 @@ struct string_body
errc::not_enough_memory); errc::not_enough_memory);
return; return;
} }
ec = {}; ec.assign(0, ec.category());
body_.reserve(static_cast< body_.reserve(static_cast<
std::size_t>(*content_length)); std::size_t>(*content_length));
} }
@@ -135,7 +135,7 @@ struct string_body
ec = error::buffer_overflow; ec = error::buffer_overflow;
return; return;
} }
ec = {}; ec.assign(0, ec.category());
buffer_copy(boost::asio::buffer( buffer_copy(boost::asio::buffer(
&body_[0] + len, n), buffers); &body_[0] + len, n), buffers);
} }
@@ -143,7 +143,7 @@ struct string_body
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };
#endif #endif

View File

@@ -64,20 +64,20 @@ struct string_view_body
void void
init(error_code& ec) init(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
return {{{body_.data(), body_.size()}, false}}; return {{{body_.data(), body_.size()}, false}};
} }
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };
#endif #endif

View File

@@ -378,7 +378,7 @@ inflate(
if( ec == zlib::error::need_buffers || if( ec == zlib::error::need_buffers ||
ec == zlib::error::end_of_stream) ec == zlib::error::end_of_stream)
{ {
ec = {}; ec.assign(0, ec.category());
break; break;
} }
if(ec) if(ec)
@@ -420,7 +420,7 @@ deflate(
return false; return false;
BOOST_ASSERT(zs.avail_out == 0); BOOST_ASSERT(zs.avail_out == 0);
BOOST_ASSERT(zs.total_out == buffer_size(out)); BOOST_ASSERT(zs.total_out == buffer_size(out));
ec = {}; ec.assign(0, ec.category());
break; break;
} }
if(zs.avail_out == 0) if(zs.avail_out == 0)
@@ -444,7 +444,7 @@ deflate(
zo.write(zs, zlib::Flush::block, ec); zo.write(zs, zlib::Flush::block, ec);
BOOST_ASSERT(! ec || ec == zlib::error::need_buffers); BOOST_ASSERT(! ec || ec == zlib::error::need_buffers);
if(ec == zlib::error::need_buffers) if(ec == zlib::error::need_buffers)
ec = {}; ec.assign(0, ec.category());
if(ec) if(ec)
return false; return false;
if(zs.avail_out >= 6) if(zs.avail_out >= 6)
@@ -459,7 +459,7 @@ deflate(
} }
} }
} }
ec = {}; ec.assign(0, ec.category());
out = buffer( out = buffer(
buffer_cast<void*>(out), zs.total_out); buffer_cast<void*>(out), zs.total_out);
return true; return true;

View File

@@ -178,7 +178,7 @@ operator()(error_code ec,
{ {
// Rationale: // Rationale:
// http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error
ec = {}; ec.assign(0, ec.category());
} }
if(! ec) if(! ec)
{ {
@@ -960,7 +960,7 @@ do_close:
{ {
// Rationale: // Rationale:
// http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error
ec = {}; ec.assign(0, ec.category());
} }
failed_ = ec != 0; failed_ = ec != 0;
if(failed_) if(failed_)
@@ -975,7 +975,7 @@ do_close:
if(ec == boost::asio::error::eof) if(ec == boost::asio::error::eof)
{ {
// (See above) // (See above)
ec = {}; ec.assign(0, ec.category());
} }
} }
if(! ec) if(! ec)

View File

@@ -302,7 +302,7 @@ do_response(http::header<false> const& res,
ec = error::handshake_failed; ec = error::handshake_failed;
return; return;
} }
ec = {}; ec.assign(0, ec.category());
detail::pmd_offer offer; detail::pmd_offer offer;
pmd_read(offer, res); pmd_read(offer, res);
// VFALCO see if offer satisfies pmd_config_, // VFALCO see if offer satisfies pmd_config_,

View File

@@ -997,7 +997,7 @@ doParams(z_params& zs, int level, Strategy strategy, error_code& ec)
// Flush the last buffer: // Flush the last buffer:
doWrite(zs, Flush::block, ec); doWrite(zs, Flush::block, ec);
if(ec == error::need_buffers && pending_ == 0) if(ec == error::need_buffers && pending_ == 0)
ec = {}; ec.assign(0, ec.category());
} }
if(level_ != level) if(level_ != level)
{ {

View File

@@ -225,7 +225,7 @@ public:
error_code ec; error_code ec;
p.put(buffer(s.data(), i), ec); p.put(buffer(s.data(), i), ec);
BEAST_EXPECTS(ec == error::need_more, ec.message()); BEAST_EXPECTS(ec == error::need_more, ec.message());
ec = {}; ec.assign(0, ec.category());
p.put(boost::asio::buffer(s.data(), s.size()), ec); p.put(boost::asio::buffer(s.data(), s.size()), ec);
BEAST_EXPECTS(! ec, ec.message()); BEAST_EXPECTS(! ec, ec.message());
BEAST_EXPECT(p.is_done()); BEAST_EXPECT(p.is_done());
@@ -247,7 +247,7 @@ public:
error_code ec; error_code ec;
p.put(b1, ec); p.put(b1, ec);
BEAST_EXPECTS(ec == error::need_more, ec.message()); BEAST_EXPECTS(ec == error::need_more, ec.message());
ec = {}; ec.assign(0, ec.category());
p.put(buffer_cat(b1, b2), ec); p.put(buffer_cat(b1, b2), ec);
BEAST_EXPECTS(! ec, ec.message()); BEAST_EXPECTS(! ec, ec.message());
p.put_eof(ec); p.put_eof(ec);

View File

@@ -213,7 +213,7 @@ print_cxx14(message<isRequest, Body, Fields> const& m)
sr.get(ec, sr.get(ec,
[&sr](error_code& ec, auto const& buffer) [&sr](error_code& ec, auto const& buffer)
{ {
ec = {}; ec.assign(0, ec.category());
std::cout << buffers(buffer); std::cout << buffers(buffer);
sr.consume(boost::asio::buffer_size(buffer)); sr.consume(boost::asio::buffer_size(buffer));
}); });
@@ -240,7 +240,7 @@ struct lambda
template<class ConstBufferSequence> template<class ConstBufferSequence>
void operator()(error_code& ec, ConstBufferSequence const& buffer) const void operator()(error_code& ec, ConstBufferSequence const& buffer) const
{ {
ec = {}; ec.assign(0, ec.category());
std::cout << buffers(buffer); std::cout << buffers(buffer);
sr.consume(boost::asio::buffer_size(buffer)); sr.consume(boost::asio::buffer_size(buffer));
} }
@@ -281,7 +281,7 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
sr.get(ec, sr.get(ec,
[&sr](error_code& ec, auto const& buffer) [&sr](error_code& ec, auto const& buffer)
{ {
ec = {}; ec.assign(0, ec.category());
std::cout << buffers(buffer); std::cout << buffers(buffer);
sr.consume(boost::asio::buffer_size(buffer)); sr.consume(boost::asio::buffer_size(buffer));
}); });
@@ -295,7 +295,7 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
sr.get(ec, sr.get(ec,
[&sr](error_code& ec, auto const& buffer) [&sr](error_code& ec, auto const& buffer)
{ {
ec = {}; ec.assign(0, ec.category());
std::cout << buffers(buffer); std::cout << buffers(buffer);
sr.consume(boost::asio::buffer_size(buffer)); sr.consume(boost::asio::buffer_size(buffer));
}); });

View File

@@ -95,7 +95,7 @@ public:
p.put(buffer(s.data(), n), ec); p.put(buffer(s.data(), n), ec);
s.remove_prefix(used); s.remove_prefix(used);
if(ec == error::need_more) if(ec == error::need_more)
ec = {}; ec.assign(0, ec.category());
if(! BEAST_EXPECTS(! ec, ec.message())) if(! BEAST_EXPECTS(! ec, ec.message()))
continue; continue;
BEAST_EXPECT(! p.is_done()); BEAST_EXPECT(! p.is_done());
@@ -256,7 +256,7 @@ public:
used = p.put(b.data(), ec); used = p.put(b.data(), ec);
b.consume(used); b.consume(used);
BEAST_EXPECT(ec == error::need_more); BEAST_EXPECT(ec == error::need_more);
ec = {}; ec.assign(0, ec.category());
BEAST_EXPECT(! p.is_done()); BEAST_EXPECT(! p.is_done());
ostream(b) << ostream(b) <<
"\r\n"; // final crlf to end message "\r\n"; // final crlf to end message
@@ -300,7 +300,7 @@ public:
used = p.put(b.data(), ec); used = p.put(b.data(), ec);
BEAST_EXPECTS(ec == error::need_more, ec.message()); BEAST_EXPECTS(ec == error::need_more, ec.message());
b.consume(used); b.consume(used);
ec = {}; ec.assign(0, ec.category());
ostream(b) << ostream(b) <<
"User-Agent: test\r\n" "User-Agent: test\r\n"
"\r\n"; "\r\n";
@@ -321,7 +321,7 @@ public:
BEAST_EXPECT(ec == error::need_more); BEAST_EXPECT(ec == error::need_more);
BEAST_EXPECT(! p.got_some()); BEAST_EXPECT(! p.got_some());
BEAST_EXPECT(used == 0); BEAST_EXPECT(used == 0);
ec = {}; ec.assign(0, ec.category());
used = p.put(buf("G"), ec); used = p.put(buf("G"), ec);
BEAST_EXPECT(ec == error::need_more); BEAST_EXPECT(ec == error::need_more);
BEAST_EXPECT(p.got_some()); BEAST_EXPECT(p.got_some());

View File

@@ -168,7 +168,7 @@ public:
on_request(verb, string_view, on_request(verb, string_view,
string_view, int, error_code& ec) string_view, int, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -176,34 +176,34 @@ public:
string_view, string_view,
int, error_code& ec) int, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
void void
on_field(field, on_field(field,
string_view, string_view, error_code& ec) string_view, string_view, error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
void void
on_header(error_code& ec) on_header(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
void void
on_body(boost::optional<std::uint64_t> const&, on_body(boost::optional<std::uint64_t> const&,
error_code& ec) error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
void void
on_data(string_view, on_data(string_view,
error_code& ec) error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -211,13 +211,13 @@ public:
string_view, string_view,
error_code& ec) error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
void void
on_complete(error_code& ec) on_complete(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };

View File

@@ -59,7 +59,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -75,7 +75,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -86,7 +86,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -96,7 +96,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -110,7 +110,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -121,7 +121,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -132,7 +132,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec = {}; ec.assign(0, ec.category());
} }
void void
@@ -142,7 +142,7 @@ public:
if(fc_) if(fc_)
fc_->fail(ec); fc_->fail(ec);
else else
ec = {}; ec.assign(0, ec.category());
} }
}; };

View File

@@ -57,13 +57,13 @@ public:
void void
init(error_code& ec) init(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
return {{const_buffers_type{ return {{const_buffers_type{
body_.data(), body_.size()}, false}}; body_.data(), body_.size()}, false}};
} }
@@ -71,7 +71,7 @@ public:
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
}; };
}; };
@@ -112,13 +112,13 @@ public:
void void
init(error_code& ec) init(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
boost::optional<std::pair<const_buffers_type, bool>> boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec) get(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
body_.read = true; body_.read = true;
return get( return get(
std::integral_constant<bool, isSplit>{}, std::integral_constant<bool, isSplit>{},
@@ -128,7 +128,7 @@ public:
void void
finish(error_code& ec) finish(error_code& ec)
{ {
ec = {}; ec.assign(0, ec.category());
} }
private: private:

View File

@@ -224,7 +224,7 @@ public:
con.shutdown(ec); con.shutdown(ec);
// VFALCO No idea why we get eof in the normal case // VFALCO No idea why we get eof in the normal case
if(ec == boost::asio::error::eof) if(ec == boost::asio::error::eof)
ec = {}; ec.assign(0, ec.category());
if(! BEAST_EXPECTS(! ec, ec.message())) if(! BEAST_EXPECTS(! ec, ec.message()))
return; return;
} }