blob: d9ec2422ddc7b6641e6576f0072b29016a65050a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* Module: lbpathtest.cc
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*/
#include <syslog.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/sysinfo.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/udp.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <errno.h>
#include <string.h>
#include <memory>
#include <time.h>
#include <sys/timeb.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "lbdata.hh"
#include "lbpathtest.hh"
using namespace std;
/**
*
*
**/
LBPathTest::LBPathTest(bool debug) :
_debug(debug)
{
}
/**
*
*
**/
LBPathTest::~LBPathTest()
{
}
/**
*
*
**/
void
LBPathTest::start(LBData &lb_data)
{
//iterate through the tests until success per interface or complete
if (_debug) {
cout << "LBPathTest::start(): init" << endl;
}
set<LBHealth*> coll;
//iterate over the health interfaces
LBData::InterfaceHealthIter iter = lb_data._iface_health_coll.begin();
while (iter != lb_data._iface_health_coll.end()) {
iter->second.start_new_test_cycle();
coll.insert(&(iter->second));
++iter;
}
while (!coll.empty()) {
if (_debug) {
cout << "LBPathTest::start(): sending " << coll.size() << " tests" << endl;
}
//send all interface tests together
set<LBHealth*>::iterator i = coll.begin();
while (i != coll.end()) {
(*i)->send_test();
++i;
}
if (_debug) {
cout << "LBPathTest::start(): waiting on recv" << endl;
}
//wait on responses
i = coll.begin();
while (i != coll.end()) {
if ((*i)->recv_test()) {
coll.erase(i++);
}
else {
++i;
}
}
}
}
|