From 06103b536fc63ba32439da8552bd2052ad577eb0 Mon Sep 17 00:00:00 2001 From: qicosmos Date: Tue, 30 Jan 2024 17:14:37 +0800 Subject: [PATCH] [string_resize][bug]fix resize (#586) --- .github/workflows/linux_llvm_cov.yml | 4 ++-- include/ylt/struct_pack/util.h | 2 +- include/ylt/thirdparty/cinatra/coro_http_client.hpp | 9 +++++++-- include/ylt/thirdparty/cinatra/string_resize.hpp | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linux_llvm_cov.yml b/.github/workflows/linux_llvm_cov.yml index 356958f26..c4d006b63 100644 --- a/.github/workflows/linux_llvm_cov.yml +++ b/.github/workflows/linux_llvm_cov.yml @@ -43,7 +43,7 @@ jobs: ./struct_pack_test ./struct_pack_test_with_optimize llvm-profdata merge -sparse test_ylt-*.profraw -o test_ylt.profdata - llvm-cov show coro_io_test coro_rpc_test easylog_test struct_pack_test struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio" -show-instantiations=false + llvm-cov show coro_io_test coro_rpc_test easylog_test struct_pack_test struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio|src" -show-instantiations=false echo "Done!" - name: Upload Coverage Results @@ -58,7 +58,7 @@ jobs: echo "Code Coverage Report" > tmp.log echo "for detail, [goto summary](https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/runs/${{github.run_id}}) download Artifacts `llvm-cov`" >> tmp.log echo "\`\`\`" >> tmp.log - llvm-cov report coro_io_test coro_rpc_test easylog_test struct_pack_test struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -ignore-filename-regex="thirdparty|asio" -show-region-summary=false >> tmp.log + llvm-cov report coro_io_test coro_rpc_test easylog_test struct_pack_test struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -ignore-filename-regex="thirdparty|asio|src" -show-region-summary=false >> tmp.log echo "\`\`\`" >> tmp.log - name: Create Comment diff --git a/include/ylt/struct_pack/util.h b/include/ylt/struct_pack/util.h index d2d4d9342..a42635641 100644 --- a/include/ylt/struct_pack/util.h +++ b/include/ylt/struct_pack/util.h @@ -128,7 +128,7 @@ constexpr void STRUCT_PACK_INLINE compile_time_unique( #if __cpp_lib_string_resize_and_overwrite >= 202110L template inline void resize(std::basic_string &str, std::size_t sz) { - str.resize_and_overwrite(sz, [](ch *, std::size_t sz) { + str.resize_and_overwrite(sz, [sz](ch *, std::size_t) { return sz; }); } diff --git a/include/ylt/thirdparty/cinatra/coro_http_client.hpp b/include/ylt/thirdparty/cinatra/coro_http_client.hpp index 34219e57e..36b3b34a5 100644 --- a/include/ylt/thirdparty/cinatra/coro_http_client.hpp +++ b/include/ylt/thirdparty/cinatra/coro_http_client.hpp @@ -811,6 +811,11 @@ class coro_http_client : public std::enable_shared_from_this { req_str_.clear(); total_len_ = 0; #endif + + // clear + head_buf_.consume(head_buf_.size()); + chunked_buf_.consume(chunked_buf_.size()); + resp_chunk_str_.clear(); } async_simple::coro::Lazy reconnect(std::string uri) { @@ -1774,8 +1779,8 @@ class coro_http_client : public std::enable_shared_from_this { head_buf_.consume(head_buf_.size()); size_t header_size = 2; std::shared_ptr sock = socket_; - auto on_ws_msg = std::move(on_ws_msg_); - auto on_ws_close = std::move(on_ws_close_); + auto on_ws_msg = on_ws_msg_; + auto on_ws_close = on_ws_close_; asio::streambuf &read_buf = sock->head_buf_; bool has_init_ssl = false; #ifdef CINATRA_ENABLE_SSL diff --git a/include/ylt/thirdparty/cinatra/string_resize.hpp b/include/ylt/thirdparty/cinatra/string_resize.hpp index bb000f361..7822cfa32 100644 --- a/include/ylt/thirdparty/cinatra/string_resize.hpp +++ b/include/ylt/thirdparty/cinatra/string_resize.hpp @@ -8,7 +8,7 @@ namespace cinatra::detail { #if __cpp_lib_string_resize_and_overwrite >= 202110L template inline void resize(std::basic_string &str, std::size_t sz) { - str.resize_and_overwrite(sz, [](ch *, std::size_t sz) { + str.resize_and_overwrite(sz, [sz](ch *, std::size_t) { return sz; }); }