Browse Source

Merge conflict fix

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

72
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,31 +194,23 @@ void UDPLink::_writeDataGram(const QByteArray data, const UDPCLient* target)
void UDPLink::readBytes() void UDPLink::readBytes()
{ {
if (_socket) { if (_socket) {
QByteArray databuffer; return;
while (_socket->hasPendingDatagrams()) { }
QByteArray datagram;
datagram.resize(_socket->pendingDatagramSize()); QByteArray databuffer;
QHostAddress sender; while (_socket->hasPendingDatagrams())
quint16 senderPort; {
_socket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort); QByteArray datagram;
databuffer.append(datagram); datagram.resize(_socket->pendingDatagramSize());
//-- Wait a bit before sending it over QHostAddress sender;
if(databuffer.size() > 10 * 1024) { quint16 senderPort;
emit bytesReceived(this, databuffer); _socket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);
databuffer.clear(); databuffer.append(datagram);
} //-- Wait a bit before sending it over
_logInputDataRate(datagram.length(), QDateTime::currentMSecsSinceEpoch()); if(databuffer.size() > 10 * 1024) {
// 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); emit bytesReceived(this, databuffer);
databuffer.clear();
} }
<<<<<<< HEAD
_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 // 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
@ -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