Skip to content

Commit 133ccdf

Browse files
author
Razvan Becheriu
committed
[#3190] fixed ASAN warnings
1 parent 8fc6b6f commit 133ccdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+941
-588
lines changed

src/bin/agent/ca_process.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ CtrlAgentProcess::CtrlAgentProcess(const char* name,
3333
}
3434

3535
CtrlAgentProcess::~CtrlAgentProcess() {
36+
garbageCollectListeners(0);
3637
}
3738

3839
void
@@ -206,7 +207,10 @@ CtrlAgentProcess::garbageCollectListeners(size_t leaving) {
206207
}
207208
// We have stopped listeners but there may be some pending handlers
208209
// related to these listeners. Need to invoke these handlers.
209-
getIOService()->poll();
210+
try {
211+
getIOService()->poll();
212+
} catch (...) {
213+
}
210214
// Finally, we're ready to remove no longer used listeners.
211215
http_listeners_.erase(http_listeners_.begin(),
212216
http_listeners_.end() - leaving);

src/bin/agent/tests/ca_controller_unittests.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ TEST_F(CtrlAgentControllerTest, basicInstanceTesting) {
188188
EXPECT_FALSE(checkProcess());
189189
}
190190

191-
192191
// Tests basic command line processing.
193192
// Verifies that:
194193
// 1. Standard command line options are supported.
@@ -680,7 +679,6 @@ TEST_F(CtrlAgentControllerTest, configReloadFileValid) {
680679
answer = CtrlAgentCommandMgr::instance().handleCommand("config-reload",
681680
params, cmd);
682681

683-
684682
// Verify the reload was successful.
685683
string expected = "{ \"result\": 0, \"text\": "
686684
"\"Configuration applied successfully.\" }";
@@ -785,7 +783,6 @@ TEST_F(CtrlAgentControllerTest, shutdown) {
785783
ctrl->deregisterCommands();
786784
}
787785

788-
789786
TEST_F(CtrlAgentControllerTest, shutdownExitValue) {
790787
ASSERT_NO_THROW(initProcess());
791788
EXPECT_TRUE(checkProcess());

src/bin/agent/tests/ca_process_unittests.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ TEST_F(CtrlAgentProcessTest, shutdown) {
8484
time_duration elapsed = stop - start;
8585
EXPECT_TRUE(elapsed.total_milliseconds() >= 100 &&
8686
elapsed.total_milliseconds() <= 400);
87-
}
8887

88+
timer.cancel();
89+
getIOService()->restart();
90+
try {
91+
getIOService()->poll();
92+
} catch (...) {
93+
}
94+
}
8995

9096
}

src/bin/d2/d2_process.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ D2Process::reconfigureQueueMgr() {
439439
}
440440

441441
D2Process::~D2Process() {
442+
queue_mgr_->stopListening();
443+
auto f = [](D2QueueMgrPtr) {};
444+
getIOService()->post(std::bind(f, queue_mgr_));
442445
}
443446

444447
D2CfgMgrPtr

src/bin/d2/d2_queue_mgr.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ D2QueueMgr::updateStopState() {
178178
DHCP_DDNS_QUEUE_MGR_STOPPED);
179179
}
180180

