mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
merge fix from 3.0.1 regarding gethostbyname thread safety
This commit is contained in:
commit
23ddb3d4b5
@ -6355,13 +6355,15 @@ int slsDetector::setUDPConnection(){
|
|||||||
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
||||||
//if hostname not ip, convert it to ip
|
//if hostname not ip, convert it to ip
|
||||||
else{
|
else{
|
||||||
struct hostent *he = gethostbyname(thisDetector->receiver_hostname);
|
struct addrinfo *result;
|
||||||
if (he == NULL){
|
if (!dataSocket->ConvertHostnameToInternetAddress(thisDetector->receiver_hostname, &result)) {
|
||||||
cout<<"rx_hostname:"<<thisDetector->receiver_hostname<<endl;
|
// on success
|
||||||
std::cout << "no rx_udpip given and could not convert receiver hostname to ip" << endl;
|
memset(thisDetector->receiverUDPIP, 0, MAX_STR_LENGTH);
|
||||||
return FAIL;
|
// on failure, back to none
|
||||||
}else
|
if (dataSocket->ConvertInternetAddresstoIpString(result, thisDetector->receiverUDPIP, MAX_STR_LENGTH)) {
|
||||||
strcpy(thisDetector->receiverUDPIP,inet_ntoa(*(struct in_addr*)he->h_addr));
|
strcpy(thisDetector->receiverUDPIP, "none");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6435,6 +6437,7 @@ int slsDetector::configureMAC(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//if udpip wasnt initialized in config file
|
//if udpip wasnt initialized in config file
|
||||||
if(!(strcmp(thisDetector->receiverUDPIP,"none"))){
|
if(!(strcmp(thisDetector->receiverUDPIP,"none"))){
|
||||||
//hostname is an ip address
|
//hostname is an ip address
|
||||||
@ -6442,13 +6445,14 @@ int slsDetector::configureMAC(){
|
|||||||
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
||||||
//if hostname not ip, convert it to ip
|
//if hostname not ip, convert it to ip
|
||||||
else{
|
else{
|
||||||
struct hostent *he = gethostbyname(thisDetector->receiver_hostname);
|
struct addrinfo *result;
|
||||||
if (he != NULL)
|
if (!dataSocket->ConvertHostnameToInternetAddress(thisDetector->receiver_hostname, &result)) {
|
||||||
strcpy(thisDetector->receiverUDPIP,inet_ntoa(*(struct in_addr*)he->h_addr));
|
// on success
|
||||||
else{
|
memset(thisDetector->receiverUDPIP, 0, MAX_STR_LENGTH);
|
||||||
std::cout << "configure mac failed. no rx_udpip given and invalid receiver hostname" << endl;
|
// on failure, back to none
|
||||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
if (dataSocket->ConvertInternetAddresstoIpString(result, thisDetector->receiverUDPIP, MAX_STR_LENGTH)) {
|
||||||
return FAIL;
|
strcpy(thisDetector->receiverUDPIP, "none");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user