summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorslioch <slioch@eng-140.vyatta.com>2009-07-27 17:51:34 -0700
committerslioch <slioch@eng-140.vyatta.com>2009-07-27 17:51:34 -0700
commitfe6f0901ab0970bcc937328e6093f5b0f118230d (patch)
tree7f65d496da6a496ef5383075f164e7d71f7a760d
parentb80e518d20d05646404a28c2a5cbfc86d0221600 (diff)
downloadvyatta-wanloadbalance-fe6f0901ab0970bcc937328e6093f5b0f118230d.tar.gz
vyatta-wanloadbalance-fe6f0901ab0970bcc937328e6093f5b0f118230d.zip
fix bug in failed test completion.
-rw-r--r--src/lbdata.cc22
-rw-r--r--src/lbdata.hh7
-rw-r--r--src/lbpathtest.cc2
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 {