mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 15:13:41 +02:00
don't attempt to send in UDPSocket with NULL destAddress
This commit is contained in:
parent
14e258c357
commit
bd806241fd
2 changed files with 15 additions and 9 deletions
|
@ -265,16 +265,22 @@ bool UDPSocket::receive(sockaddr* recvAddress, void* receivedData, ssize_t* rece
|
|||
}
|
||||
|
||||
int UDPSocket::send(sockaddr* destAddress, const void* data, size_t byteLength) const {
|
||||
// send data via UDP
|
||||
int sent_bytes = sendto(handle, (const char*)data, byteLength,
|
||||
0, (sockaddr *) destAddress, sizeof(sockaddr_in));
|
||||
|
||||
if (sent_bytes != byteLength) {
|
||||
qDebug("Failed to send packet: %s\n", strerror(errno));
|
||||
return false;
|
||||
if (destAddress) {
|
||||
// send data via UDP
|
||||
int sent_bytes = sendto(handle, (const char*)data, byteLength,
|
||||
0, (sockaddr *) destAddress, sizeof(sockaddr_in));
|
||||
|
||||
if (sent_bytes != byteLength) {
|
||||
qDebug("Failed to send packet: %s\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
return sent_bytes;
|
||||
} else {
|
||||
qDebug("UDPSocket send called with NULL destination address - Likely a node with no active socket.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sent_bytes;
|
||||
}
|
||||
|
||||
int UDPSocket::send(const char* destAddress, int destPort, const void* data, size_t byteLength) const {
|
||||
|
|
|
@ -454,7 +454,7 @@ void VoxelServer::run() {
|
|||
Node* node = nodeList->nodeWithUUID(nodeUUID);
|
||||
|
||||
if (node) {
|
||||
NodeList::getInstance()->updateNodeWithData(node, &senderAddress, packetData, packetLength);
|
||||
nodeList->updateNodeWithData(node, &senderAddress, packetData, packetLength);
|
||||
|
||||
VoxelNodeData* nodeData = (VoxelNodeData*) node->getLinkedData();
|
||||
if (nodeData && !nodeData->isVoxelSendThreadInitalized()) {
|
||||
|
|
Loading…
Reference in a new issue