don't attempt to send in UDPSocket with NULL destAddress

This commit is contained in:
Stephen Birarda 2013-10-17 17:01:15 -07:00
parent 14e258c357
commit bd806241fd
2 changed files with 15 additions and 9 deletions

View file

@ -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 {

View file

@ -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()) {