Skip to content

Commit

Permalink
tests: fix fstream_test misuse of shared_ptr
Browse files Browse the repository at this point in the history
'static shared_ptr' causes the shared_ptr to be destroyed on a cpu other
than the one it was constructed on, which is illegal.
  • Loading branch information
avikivity committed Jun 20, 2015
1 parent 535928c commit 439b9c8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/fstream_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ struct reader {
};

SEASTAR_TEST_CASE(test_fstream) {
static auto sem = make_lw_shared<semaphore>(0);
auto sem = make_lw_shared<semaphore>(0);

engine().open_file_dma("testfile.tmp",
open_flags::rw | open_flags::create | open_flags::truncate).then([] (file f) {
open_flags::rw | open_flags::create | open_flags::truncate).then([sem] (file f) {
auto w = make_shared<writer>(std::move(f));
auto buf = static_cast<char*>(::malloc(4096));
memset(buf, 0, 4096);
Expand Down Expand Up @@ -85,7 +85,7 @@ SEASTAR_TEST_CASE(test_fstream) {
BOOST_REQUIRE(p[4096] == '[' && p[4096 + 1] == 'B' && p[4096 + 8191] == ']');
return make_ready_future<>();
});
}).finally([] () {
}).finally([sem] () {
sem->signal();
});
});
Expand All @@ -94,10 +94,10 @@ SEASTAR_TEST_CASE(test_fstream) {
}

SEASTAR_TEST_CASE(test_fstream_unaligned) {
static auto sem = make_lw_shared<semaphore>(0);
auto sem = make_lw_shared<semaphore>(0);

engine().open_file_dma("testfile.tmp",
open_flags::rw | open_flags::create | open_flags::truncate).then([] (file f) {
open_flags::rw | open_flags::create | open_flags::truncate).then([sem] (file f) {
auto w = make_shared<writer>(std::move(f));
auto buf = static_cast<char*>(::malloc(40));
memset(buf, 0, 40);
Expand Down Expand Up @@ -126,7 +126,7 @@ SEASTAR_TEST_CASE(test_fstream_unaligned) {
BOOST_REQUIRE(p[0] == '[' && p[1] == 'A' && p[39] == ']');
return make_ready_future<>();
});
}).finally([] () {
}).finally([sem] () {
sem->signal();
});
});
Expand Down

0 comments on commit 439b9c8

Please sign in to comment.