From: Remi Gacogne Date: Thu, 5 Aug 2021 09:16:49 +0000 (+0200) Subject: Take a ref, not a copy, of the multiplexer callback parameter in the unit tests X-Git-Tag: dnsdist-1.7.0-alpha1~61^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bf1d97f49dc2e62248e379502d5f207b7a37f55;p=thirdparty%2Fpdns.git 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. --- 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;