181-
182181
void
183182
D2QueueMgr::removeListener() {
184183
// Force our managing layer(s) to stop us properly first.
@@ -224,7 +223,6 @@ D2QueueMgr::dequeueAt(const size_t index) {
224223
ncr_queue_.erase(pos);
225224
}
226225

227-
228226
void
229227
D2QueueMgr::dequeue() {
230228
if (getQueueSize() == 0) {

src/bin/d2/d2_queue_mgr.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class D2QueueMgrReceiveError : public isc::Exception {
4040
isc::Exception(file, line, what) { };
4141
};
4242

43-
4443
/// @brief Thrown if the request queue is full when an enqueue is attempted.
4544
/// @todo use or remove it.
4645
class D2QueueMgrQueueFull : public isc::Exception {
@@ -63,7 +62,6 @@ class D2QueueMgrInvalidIndex : public isc::Exception {
6362
isc::Exception(file, line, what) { };
6463
};
6564

66-
6765
/// @brief D2QueueMgr creates and manages a queue of DNS update requests.
6866
///
6967
/// D2QueueMgr is a class specifically designed as an integral part of DHCP-DDNS.
@@ -217,8 +215,8 @@ class D2QueueMgr : public dhcp_ddns::NameChangeListener::RequestReceiveHandler,
217215
/// @param ncr is a pointer to the newly received NameChangeRequest if
218216
/// result is NameChangeListener::SUCCESS. It is indeterminate other
219217
/// wise.
220-
virtual void operator ()(const dhcp_ddns::NameChangeListener::Result result,
221-
dhcp_ddns::NameChangeRequestPtr& ncr);
218+
virtual void operator()(const dhcp_ddns::NameChangeListener::Result result,
219+
dhcp_ddns::NameChangeRequestPtr& ncr);
222220

223221
/// @brief Stops listening for requests.
224222
///
@@ -234,7 +232,6 @@ class D2QueueMgr : public dhcp_ddns::NameChangeListener::RequestReceiveHandler,
234232
/// @throw D2QueueMgrError if stop_state is a valid stop state.
235233
void stopListening(const State target_stop_state = STOPPED);
236234

237-
238235
/// @brief Deletes the current listener
239236
///
240237
/// This method will delete the current listener and returns the manager

src/bin/d2/tests/d2_process_unittests.cc

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ class D2ProcessTest : public D2Process, public ConfigParseTest {
113113
const D2QueueMgrPtr& queue_mgr = getD2QueueMgr();
114114

115115
// If queue manager isn't in the RUNNING state, return failure.
116-
if (D2QueueMgr::RUNNING != queue_mgr->getMgrState()) {
116+
if (D2QueueMgr::RUNNING != queue_mgr->getMgrState()) {
117117
return (::testing::AssertionFailure(::testing::Message() <<
118-
"queue manager did not start"));
118+
"queue manager did not start"));
119119
}
120120

121121
// Good to go.
@@ -578,6 +578,13 @@ TEST_F(D2ProcessTest, normalShutdown) {
578578
time_duration elapsed = stop - start;
579579
EXPECT_TRUE(elapsed.total_milliseconds() >= 1900 &&
580580
elapsed.total_milliseconds() <= 2200);
581+
582+
timer.cancel();
583+
getIOService()->restart();
584+
try {
585+
getIOService()->poll();
586+
} catch (...) {
587+
}
581588
}
582589

583590
/// @brief Verifies that an "uncaught" exception thrown during event loop
@@ -602,6 +609,13 @@ TEST_F(D2ProcessTest, fatalErrorShutdown) {
602609
time_duration elapsed = stop - start;
603610
EXPECT_TRUE(elapsed.total_milliseconds() >= 1900 &&
604611
elapsed.total_milliseconds() <= 2200);
612+
613+
timer.cancel();
614+
getIOService()->restart();
615+
try {
616+
getIOService()->poll();
617+
} catch (...) {
618+
}
605619
}
606620

607621
/// @brief Used to permit visual inspection of logs to ensure

src/bin/d2/tests/d2_queue_mgr_unittests.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,15 @@ class QueueMgrUDPTest : public virtual ::testing::Test, public D2StatTest,
232232
TEST_TIMEOUT);
233233
}
234234

235+
virtual ~QueueMgrUDPTest() {
236+
test_timer_.cancel();
237+
io_service_->restart();
238+
try {
239+
io_service_->poll();
240+
} catch (...) {
241+
}
242+
}
243+
235244
void reset_results() {
236245
sent_ncrs_.clear();
237246
received_ncrs_.clear();

src/bin/d2/tests/d2_update_mgr_unittests.cc

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class D2UpdateMgrTest : public TimedIO, public ConfigParseTest {
7171
D2UpdateMgrWrapperPtr update_mgr_;
7272
std::vector<NameChangeRequestPtr> canned_ncrs_;
7373
size_t canned_count_;
74+
boost::shared_ptr<FauxServer> server_;
7475

7576
D2UpdateMgrTest() {
7677
queue_mgr_.reset(new D2QueueMgr(io_service_));
@@ -82,6 +83,14 @@ class D2UpdateMgrTest : public TimedIO, public ConfigParseTest {
8283
}
8384

8485
~D2UpdateMgrTest() {
86+
if (server_) {
87+
server_->stop();
88+
}
89+
io_service_->restart();
90+
try {
91+
io_service_->poll();
92+
} catch (...) {
93+
}
8594
}
8695

8796
/// @brief Creates a list of valid NameChangeRequest.
@@ -184,11 +193,11 @@ class D2UpdateMgrTest : public TimedIO, public ConfigParseTest {
184193
TransactionList::iterator it = update_mgr_->transactionListBegin();
185194
while (it != update_mgr_->transactionListEnd()) {
186195
if (((*it).second)->isModelWaiting()) {
187-
return true;
196+
return (true);
188197
}
189198
}
190199

191-
return false;
200+
return (false);
192201
}
193202

194203
/// @brief Process events until all requests have been completed.
@@ -692,8 +701,8 @@ TEST_F(D2UpdateMgrTest, addTransaction) {
692701

693702
// Create a server based on the transaction's current server, and
694703
// start it listening.
695-
FauxServer server(io_service_, *(trans->getCurrentServer()));
696-
server.receive(FauxServer::USE_RCODE, dns::Rcode::NOERROR());
704+
server_.reset(new FauxServer(io_service_, *(trans->getCurrentServer())));
705+
server_->receive(FauxServer::USE_RCODE, dns::Rcode::NOERROR());
697706

698707
// Run sweep and IO until everything is done.
699708
processAll();
@@ -749,8 +758,8 @@ TEST_F(D2UpdateMgrTest, removeTransaction) {
749758

750759
// Create a server based on the transaction's current server, and
751760
// start it listening.
752-
FauxServer server(io_service_, *(trans->getCurrentServer()));
753-
server.receive(FauxServer::USE_RCODE, dns::Rcode::NOERROR());
761+
server_.reset(new FauxServer(io_service_, *(trans->getCurrentServer())));
762+
server_->receive(FauxServer::USE_RCODE, dns::Rcode::NOERROR());
754763

755764
// Run sweep and IO until everything is done.
756765
processAll();
@@ -797,8 +806,8 @@ TEST_F(D2UpdateMgrTest, errorTransaction) {
797806
ASSERT_TRUE(trans->getCurrentServer());
798807

799808
// Create a server and start it listening.
800-
FauxServer server(io_service_, *(trans->getCurrentServer()));
801-
server.receive(FauxServer::CORRUPT_RESP);
809+
server_.reset(new FauxServer(io_service_, *(trans->getCurrentServer())));
810+
server_->receive(FauxServer::CORRUPT_RESP);
802811

803812
// Run sweep and IO until everything is done.
804813
processAll();
@@ -836,8 +845,8 @@ TEST_F(D2UpdateMgrTest, multiTransaction) {
836845
// that all of configured servers have the same address.
837846
// and start it listening.
838847
asiolink::IOAddress server_ip("127.0.0.1");
839-
FauxServer server(io_service_, server_ip, 5301);
840-
server.receive(FauxServer::USE_RCODE, dns::Rcode::NOERROR());
848+
server_.reset(new FauxServer(io_service_, server_ip, 5301));
849+
server_->receive(FauxServer::USE_RCODE, dns::Rcode::NOERROR());
841850

842851
// Run sweep and IO until everything is done.
843852
processAll();
@@ -908,8 +917,8 @@ TEST_F(D2UpdateMgrTest, simpleAddTransaction) {
908917

909918
// Create a server based on the transaction's current server, and
910919
// start it listening.
911-
FauxServer server(io_service_, *(trans->getCurrentServer()));
912-
server.receive(FauxServer::USE_RCODE, dns::Rcode::NOERROR());
920+
server_.reset(new FauxServer(io_service_, *(trans->getCurrentServer())));
921+
server_->receive(FauxServer::USE_RCODE, dns::Rcode::NOERROR());
913922

914923
// Run sweep and IO until everything is done.
915924
processAll();
@@ -966,8 +975,8 @@ TEST_F(D2UpdateMgrTest, simpleRemoveTransaction) {
966975

967976
// Create a server based on the transaction's current server, and
968977
// start it listening.
969-
FauxServer server(io_service_, *(trans->getCurrentServer()));
970-
server.receive(FauxServer::USE_RCODE, dns::Rcode::NOERROR());
978+
server_.reset(new FauxServer(io_service_, *(trans->getCurrentServer())));
979+
server_->receive(FauxServer::USE_RCODE, dns::Rcode::NOERROR());
971980

972981
// Run sweep and IO until everything is done.
973982
processAll();

src/bin/dhcp4/dhcp4_srv.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,11 @@ Dhcpv4Srv::~Dhcpv4Srv() {
705705
}
706706
LOG_ERROR(dhcp4_logger, DHCP4_SRV_UNLOAD_LIBRARIES_ERROR).arg(msg);
707707
}
708+
io_service_->restart();
709+
try {
710+
io_service_->poll();
711+
} catch (...) {
712+
}
708713
}
709714

710715
void

src/bin/dhcp4/tests/classify_unittest.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,6 @@ class ClassifyTest : public Dhcpv4SrvTest {
521521
IfaceMgrTestConfig iface_mgr_test_config_;
522522
};
523523

524-
525524
// This test checks that an incoming DISCOVER that does not match any classes
526525
// will get the fixed fields empty.
527526
TEST_F(ClassifyTest, fixedFieldsDiscoverNoClasses) {
@@ -538,7 +537,6 @@ TEST_F(ClassifyTest, fixedFieldsInformNoClasses) {
538537
testFixedFields(CONFIGS[0], DHCPINFORM, OptionPtr(), "0.0.0.0", "", "");
539538
}
540539

541-
542540
// This test checks that an incoming DISCOVER that does match a class that has
543541
// next-server specified will result in a response that has the next-server set.
544542
TEST_F(ClassifyTest, fixedFieldsDiscoverNextServer) {
@@ -561,7 +559,6 @@ TEST_F(ClassifyTest, fixedFieldsInformNextServer) {
561559
testFixedFields(CONFIGS[0], DHCPINFORM, pxe, "1.2.3.4", "", "");
562560
}
563561

564-
565562
// This test checks that an incoming DISCOVER that does match a class that has
566563
// server-hostname specified will result in a response that has the sname field set.
567564
TEST_F(ClassifyTest, fixedFieldsDiscoverHostname) {
@@ -584,7 +581,6 @@ TEST_F(ClassifyTest, fixedFieldsInformHostname) {
584581
testFixedFields(CONFIGS[0], DHCPINFORM, pxe, "0.0.0.0", "deneb", "");
585582
}
586583

587-
588584
// This test checks that an incoming DISCOVER that does match a class that has
589585
// boot-file-name specified will result in a response that has the filename field set.
590586
TEST_F(ClassifyTest, fixedFieldsDiscoverFile1) {
@@ -607,7 +603,6 @@ TEST_F(ClassifyTest, fixedFieldsInformFile1) {
607603
testFixedFields(CONFIGS[0], DHCPDISCOVER, pxe, "0.0.0.0", "", "pxelinux.0");
608604
}
609605

610-
611606
// This test checks that an incoming DISCOVER that does match a different class that has
612607
// boot-file-name specified will result in a response that has the filename field set.
613608
TEST_F(ClassifyTest, fixedFieldsDiscoverFile2) {
@@ -703,7 +698,6 @@ TEST_F(ClassifyTest, fixedFieldsInformNoClasses2) {
703698
testFixedFields(CONFIGS[2], DHCPINFORM, OptionPtr(), "0.0.0.0", "", "");
704699
}
705700

706-
707701
// This test checks that an incoming DISCOVER that does match a class that has
708702
// next-server specified will result in a response that has the next-server set.
709703
TEST_F(ClassifyTest, fixedFieldsDiscoverNextServer2) {
@@ -726,7 +720,6 @@ TEST_F(ClassifyTest, fixedFieldsInformNextServer2) {
726720
testFixedFields(CONFIGS[2], DHCPINFORM, pxe, "1.2.3.4", "", "");
727721
}
728722

729-
730723
// This test checks that an incoming DISCOVER that does match a class that has
731724
// boot-file-name specified will result in a response that has the filename field set.
732725
TEST_F(ClassifyTest, fixedFieldsDiscoverFile21) {
@@ -749,7 +742,6 @@ TEST_F(ClassifyTest, fixedFieldsInformFile21) {
749742
testFixedFields(CONFIGS[2], DHCPDISCOVER, pxe, "0.0.0.0", "", "pxelinux.0");
750743
}
751744

752-
753745
// This test checks that an incoming DISCOVER that does match a different class that has
754746
// boot-file-name specified will result in a response that has the filename field set.
755747
TEST_F(ClassifyTest, fixedFieldsDiscoverFile22) {
@@ -800,7 +792,6 @@ TEST_F(ClassifyTest, fixedFieldsInformNextServer3) {
800792
testFixedFields(CONFIGS[3], DHCPINFORM, pxe, "0.0.0.0", "", "");
801793
}
802794

803-
804795
// Class pxe2 is only-if-required but the subnet requires its evaluation
805796
TEST_F(ClassifyTest, fixedFieldsDiscoverHostname3) {
806797
OptionPtr pxe(new OptionInt<uint16_t>(Option::V4, 93, 0x0007));

src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class CtrlChannelDhcpv4SrvTest : public ::testing::Test {
135135
CommandMgr::instance().setConnectionTimeout(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND);
136136

137137
server_.reset();
138+
reset();
138139
IfaceMgr::instance().setTestMode(false);
139140
IfaceMgr::instance().setDetectCallback(std::bind(&IfaceMgr::checkDetectIfaces,
140141
IfaceMgr::instancePtr().get(), ph::_1));
@@ -806,7 +807,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configSet) {
806807
" \"name\": \"kea\", \n"
807808
" \"severity\": \"FATAL\", \n"
808809
" \"output-options\": [{ \n"
809-
" \"output\": \"/dev/null\" \n"
810+
" \"output\": \"/dev/null\", \n"
811+
" \"maxsize\": 0"
810812
" }] \n"
811813
" }] \n";
812814

@@ -1021,7 +1023,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configTest) {
10211023
" \"name\": \"kea\", \n"
10221024
" \"severity\": \"FATAL\", \n"
10231025
" \"output-options\": [{ \n"
1024-
" \"output\": \"/dev/null\" \n"
1026+
" \"output\": \"/dev/null\", \n"
1027+
" \"maxsize\": 0"
10251028
" }] \n"
10261029
" }] \n";
10271030

0 commit comments

Comments
 (0)