From 69baa3b47859bda4fe65e389477219821a47c979 Mon Sep 17 00:00:00 2001 From: Eric Esquibel Date: Tue, 21 Nov 2017 18:07:37 -0700 Subject: [PATCH 1/7] Fixed ambiguous reference to shared_ptr --- bench/db.cpp | 2 +- src/queue/iqstream.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bench/db.cpp b/bench/db.cpp index a5634d2..b2c41bd 100644 --- a/bench/db.cpp +++ b/bench/db.cpp @@ -55,7 +55,7 @@ class session : public enable_shared_from_this public: typedef ip::tcp::socket socket_type; - typedef shared_ptr ptr_type; + typedef boost::shared_ptr ptr_type; session(io_service& ios, results& _results, const string& host, size_t port, size_t bad_client_rate, size_t action = 0) diff --git a/src/queue/iqstream.cpp b/src/queue/iqstream.cpp index 36d1f00..4664cf1 100644 --- a/src/queue/iqstream.cpp +++ b/src/queue/iqstream.cpp @@ -12,7 +12,7 @@ iqstream::~iqstream() queue_->pop_end(false, id_, header_); } -bool iqstream::open(shared_ptr queue) +bool iqstream::open(boost::shared_ptr queue) { if (queue_) throw system::system_error(asio::error::already_open); // can't open what's open From 9ace1026be6b6c64bd94f73edb238421ead9f1e1 Mon Sep 17 00:00:00 2001 From: Eric Esquibel Date: Tue, 21 Nov 2017 18:35:36 -0700 Subject: [PATCH 2/7] Added explicit type conversion --- include/darner/queue/iqstream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/darner/queue/iqstream.h b/include/darner/queue/iqstream.h index 59222ea..d1c15b0 100644 --- a/include/darner/queue/iqstream.h +++ b/include/darner/queue/iqstream.h @@ -45,7 +45,7 @@ class iqstream /* * returns true if open */ - operator bool() const { return queue_; } + operator bool() const { return static_cast(queue_); } private: From 1d1a17043f5430a9e587d3f36ba62403c7ff1860 Mon Sep 17 00:00:00 2001 From: Eric Esquibel Date: Tue, 21 Nov 2017 18:51:42 -0700 Subject: [PATCH 3/7] Fixed ambiguous references to ref --- tests/queue.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/queue.cpp b/tests/queue.cpp index e070075..b4f245c 100644 --- a/tests/queue.cpp +++ b/tests/queue.cpp @@ -40,7 +40,7 @@ BOOST_FIXTURE_TEST_CASE( test_pop_wait, fixtures::basic_queue ) "elevator sometimes, my 7 floor sanctuary"; posix_time::ptime beg = boost::posix_time::microsec_clock::local_time(); deadline_timer timer(ios_, posix_time::milliseconds(10)); - timer.async_wait(bind(&fixtures::basic_queue::delayed_push, this, ref(value), _1)); + timer.async_wait(bind(&fixtures::basic_queue::delayed_push, this, boost::ref(value), _1)); queue_->wait(100, wait_cb_); ios_.run(); boost::posix_time::ptime end = boost::posix_time::microsec_clock::local_time(); @@ -56,9 +56,9 @@ BOOST_FIXTURE_TEST_CASE( test_multiple_pop_wait, fixtures::basic_queue ) string value2 = "Hotel robe got me feeling like a Sheik"; posix_time::ptime beg = boost::posix_time::microsec_clock::local_time(); deadline_timer timer1(ios_, posix_time::milliseconds(10)); - timer1.async_wait(bind(&fixtures::basic_queue::delayed_push, this, ref(value1), _1)); + timer1.async_wait(bind(&fixtures::basic_queue::delayed_push, this, boost::ref(value1), _1)); deadline_timer timer2(ios_, posix_time::milliseconds(20)); - timer2.async_wait(bind(&fixtures::basic_queue::delayed_push, this, ref(value2), _1)); + timer2.async_wait(bind(&fixtures::basic_queue::delayed_push, this, boost::ref(value2), _1)); queue_->wait(100, wait_cb_); queue_->wait(100, wait_cb_); ios_.run(); @@ -74,7 +74,7 @@ BOOST_FIXTURE_TEST_CASE( test_pop_wait_race, fixtures::basic_queue ) { string value = "Fur pillows are hard to actually sleep on"; deadline_timer timer(ios_, posix_time::milliseconds(80)); - timer.async_wait(bind(&fixtures::basic_queue::delayed_push_block, this, ref(value), _1)); + timer.async_wait(bind(&fixtures::basic_queue::delayed_push_block, this, boost::ref(value), _1)); queue_->wait(100, wait_cb_); ios_.run(); @@ -86,7 +86,7 @@ BOOST_FIXTURE_TEST_CASE( test_pop_wait_timeout, fixtures::basic_queue ) { string value = "Classical music is tight yo"; deadline_timer timer(ios_, posix_time::milliseconds(50)); - timer.async_wait(bind(&fixtures::basic_queue::delayed_push, this, ref(value), _1)); + timer.async_wait(bind(&fixtures::basic_queue::delayed_push, this, boost::ref(value), _1)); queue_->wait(10, wait_cb_); ios_.run(); From 4c8f53cba78249fad9bf36e8d0f3a23d95d0db92 Mon Sep 17 00:00:00 2001 From: Eric Esquibel Date: Tue, 21 Nov 2017 19:02:59 -0700 Subject: [PATCH 4/7] Fixed ambiguous reference to array --- src/net/handler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net/handler.cpp b/src/net/handler.cpp index dc08fd6..a782b32 100644 --- a/src/net/handler.cpp +++ b/src/net/handler.cpp @@ -228,12 +228,12 @@ void handler::get() } } ++stats_.items_dequeued; - array bufs = {{ buffer(header_buf_), buffer(buf_), buffer("\r\nEND\r\n", 7) }}; + boost::array bufs = {{ buffer(header_buf_), buffer(buf_), buffer("\r\nEND\r\n", 7) }}; async_write(socket_, bufs, bind(&handler::read_request, shared_from_this(), _1, _2)); } else { - array bufs = {{ buffer(header_buf_), buffer(buf_) }}; + boost::array bufs = {{ buffer(header_buf_), buffer(buf_) }}; async_write(socket_, bufs, bind(&handler::get_on_write_chunk, shared_from_this(), _1, _2)); } } From b9faeaca634c18d986a5bf5e000d8e83f84e1b87 Mon Sep 17 00:00:00 2001 From: Eric Esquibel Date: Tue, 21 Nov 2017 19:08:52 -0700 Subject: [PATCH 5/7] Fixed ambiguous reference to enable_shared_from_this --- bench/db.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/db.cpp b/bench/db.cpp index b2c41bd..a75bdfd 100644 --- a/bench/db.cpp +++ b/bench/db.cpp @@ -50,7 +50,7 @@ struct results size_t sets_remaining; }; -class session : public enable_shared_from_this +class session : public boost::enable_shared_from_this { public: From 7636e78f41cd8f2e3faa8a77d89f9256abc18297 Mon Sep 17 00:00:00 2001 From: Eric Esquibel Date: Wed, 22 Nov 2017 16:58:05 -0700 Subject: [PATCH 6/7] Fixed suspected chicken-and-egg problem with unit test Suspect that we were opening a new connection to the journal before the previous instance of the object had properly destructed --- tests/queue.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/queue.cpp b/tests/queue.cpp index b4f245c..f8b2ed3 100644 --- a/tests/queue.cpp +++ b/tests/queue.cpp @@ -101,6 +101,7 @@ BOOST_FIXTURE_TEST_CASE( test_queue_close_reopen, fixtures::basic_queue ) oqs_.open(queue_, 1); oqs_.write(value); + queue_.reset(); queue_.reset(new darner::queue(ios_, (tmp_ / "queue").string())); BOOST_REQUIRE_EQUAL(queue_->count(), 1); From 8703f4acd3007cd50a7244af27606155040a2fca Mon Sep 17 00:00:00 2001 From: Eric Esquibel Date: Wed, 22 Nov 2017 17:50:43 -0700 Subject: [PATCH 7/7] Updated CMakeList.txt to not link server binary against the unit test framework - Needed for Docker multi-stage build, i.e. https://github.com/eesquibel/darner-docker --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19c862e..20955ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,9 +35,11 @@ ADD_EXECUTABLE(test tests/main ) -FIND_PACKAGE(Boost 1.40.0 COMPONENTS thread system program_options unit_test_framework filesystem) +FIND_PACKAGE(Boost 1.40.0 COMPONENTS thread system program_options filesystem unit_test_framework) + +# Explicitly list libraries for each Boost component to avoid linking server executable to the unit test library +TARGET_LINK_LIBRARIES(darner pthread ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} leveldb snappy) -TARGET_LINK_LIBRARIES(darner pthread ${Boost_LIBRARIES} leveldb snappy) TARGET_LINK_LIBRARIES(db ${Boost_LIBRARIES}) TARGET_LINK_LIBRARIES(test pthread ${Boost_LIBRARIES} leveldb snappy)