1
0
Fork 0

Reflector clean ups and fix memory leaks.

ycs232-kbc
Jonathan Naylor 8 years ago
parent 6782b4bf0d
commit 06580ba87a

@ -191,8 +191,8 @@ void CYSFReflector::run()
unsigned int len = network.readData(buffer, 200U, address, port);
if (len > 0U) {
if (::memcmp(buffer, "YSFP", 4U) == 0) {
CYSFRepeater* rpt = findRepeater(address, port);
if (::memcmp(buffer, "YSFP", 4U) == 0) {
if (rpt == NULL) {
rpt = new CYSFRepeater;
rpt->m_callsign = std::string((char*)(buffer + 4U), 10U);
@ -204,18 +204,18 @@ void CYSFReflector::run()
}
rpt->m_timer.start();
network.writePoll(address, port);
} else if (::memcmp(buffer + 0U, "YSFU", 4U) == 0) {
CYSFRepeater* rpt = findRepeater(address, port);
if (rpt != NULL) {
} else if (::memcmp(buffer + 0U, "YSFU", 4U) == 0 && rpt != NULL) {
LogMessage("Removing %s (unlinked)", rpt->m_callsign.c_str());
std::vector<CYSFRepeater*>::iterator it = std::find(m_repeaters.begin(), m_repeaters.end(), rpt);
if (it != m_repeaters.end())
for (std::vector<CYSFRepeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
CYSFRepeater* itRpt = *it;
if (itRpt->m_address.s_addr == rpt->m_address.s_addr && itRpt->m_port == rpt->m_port) {
m_repeaters.erase(it);
network.setCount(m_repeaters.size());
delete itRpt;
break;
}
} else if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) {
CYSFRepeater* rpt = findRepeater(address, port);
if (rpt != NULL) {
}
network.setCount(m_repeaters.size());
} else if (::memcmp(buffer + 0U, "YSFD", 4U) == 0 && rpt != NULL) {
if (!watchdogTimer.isRunning()) {
::memcpy(tag, buffer + 4U, YSF_CALLSIGN_LENGTH);
@ -262,7 +262,6 @@ void CYSFReflector::run()
}
}
}
}
unsigned int ms = stopWatch.elapsed();
stopWatch.start();
@ -279,9 +278,11 @@ void CYSFReflector::run()
(*it)->m_timer.clock(ms);
for (std::vector<CYSFRepeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
if ((*it)->m_timer.hasExpired()) {
LogMessage("Removing %s (polls lost)", (*it)->m_callsign.c_str());
CYSFRepeater* itRpt = *it;
if (itRpt->m_timer.hasExpired()) {
LogMessage("Removing %s (polls lost)", itRpt->m_callsign.c_str());
m_repeaters.erase(it);
delete itRpt;
network.setCount(m_repeaters.size());
break;
}

Loading…
Cancel
Save