From bc1fc65d7e1212a427f596014a5c24ad88d72808 Mon Sep 17 00:00:00 2001 From: Richard Hodges Date: Thu, 27 Aug 2020 13:44:33 +0200 Subject: [PATCH] Add handler tracking locations to websocket --- CHANGELOG.md | 1 + include/boost/beast/websocket/impl/accept.hpp | 20 ++- include/boost/beast/websocket/impl/close.hpp | 80 +++++++-- .../boost/beast/websocket/impl/handshake.hpp | 32 +++- include/boost/beast/websocket/impl/ping.hpp | 55 ++++-- include/boost/beast/websocket/impl/read.hpp | 161 ++++++++++++++---- .../beast/websocket/impl/stream_impl.hpp | 36 +++- include/boost/beast/websocket/impl/write.hpp | 118 ++++++++++--- 8 files changed, 411 insertions(+), 92 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 993b6342..83bedba3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ Version XXX: +* Add handler tracking locations to websocket. * Add handler tracking locations to tcp teardown. * Eliminate spurious uninitialised variable warning in detect_ssl. * Add handler tracking locations to flat_stream. diff --git a/include/boost/beast/websocket/impl/accept.hpp b/include/boost/beast/websocket/impl/accept.hpp index 5bc592fe..588aa5da 100644 --- a/include/boost/beast/websocket/impl/accept.hpp +++ b/include/boost/beast/websocket/impl/accept.hpp @@ -215,8 +215,14 @@ public: // Send response BOOST_ASIO_CORO_YIELD - http::async_write( - impl.stream(), res_, std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_accept")); + + http::async_write( + impl.stream(), res_, std::move(*this)); + } if(impl.check_stop_now(ec)) goto upcall; if(! ec) @@ -298,8 +304,14 @@ public: goto upcall; BOOST_ASIO_CORO_YIELD - http::async_read(impl.stream(), - impl.rd_buf, p_, std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_accept")); + + http::async_read(impl.stream(), + impl.rd_buf, p_, std::move(*this)); + } if(ec == http::error::end_of_stream) ec = error::closed; if(impl.check_stop_now(ec)) diff --git a/include/boost/beast/websocket/impl/close.hpp b/include/boost/beast/websocket/impl/close.hpp index 2b7d7293..4e42c366 100644 --- a/include/boost/beast/websocket/impl/close.hpp +++ b/include/boost/beast/websocket/impl/close.hpp @@ -86,10 +86,22 @@ public: if(! impl.wr_block.try_lock(this)) { BOOST_ASIO_CORO_YIELD - impl.op_close.emplace(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_close")); + + impl.op_close.emplace(std::move(*this)); + } impl.wr_block.lock(this); BOOST_ASIO_CORO_YIELD - net::post(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_close")); + + net::post(std::move(*this)); + } BOOST_ASSERT(impl.wr_block.is_locked(this)); } if(impl.check_stop_now(ec)) @@ -104,8 +116,14 @@ public: impl.change_status(status::closing); impl.update_timer(this->get_executor()); BOOST_ASIO_CORO_YIELD - net::async_write(impl.stream(), fb_.data(), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_close")); + + net::async_write(impl.stream(), fb_.data(), + beast::detail::bind_continuation(std::move(*this))); + } if(impl.check_stop_now(ec)) goto upcall; @@ -121,10 +139,22 @@ public: if(! impl.rd_block.try_lock(this)) { BOOST_ASIO_CORO_YIELD - impl.op_r_close.emplace(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_close")); + + impl.op_r_close.emplace(std::move(*this)); + } impl.rd_block.lock(this); BOOST_ASIO_CORO_YIELD - net::post(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_close")); + + net::post(std::move(*this)); + } BOOST_ASSERT(impl.rd_block.is_locked(this)); if(impl.check_stop_now(ec)) goto upcall; @@ -144,10 +174,16 @@ public: if(ev_) goto teardown; BOOST_ASIO_CORO_YIELD - impl.stream().async_read_some( - impl.rd_buf.prepare(read_size( - impl.rd_buf, impl.rd_buf.max_size())), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_close")); + + impl.stream().async_read_some( + impl.rd_buf.prepare(read_size( + impl.rd_buf, impl.rd_buf.max_size())), + beast::detail::bind_continuation(std::move(*this))); + } impl.rd_buf.commit(bytes_transferred); if(impl.check_stop_now(ec)) goto upcall; @@ -184,10 +220,16 @@ public: impl.rd_remain -= impl.rd_buf.size(); impl.rd_buf.consume(impl.rd_buf.size()); BOOST_ASIO_CORO_YIELD - impl.stream().async_read_some( - impl.rd_buf.prepare(read_size( - impl.rd_buf, impl.rd_buf.max_size())), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_close")); + + impl.stream().async_read_some( + impl.rd_buf.prepare(read_size( + impl.rd_buf, impl.rd_buf.max_size())), + beast::detail::bind_continuation(std::move(*this))); + } impl.rd_buf.commit(bytes_transferred); if(impl.check_stop_now(ec)) goto upcall; @@ -202,8 +244,14 @@ public: BOOST_ASSERT(impl.wr_block.is_locked(this)); using beast::websocket::async_teardown; BOOST_ASIO_CORO_YIELD - async_teardown(impl.role, impl.stream(), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_close")); + + async_teardown(impl.role, impl.stream(), + beast::detail::bind_continuation(std::move(*this))); + } BOOST_ASSERT(impl.wr_block.is_locked(this)); if(ec == net::error::eof) { diff --git a/include/boost/beast/websocket/impl/handshake.hpp b/include/boost/beast/websocket/impl/handshake.hpp index c1ed0264..2298decf 100644 --- a/include/boost/beast/websocket/impl/handshake.hpp +++ b/include/boost/beast/websocket/impl/handshake.hpp @@ -105,16 +105,28 @@ public: // write HTTP request impl.do_pmd_config(d_.req); BOOST_ASIO_CORO_YIELD - http::async_write(impl.stream(), - d_.req, std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_handshake")); + + http::async_write(impl.stream(), + d_.req, std::move(*this)); + } if(impl.check_stop_now(ec)) goto upcall; // read HTTP response BOOST_ASIO_CORO_YIELD - http::async_read(impl.stream(), - impl.rd_buf, d_.p, - std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_handshake")); + + http::async_read(impl.stream(), + impl.rd_buf, d_.p, + std::move(*this)); + } if(ec == http::error::buffer_overflow) { // If the response overflows the internal @@ -127,8 +139,14 @@ public: impl.rd_buf.clear(); BOOST_ASIO_CORO_YIELD - http::async_read(impl.stream(), - d_.fb, d_.p, std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_handshake")); + + http::async_read(impl.stream(), + d_.fb, d_.p, std::move(*this)); + } if(! ec) { diff --git a/include/boost/beast/websocket/impl/ping.hpp b/include/boost/beast/websocket/impl/ping.hpp index eef9983b..735c8543 100644 --- a/include/boost/beast/websocket/impl/ping.hpp +++ b/include/boost/beast/websocket/impl/ping.hpp @@ -82,10 +82,22 @@ public: if(! impl.wr_block.try_lock(this)) { BOOST_ASIO_CORO_YIELD - impl.op_ping.emplace(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_ping")); + + impl.op_ping.emplace(std::move(*this)); + } impl.wr_block.lock(this); BOOST_ASIO_CORO_YIELD - net::post(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_ping")); + + net::post(std::move(*this)); + } BOOST_ASSERT(impl.wr_block.is_locked(this)); } if(impl.check_stop_now(ec)) @@ -93,8 +105,14 @@ public: // Send ping frame BOOST_ASIO_CORO_YIELD - net::async_write(impl.stream(), fb_.data(), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_ping")); + + net::async_write(impl.stream(), fb_.data(), + beast::detail::bind_continuation(std::move(*this))); + } if(impl.check_stop_now(ec)) goto upcall; @@ -173,11 +191,23 @@ public: if(! impl.wr_block.try_lock(this)) { BOOST_ASIO_CORO_YIELD - impl.op_idle_ping.emplace(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_ping")); + + impl.op_idle_ping.emplace(std::move(*this)); + } impl.wr_block.lock(this); BOOST_ASIO_CORO_YIELD - net::post( - this->get_executor(), std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_ping")); + + net::post( + this->get_executor(), std::move(*this)); + } BOOST_ASSERT(impl.wr_block.is_locked(this)); } if(impl.check_stop_now(ec)) @@ -185,9 +215,14 @@ public: // Send ping frame BOOST_ASIO_CORO_YIELD - net::async_write(impl.stream(), fb_->data(), - //beast::detail::bind_continuation(std::move(*this))); - std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_ping")); + + net::async_write(impl.stream(), fb_->data(), + std::move(*this)); + } if(impl.check_stop_now(ec)) goto upcall; diff --git a/include/boost/beast/websocket/impl/read.hpp b/include/boost/beast/websocket/impl/read.hpp index 9d788be1..317983f2 100644 --- a/include/boost/beast/websocket/impl/read.hpp +++ b/include/boost/beast/websocket/impl/read.hpp @@ -102,10 +102,22 @@ public: { do_suspend: BOOST_ASIO_CORO_YIELD - impl.op_r_rd.emplace(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + impl.op_r_rd.emplace(std::move(*this)); + } impl.rd_block.lock(this); BOOST_ASIO_CORO_YIELD - net::post(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + net::post(std::move(*this)); + } BOOST_ASSERT(impl.rd_block.is_locked(this)); BOOST_ASSERT(!ec); @@ -162,10 +174,16 @@ public: } BOOST_ASSERT(impl.rd_block.is_locked(this)); BOOST_ASIO_CORO_YIELD - impl.stream().async_read_some( - impl.rd_buf.prepare(read_size( - impl.rd_buf, impl.rd_buf.max_size())), - std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + impl.stream().async_read_some( + impl.rd_buf.prepare(read_size( + impl.rd_buf, impl.rd_buf.max_size())), + std::move(*this)); + } BOOST_ASSERT(impl.rd_block.is_locked(this)); impl.rd_buf.commit(bytes_transferred); if(impl.check_stop_now(ec)) @@ -205,7 +223,13 @@ public: if(! cont) { BOOST_ASIO_CORO_YIELD - net::post(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + net::post(std::move(*this)); + } BOOST_ASSERT(cont); // VFALCO call check_stop_now() here? } @@ -240,10 +264,22 @@ public: if(! impl.wr_block.try_lock(this)) { BOOST_ASIO_CORO_YIELD - impl.op_rd.emplace(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + impl.op_rd.emplace(std::move(*this)); + } impl.wr_block.lock(this); BOOST_ASIO_CORO_YIELD - net::post(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + net::post(std::move(*this)); + } BOOST_ASSERT(impl.wr_block.is_locked(this)); if(impl.check_stop_now(ec)) goto upcall; @@ -252,9 +288,15 @@ public: // Send pong BOOST_ASSERT(impl.wr_block.is_locked(this)); BOOST_ASIO_CORO_YIELD - net::async_write( - impl.stream(), impl.rd_fb.data(), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + net::async_write( + impl.stream(), impl.rd_fb.data(), + beast::detail::bind_continuation(std::move(*this))); + } BOOST_ASSERT(impl.wr_block.is_locked(this)); if(impl.check_stop_now(ec)) goto upcall; @@ -275,7 +317,13 @@ public: if(! cont) { BOOST_ASIO_CORO_YIELD - net::post(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + net::post(std::move(*this)); + } BOOST_ASSERT(cont); } } @@ -300,7 +348,13 @@ public: if(! cont) { BOOST_ASIO_CORO_YIELD - net::post(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + net::post(std::move(*this)); + } BOOST_ASSERT(cont); } } @@ -358,10 +412,16 @@ public: // Fill the read buffer first, otherwise we // get fewer bytes at the cost of one I/O. BOOST_ASIO_CORO_YIELD - impl.stream().async_read_some( - impl.rd_buf.prepare(read_size( - impl.rd_buf, impl.rd_buf.max_size())), - std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + impl.stream().async_read_some( + impl.rd_buf.prepare(read_size( + impl.rd_buf, impl.rd_buf.max_size())), + std::move(*this)); + } impl.rd_buf.commit(bytes_transferred); if(impl.check_stop_now(ec)) goto upcall; @@ -404,8 +464,14 @@ public: BOOST_ASSERT(buffer_bytes(buffers_prefix( clamp(impl.rd_remain), cb_)) > 0); BOOST_ASIO_CORO_YIELD - impl.stream().async_read_some(buffers_prefix( - clamp(impl.rd_remain), cb_), std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + impl.stream().async_read_some(buffers_prefix( + clamp(impl.rd_remain), cb_), std::move(*this)); + } if(impl.check_stop_now(ec)) goto upcall; impl.reset_idle(); @@ -448,10 +514,16 @@ public: { // read new BOOST_ASIO_CORO_YIELD - impl.stream().async_read_some( - impl.rd_buf.prepare(read_size( - impl.rd_buf, impl.rd_buf.max_size())), - std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + impl.stream().async_read_some( + impl.rd_buf.prepare(read_size( + impl.rd_buf, impl.rd_buf.max_size())), + std::move(*this)); + } if(impl.check_stop_now(ec)) goto upcall; impl.reset_idle(); @@ -548,10 +620,22 @@ public: if(! impl.wr_block.try_lock(this)) { BOOST_ASIO_CORO_YIELD - impl.op_rd.emplace(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + impl.op_rd.emplace(std::move(*this)); + } impl.wr_block.lock(this); BOOST_ASIO_CORO_YIELD - net::post(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + net::post(std::move(*this)); + } BOOST_ASSERT(impl.wr_block.is_locked(this)); if(impl.check_stop_now(ec)) goto upcall; @@ -572,8 +656,14 @@ public: // Send close frame BOOST_ASSERT(impl.wr_block.is_locked(this)); BOOST_ASIO_CORO_YIELD - net::async_write(impl.stream(), impl.rd_fb.data(), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + net::async_write(impl.stream(), impl.rd_fb.data(), + beast::detail::bind_continuation(std::move(*this))); + } BOOST_ASSERT(impl.wr_block.is_locked(this)); if(impl.check_stop_now(ec)) goto upcall; @@ -583,8 +673,14 @@ public: using beast::websocket::async_teardown; BOOST_ASSERT(impl.wr_block.is_locked(this)); BOOST_ASIO_CORO_YIELD - async_teardown(impl.role, impl.stream(), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read_some")); + + async_teardown(impl.role, impl.stream(), + beast::detail::bind_continuation(std::move(*this))); + } BOOST_ASSERT(impl.wr_block.is_locked(this)); if(ec == net::error::eof) { @@ -677,6 +773,11 @@ public: ec, error::buffer_overflow); if(impl.check_stop_now(ec)) goto upcall; + + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::async_read")); + read_some_op( std::move(*this), sp, *mb); } diff --git a/include/boost/beast/websocket/impl/stream_impl.hpp b/include/boost/beast/websocket/impl/stream_impl.hpp index 53e18157..01c0be84 100644 --- a/include/boost/beast/websocket/impl/stream_impl.hpp +++ b/include/boost/beast/websocket/impl/stream_impl.hpp @@ -420,6 +420,12 @@ struct stream::impl_type { timer.expires_after( timeout_opt.handshake_timeout); + + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::check_stop_now" + )); + timer.async_wait( timeout_handler( ex, this->weak_from_this())); @@ -436,6 +442,12 @@ struct stream::impl_type else timer.expires_after( timeout_opt.idle_timeout); + + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::check_stop_now" + )); + timer.async_wait( timeout_handler( ex, this->weak_from_this())); @@ -453,6 +465,12 @@ struct stream::impl_type idle_counter = 0; timer.expires_after( timeout_opt.handshake_timeout); + + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::check_stop_now" + )); + timer.async_wait( timeout_handler( ex, this->weak_from_this())); @@ -551,12 +569,26 @@ private: if( impl.timeout_opt.keep_alive_pings && impl.idle_counter < 1) { - idle_ping_op(sp, get_executor()); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::timeout_handler" + )); + idle_ping_op(sp, get_executor()); + } ++impl.idle_counter; impl.timer.expires_after( impl.timeout_opt.idle_timeout / 2); - impl.timer.async_wait(std::move(*this)); + + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + "websocket::timeout_handler" + )); + + impl.timer.async_wait(std::move(*this)); + } return; } diff --git a/include/boost/beast/websocket/impl/write.hpp b/include/boost/beast/websocket/impl/write.hpp index b76441d3..84f4d69d 100644 --- a/include/boost/beast/websocket/impl/write.hpp +++ b/include/boost/beast/websocket/impl/write.hpp @@ -174,10 +174,28 @@ operator()( { do_suspend: BOOST_ASIO_CORO_YIELD - impl.op_wr.emplace(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + fin_ ? + "websocket::async_write" : + "websocket::async_write_some" + )); + + impl.op_wr.emplace(std::move(*this)); + } impl.wr_block.lock(this); BOOST_ASIO_CORO_YIELD - net::post(std::move(*this)); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + fin_ ? + "websocket::async_write" : + "websocket::async_write_some" + )); + + net::post(std::move(*this)); + } BOOST_ASSERT(impl.wr_block.is_locked(this)); } if(impl.check_stop_now(ec)) @@ -195,9 +213,18 @@ operator()( impl.wr_fb, fh_); impl.wr_cont = ! fin_; BOOST_ASIO_CORO_YIELD - net::async_write(impl.stream(), - buffers_cat(impl.wr_fb.data(), cb_), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + fin_ ? + "websocket::async_write" : + "websocket::async_write_some" + )); + + net::async_write(impl.stream(), + buffers_cat(impl.wr_fb.data(), cb_), + beast::detail::bind_continuation(std::move(*this))); + } bytes_transferred_ += clamp(fh_.len); if(impl.check_stop_now(ec)) goto upcall; @@ -221,10 +248,19 @@ operator()( impl.wr_cont = ! fin_; // Send frame BOOST_ASIO_CORO_YIELD - net::async_write(impl.stream(), buffers_cat( - impl.wr_fb.data(), - buffers_prefix(clamp(fh_.len), cb_)), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + fin_ ? + "websocket::async_write" : + "websocket::async_write_some" + )); + + net::async_write(impl.stream(), buffers_cat( + impl.wr_fb.data(), + buffers_prefix(clamp(fh_.len), cb_)), + beast::detail::bind_continuation(std::move(*this))); + } n = clamp(fh_.len); // restore `n` on yield bytes_transferred_ += n; if(impl.check_stop_now(ec)) @@ -272,10 +308,19 @@ operator()( impl.wr_cont = ! fin_; // write frame header and some payload BOOST_ASIO_CORO_YIELD - net::async_write(impl.stream(), buffers_cat( - impl.wr_fb.data(), - net::buffer(impl.wr_buf.get(), n)), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + fin_ ? + "websocket::async_write" : + "websocket::async_write_some" + )); + + net::async_write(impl.stream(), buffers_cat( + impl.wr_fb.data(), + net::buffer(impl.wr_buf.get(), n)), + beast::detail::bind_continuation(std::move(*this))); + } // VFALCO What about consuming the buffer on error? bytes_transferred_ += bytes_transferred - impl.wr_fb.size(); @@ -292,9 +337,18 @@ operator()( remain_ -= n; // write more payload BOOST_ASIO_CORO_YIELD - net::async_write(impl.stream(), - net::buffer(impl.wr_buf.get(), n), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + fin_ ? + "websocket::async_write" : + "websocket::async_write_some" + )); + + net::async_write(impl.stream(), + net::buffer(impl.wr_buf.get(), n), + beast::detail::bind_continuation(std::move(*this))); + } bytes_transferred_ += bytes_transferred; if(impl.check_stop_now(ec)) goto upcall; @@ -325,10 +379,19 @@ operator()( impl.wr_cont = ! fin_; // Send frame BOOST_ASIO_CORO_YIELD - net::async_write(impl.stream(), buffers_cat( - impl.wr_fb.data(), - net::buffer(impl.wr_buf.get(), n)), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + fin_ ? + "websocket::async_write" : + "websocket::async_write_some" + )); + + net::async_write(impl.stream(), buffers_cat( + impl.wr_fb.data(), + net::buffer(impl.wr_buf.get(), n)), + beast::detail::bind_continuation(std::move(*this))); + } n = bytes_transferred - impl.wr_fb.size(); bytes_transferred_ += n; if(impl.check_stop_now(ec)) @@ -389,9 +452,18 @@ operator()( impl.wr_cont = ! fin_; // Send frame BOOST_ASIO_CORO_YIELD - net::async_write(impl.stream(), buffers_cat( - impl.wr_fb.data(), b), - beast::detail::bind_continuation(std::move(*this))); + { + BOOST_ASIO_HANDLER_LOCATION(( + __FILE__, __LINE__, + fin_ ? + "websocket::async_write" : + "websocket::async_write_some" + )); + + net::async_write(impl.stream(), buffers_cat( + impl.wr_fb.data(), b), + beast::detail::bind_continuation(std::move(*this))); + } bytes_transferred_ += in_; if(impl.check_stop_now(ec)) goto upcall;