Skip to content

async_connection: read function calls callback with too few parameters #635

Closed

Description

@susnux

Having a look at:
async_connection.hpp line 395

The read function from async_connection calls the read_callback_function with 2 instead of 4 needed parameters, this leads into this compiling issue (when using the read function):

async_connection.hpp | 395 |
error: no match for call to ‘(const read_callback_function {aka const std::function<void(boost::iterator_range<const char*>, std::error_code, long unsigned int, std::shared_ptr<boost::network::http::async_connection<boost::network::http::tags::http_server, {anonymous}::serverhandle> >)>}) (std::error_code&, size_t&)’|

First reported here: cpp-netlib google groups

Activity

  1. self-assigned this
    on Apr 19, 2016
  2. susnux commented on Apr 19, 2016

    @susnux
    Author

    I am not sure, but I think something like this should work (?)

    diff --git a/boost/network/protocol/http/server/async_connection.hpp b/boost/network/protocol/http/server/async_connection.hpp
    index e5c361a..32fb7f9 100644
    --- a/boost/network/protocol/http/server/async_connection.hpp
    +++ b/boost/network/protocol/http/server/async_connection.hpp
    @@ -388,11 +388,10 @@ struct async_connection
           return;
         }
    
    -    auto self = this->shared_from_this();
         socket().async_read_some(asio::buffer(read_buffer_),
    -                             strand.wrap([this, self, callback](
    +                             strand.wrap([this, callback](
                                      std::error_code ec, size_t bytes_transferred) {
    -                               callback(ec, bytes_transferred);
    +                               this->wrap_read_handler(callback, ec, bytes_transferred);
                                  }));
       }
    
  3. added 2 commits that reference this issue on Apr 19, 2016
    79aaa62
    ec08b28
  4. susnux commented on Apr 20, 2016

    @susnux
    Author

    Question: Are the fixes also going to be merged back into master?

  5. deanberris commented on Apr 21, 2016

    @deanberris
    Member

    @susnux It should be, I'll cherry-pick it in soon.

  6. added a commit that references this issue on Apr 21, 2016
    cf080ef
  7. MMOSimca commented on Apr 23, 2016

    @MMOSimca

    To say this is a pretty huge bug is kind of an understatement (all reading of request bodies for servers broken) - maybe there should be a 0.12.1 release for this fix?

  8. susnux commented on Apr 23, 2016

    @susnux
    Author

    I think @deanberris (?) is working on a bugfix release 0.12.1

  9. added a commit that references this issue on Apr 25, 2016
    68507ac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions