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

Fixed #1237: hpx::util::portable_binary_iarchive failed #1238

Merged
merged 3 commits into from Aug 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 10 additions & 11 deletions hpx/util/basic_binary_iprimitive.hpp
Expand Up @@ -160,22 +160,26 @@ namespace hpx { namespace util

template <typename Container>
basic_binary_iprimitive(Container const& buffer,
boost::uint64_t inbound_data_size)
: flags_(0),
boost::uint64_t inbound_data_size, unsigned flags)
: flags_(flags),
size_(0),
buffer_(boost::make_shared<detail::icontainer_type<Container> >(
buffer, inbound_data_size))
{}
{
init(flags);
}

template <typename Container>
basic_binary_iprimitive(Container const& buffer,
std::vector<serialization_chunk> const* chunks,
boost::uint64_t inbound_data_size)
: flags_(0),
boost::uint64_t inbound_data_size, unsigned flags)
: flags_(flags),
size_(0),
buffer_(boost::make_shared<detail::icontainer_type<Container> >(
buffer, chunks, inbound_data_size))
{}
{
init(flags);
}

public:
// we provide an optimized load for all fundamental types
Expand Down Expand Up @@ -208,11 +212,6 @@ namespace hpx { namespace util
{
return flags_;
}
void set_flags(boost::uint32_t flags_value)
{
flags_ = flags_value;
init(flags_);
}

protected:
// the optimized load_array dispatches to load_binary
Expand Down
8 changes: 4 additions & 4 deletions hpx/util/portable_binary_iarchive.hpp
Expand Up @@ -270,20 +270,20 @@ class HPX_SERIALIZATION_EXPORT portable_binary_iarchive :
template <typename Container>
portable_binary_iarchive(Container const& buffer,
boost::uint64_t inbound_data_size, unsigned flags_value = 0)
: primitive_base_t(buffer, inbound_data_size),
: primitive_base_t(buffer, inbound_data_size, flags_value),
archive_base_t(flags_value)
{
this->set_flags(init(flags_value));
init(flags_value);
}

template <typename Container>
portable_binary_iarchive(Container const& buffer,
std::vector<serialization_chunk> const* chunks,
boost::uint64_t inbound_data_size, unsigned flags_value = 0)
: primitive_base_t(buffer, chunks, inbound_data_size),
: primitive_base_t(buffer, chunks, inbound_data_size, flags_value),
archive_base_t(flags_value)
{
this->set_flags(init(flags_value));
init(flags_value);
}

// the optimized load_array dispatches to load_binary
Expand Down
7 changes: 3 additions & 4 deletions tests/regressions/util/CMakeLists.txt
Expand Up @@ -8,17 +8,16 @@ set(tests
command_line_arguments_706
function_argument
function_serialization_728
iarchive_1237
protect_with_nullary_pfo
serialize_buffer_1069
tuple_serialization_803
zero_copy_parcels_1001
)

set(function_argument_FLAGS DEPENDENCIES iostreams_component)

set(function_serialization_728_dependencies
iostreams_component)

set(function_serialization_728_dependencies iostreams_component)
set(iarchive_1237_FLAGS DEPENDENCIES iostreams_component)
set(serialize_buffer_1069_FLAGS DEPENDENCIES iostreams_component)

if(HPX_HAVE_COMPRESSION_ZLIB AND ZLIB_FOUND)
Expand Down
52 changes: 52 additions & 0 deletions tests/regressions/util/iarchive_1237.cpp
@@ -0,0 +1,52 @@
// Copyright (c) 2007-2013 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// This test verifies that issue #1001 is resolved (Zero copy serialization raises assert).

#include <hpx/hpx_init.hpp>
#include <hpx/include/util.hpp>
#include <hpx/util/lightweight_test.hpp>

#include <boost/serialization/serialization.hpp>
#include <boost/serialization/vector.hpp>

#include <vector>
#include <iostream>

///////////////////////////////////////////////////////////////////////////////
int hpx_main()
{
{
std::vector<int> int_vector;
int_vector.push_back(1);
int_vector.push_back(2);
int_vector.push_back(3);
std::vector<char> out_buffer;

hpx::util::portable_binary_oarchive oa(out_buffer);
oa << int_vector;

hpx::util::portable_binary_iarchive ia(out_buffer, out_buffer.size());
std::vector<int> copy_vector;
ia >> copy_vector;

HPX_TEST_EQ(std::size_t(3), copy_vector.size());
HPX_TEST_EQ(copy_vector[0], 1);
HPX_TEST_EQ(copy_vector[1], 2);
HPX_TEST_EQ(copy_vector[2], 3);
}

return hpx::finalize();
}

///////////////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{
// Initialize and run HPX
HPX_TEST_EQ(hpx::init(argc, argv), 0);

return hpx::util::report_errors();
}