From fe6f0901ab0970bcc937328e6093f5b0f118230d Mon Sep 17 00:00:00 2001 From: slioch Date: Mon, 27 Jul 2009 17:51:34 -0700 Subject: fix bug in failed test completion. --- src/lbdata.cc | 22 ++++++++++++++++------ src/lbdata.hh | 7 +++++-- src/lbpathtest.cc | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/lbdata.cc b/src/lbdata.cc index 9aa155e..dffd422 100644 --- a/src/lbdata.cc +++ b/src/lbdata.cc @@ -70,6 +70,7 @@ LBHealth::start_new_test_cycle() { _test_iter = _test_coll.begin(); _test_success = false; + _new_test = true; } /** @@ -82,12 +83,15 @@ LBHealth::send_test() if (_test_success == true || _test_iter == _test_coll.end()) { return; //means we are done } - _test_iter->second->init(); - _test_iter->second->send(*this); - - struct sysinfo si; - sysinfo(&si); - _time_start = si.uptime; + if (_new_test == true) { + _test_iter->second->init(); + _test_iter->second->send(*this); + + struct sysinfo si; + sysinfo(&si); + _time_start = si.uptime; + _new_test = false; + } } /** @@ -102,6 +106,11 @@ LBHealth::recv_test() return 0; //means stop iteration } + if (_test_iter == _test_coll.end()) { + put(-1); + return 0; //means stop iteration + } + int rtt = _test_iter->second->recv(*this); if (rtt > -1) { _test_success = true; @@ -114,6 +123,7 @@ LBHealth::recv_test() unsigned long cur_time = si.uptime; if (cur_time > _time_start + _timeout) { //move to next test + _new_test = true; ++_test_iter; } diff --git a/src/lbdata.hh b/src/lbdata.hh index 2e9cf63..6673604 100644 --- a/src/lbdata.hh +++ b/src/lbdata.hh @@ -148,7 +148,8 @@ public: _last_time_state_changed(0), _interface_index(0), _timeout(5), - _time_start(0) + _time_start(0), + _new_test(false) {} LBHealth(int interface_index, string &interface) : @@ -161,7 +162,8 @@ public: _interface(interface), _interface_index(interface_index), _timeout(5), - _time_start(0) + _time_start(0), + _new_test(false) {} void put(int rtt); @@ -207,6 +209,7 @@ private: //variables bool _test_success; unsigned long _timeout; unsigned long _time_start; + bool _new_test; }; /** diff --git a/src/lbpathtest.cc b/src/lbpathtest.cc index d865639..a886a37 100644 --- a/src/lbpathtest.cc +++ b/src/lbpathtest.cc @@ -88,7 +88,7 @@ LBPathTest::start(LBData &lb_data) //wait on responses i = coll.begin(); while (i != coll.end()) { - if ((*i)->recv_test() != -1) { + if ((*i)->recv_test() > -1) { coll.erase(i++); } else { -- cgit v1.2.3