]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Take a ref, not a copy, of the multiplexer callback parameter in the unit tests
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 5 Aug 2021 09:16:49 +0000 (11:16 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 5 Aug 2021 09:16:49 +0000 (11:16 +0200)
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

index e1928af0ba4195b8641fc0a7a828672d0291675f..fefdc54779d9dacef4a81f1f9192359a6280fa8d 100644 (file)
@@ -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<bool*>(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<bool*>(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<int> 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<bool*>(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<bool*>(param);
       BOOST_REQUIRE(calledPtr != nullptr);
       *calledPtr = true;