Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to boost::beast #2348

Closed
wants to merge 2 commits into from
Closed

Convert to boost::beast #2348

wants to merge 2 commits into from

Conversation

seelabs
Copy link
Collaborator

@seelabs seelabs commented Jan 22, 2018

After this patch is accepted rippled will require boost 1.66 or later.

@ripplelabs-jenkins
Copy link
Collaborator

ripplelabs-jenkins commented Jan 22, 2018

Jenkins Build Summary

Built from this commit

Built at 20180125 - 18:44:01

Test Results

Build Type Result Status
coverage 985 cases, 0 failed, t: 573s PASS ✅
clang.debug.unity 985 cases, 0 failed, t: 450s PASS ✅
gcc.debug.unity 985 cases, 0 failed, t: 393s PASS ✅
gcc.debug.nounity 983 cases, 0 failed, t: 287s PASS ✅
clang.debug.nounity 983 cases, 0 failed, t: 869s PASS ✅
clang.release.unity 984 cases, 0 failed, t: 478s PASS ✅
gcc.release.unity 984 cases, 0 failed, t: 501s PASS ✅

@seelabs
Copy link
Collaborator Author

seelabs commented Jan 23, 2018

Windows unit test asserts

@HowardHinnant
Copy link
Contributor

Which assert?

@HowardHinnant
Copy link
Contributor

Oh, inside boost/beast. Interesting I'm not seeing that on macOS.

@HowardHinnant
Copy link
Contributor

HowardHinnant commented Jan 23, 2018

This is the line that is asserting: https://github.com/boostorg/beast/blob/develop/include/boost/beast/websocket/impl/read.ipp#L638

Notes:

  1. This code already has fairly extensive changes since boost 1.66.
  2. This code path is not exercised during unit tests on macOS, but obviously is on Windows.

Questions:

  1. Is it exercised on Windows desktop or just by Appveyor?
  2. Why is it not exercised on macOS?
  3. Is it exercised on Linux?

@seelabs
Copy link
Collaborator Author

seelabs commented Jan 23, 2018

@HowardHinnant I do exercise that line in linux. I'm currently trying to set up a windows VM that I can compile rippled on.

@HowardHinnant
Copy link
Contributor

Interesting, thanks. I'll try to figure out why it isn't exercised on macOS.

@HowardHinnant
Copy link
Contributor

I am mistaken above: This assert is exercised on macOS, but does not fire.

@HowardHinnant
Copy link
Contributor

This PR looks fine to me. But I'm holding off on the approve until we learn more about the Windows unittest failure. I've taken a cursory look, but have been unsuccessful at a diagnosis using only macOS.

@seelabs
Copy link
Collaborator Author

seelabs commented Jan 24, 2018

Pushed a fix for the window's assert (thanks you @miguelportilla!)

Copy link
Contributor

@miguelportilla miguelportilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -117,7 +117,9 @@ class WSClientImpl : public WSClient
error_code ec;
if (!peerClosed_)
{
ws_.async_close({}, [&](error_code ec) { stream_.close(ec); });
ws_.async_close({}, strand_.wrap([&](error_code ec) {
stream_.close(ec);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not necessary to call stream_.close(ec) as its already closed with ws_async_close. However, calling stream_.cancel(ec) is a good idea to stop all asynchronous operations associated with the socket.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and pushed.

Copy link
Contributor

@HowardHinnant HowardHinnant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests out great on macOS. Nice job all around for all involved.

@seelabs seelabs added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Jan 25, 2018
{
ec.assign(0, ec.category());
return {{const_buffers_type{
body_string_.data(), body_string_.size()}, false}};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I wonder if storing the buffer might be a better option.

eg.

    class writer
    {
        boost::asio::const_buffer buffer_;

    public:
        using const_buffers_type =
            boost::asio::const_buffer;

        template<bool isRequest, class Fields>
        explicit
        writer(boost::beast::http::message<isRequest,
                json_body, Fields> const& msg)
        {
            auto s {to_string(msg.body())};
            buffer_ = const_buffers_type{s.data(), s.size()};
        }

        void
        init(boost::beast::error_code& ec)
        {
            ec.assign(0, ec.category());
        }

        boost::optional<std::pair<const_buffers_type, bool>>
        get(boost::beast::error_code& ec)
        {
            ec.assign(0, ec.category());
            return {{buffer_, false}};
        }
    };

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const_buffer doesn't own it's memory, so I don't think that works (it would point to the re-claimed string memory).

Copy link
Contributor

@miguelportilla miguelportilla Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct, I forgot const_buffer doesn't own the memory and cheap to construct.

@seelabs
Copy link
Collaborator Author

seelabs commented Jan 30, 2018

In 0.90.0-b5

@seelabs seelabs closed this Jan 30, 2018
@seelabs seelabs deleted the boost166 branch January 30, 2018 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants