Browse Source

Merge conflict fix

QGC4.4
DonLakeFlyer 7 years ago
parent
commit
a76dd63b1e
  1. 52
      src/comm/UDPLink.cc

52
src/comm/UDPLink.cc

@ -160,7 +160,6 @@ QString UDPLink::getName() const
void UDPLink::_writeBytes(const QByteArray data) void UDPLink::_writeBytes(const QByteArray data)
{ {
<<<<<<< HEAD
if (!_socket) if (!_socket)
return; return;
// Send to all manually targeted systems // Send to all manually targeted systems
@ -168,37 +167,6 @@ void UDPLink::_writeBytes(const QByteArray data)
// Skip it if it's part of the session clients below // Skip it if it's part of the session clients below
if(!contains_target(_sessionTargets, target->address, target->port)) { if(!contains_target(_sessionTargets, target->address, target->port)) {
_writeDataGram(data, target); _writeDataGram(data, target);
=======
if (_socket) {
QStringList goneHosts;
// Send to all connected systems
QString host;
int port;
if(_udpConfig->firstHost(host, port)) {
do {
QHostAddress currentHost(host);
if(_socket->writeDatagram(data, currentHost, (quint16)port) < 0) {
// This host is gone. Add to list to be removed
// We should keep track of hosts that were manually added (static) and
// hosts that were added because we heard from them (dynamic). Only
// dynamic hosts should be removed and even then, after a few tries, not
// the first failure. In the mean time, we don't remove anything.
if(REMOVE_GONE_HOSTS) {
goneHosts.append(host);
}
} else {
// Only log rate if data actually got sent. Not sure about this as
// "host not there" takes time too regardless of size of data. In fact,
// 1 byte or "UDP frame size" bytes are the same as that's the data
// unit sent by UDP.
_logOutputDataRate(data.size(), QDateTime::currentMSecsSinceEpoch());
}
} while (_udpConfig->nextHost(host, port));
//-- Remove hosts that are no longer there
foreach (const QString& ghost, goneHosts) {
_udpConfig->removeHost(ghost);
}
>>>>>>> b4f4085c6733b934358b00389d734600eab87bf7
} }
} }
// Send to all connected systems // Send to all connected systems
@ -226,8 +194,12 @@ void UDPLink::_writeDataGram(const QByteArray data, const UDPCLient* target)
void UDPLink::readBytes() void UDPLink::readBytes()
{ {
if (_socket) { if (_socket) {
return;
}
QByteArray databuffer; QByteArray databuffer;
while (_socket->hasPendingDatagrams()) { while (_socket->hasPendingDatagrams())
{
QByteArray datagram; QByteArray datagram;
datagram.resize(_socket->pendingDatagramSize()); datagram.resize(_socket->pendingDatagramSize());
QHostAddress sender; QHostAddress sender;
@ -240,18 +212,6 @@ void UDPLink::readBytes()
databuffer.clear(); databuffer.clear();
} }
_logInputDataRate(datagram.length(), QDateTime::currentMSecsSinceEpoch()); _logInputDataRate(datagram.length(), QDateTime::currentMSecsSinceEpoch());
// TODO This doesn't validade the sender. Anything sending UDP packets to this port gets
// added to the list and will start receiving datagrams from here. Even a port scanner
// would trigger this.
// Add host to broadcast list if not yet present, or update its port
_udpConfig->addHost(sender.toString(), (int)senderPort);
}
//-- Send whatever is left
if(databuffer.size()) {
emit bytesReceived(this, databuffer);
}
<<<<<<< HEAD
_logInputDataRate(datagram.length(), QDateTime::currentMSecsSinceEpoch());
// TODO: This doesn't validade the sender. Anything sending UDP packets to this port gets // TODO: This doesn't validade the sender. Anything sending UDP packets to this port gets
// added to the list and will start receiving datagrams from here. Even a port scanner // added to the list and will start receiving datagrams from here. Even a port scanner
// would trigger this. // would trigger this.
@ -269,8 +229,6 @@ void UDPLink::readBytes()
//-- Send whatever is left //-- Send whatever is left
if(databuffer.size()) { if(databuffer.size()) {
emit bytesReceived(this, databuffer); emit bytesReceived(this, databuffer);
=======
>>>>>>> b4f4085c6733b934358b00389d734600eab87bf7
} }
} }

Loading…
Cancel
Save