From 7bf1d97f49dc2e62248e379502d5f207b7a37f55 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 5 Aug 2021 11:16:49 +0200 Subject: [PATCH] Take a ref, not a copy, of the multiplexer callback parameter in the unit tests It does not matter there but we don't want to copy that code and keep the copy in a place where it does. --- pdns/test-mplexer.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pdns/test-mplexer.cc b/pdns/test-mplexer.cc index e1928af0ba..fefdc54779 100644 --- a/pdns/test-mplexer.cc +++ b/pdns/test-mplexer.cc @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(test_MPlexer) ttd.tv_sec -= 5; bool writeCBCalled = false; - auto writeCB = [](int fd, FDMultiplexer::funcparam_t param) { + auto writeCB = [](int fd, FDMultiplexer::funcparam_t& param) { auto calledPtr = boost::any_cast(param); BOOST_REQUIRE(calledPtr != nullptr); *calledPtr = true; @@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(test_MPlexer) BOOST_CHECK_EQUAL(ready, 0); bool readCBCalled = false; - auto readCB = [](int fd, FDMultiplexer::funcparam_t param) { + auto readCB = [](int fd, FDMultiplexer::funcparam_t& param) { auto calledPtr = boost::any_cast(param); BOOST_REQUIRE(calledPtr != nullptr); *calledPtr = true; @@ -235,18 +235,19 @@ BOOST_AUTO_TEST_CASE(test_MPlexer_ReadAndWrite) BOOST_REQUIRE_EQUAL(setNonBlocking(sockets[1]), true); struct timeval now; + gettimeofday(&now, nullptr); std::vector readyFDs; struct timeval ttd = now; ttd.tv_sec += 5; bool readCBCalled = false; bool writeCBCalled = false; - auto readCB = [](int fd, FDMultiplexer::funcparam_t param) { + auto readCB = [](int fd, FDMultiplexer::funcparam_t& param) { auto calledPtr = boost::any_cast(param); BOOST_REQUIRE(calledPtr != nullptr); *calledPtr = true; }; - auto writeCB = [](int fd, FDMultiplexer::funcparam_t param) { + auto writeCB = [](int fd, FDMultiplexer::funcparam_t& param) { auto calledPtr = boost::any_cast(param); BOOST_REQUIRE(calledPtr != nullptr); *calledPtr = true; -- 2.47.2