mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-16 06:47:14 +02:00
ensuring no duplicate rx hostname port combo (#604)
* rx_hostname and port combo to one, or hostname to all, or a vector of hostnames and ports, ignoring none or empty, then verifying no duplicates for the host port combo including from shared memory * extracted function for rx_hostname (#694) * c++14 revert * unique hostname-port combo for port, hostname, rx_tcpport (#696) * verify unique combo for rx_port as well * check unique hostname-port combo also when setting control port, hostname, rx_hostname and rx_tcpport --------- Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com> Co-authored-by: Erik Frojdh <erik.frojdh@psi.ch>
This commit is contained in:
@ -1329,30 +1329,33 @@ std::string Module::getReceiverHostname() const {
|
||||
return std::string(shm()->rxHostname);
|
||||
}
|
||||
|
||||
void Module::setReceiverHostname(const std::string &receiverIP,
|
||||
void Module::setReceiverHostname(const std::string &hostname, const int port,
|
||||
const bool initialChecks) {
|
||||
LOG(logDEBUG1) << "Setting up Receiver hostname with " << receiverIP;
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Setting up Receiver hostname with " << hostname;
|
||||
if (port != 0) {
|
||||
oss << " at port " << port;
|
||||
}
|
||||
LOG(logDEBUG1) << oss.str();
|
||||
}
|
||||
|
||||
if (getRunStatus() == RUNNING) {
|
||||
throw RuntimeError("Cannot set receiver hostname. Acquisition already "
|
||||
"running. Stop it first.");
|
||||
}
|
||||
|
||||
if (receiverIP == "none") {
|
||||
if (hostname == "none") {
|
||||
memset(shm()->rxHostname, 0, MAX_STR_LENGTH);
|
||||
strcpy_safe(shm()->rxHostname, "none");
|
||||
shm()->useReceiverFlag = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// start updating
|
||||
std::string host = receiverIP;
|
||||
auto res = split(host, ':');
|
||||
if (res.size() > 1) {
|
||||
host = res[0];
|
||||
shm()->rxTCPPort = std::stoi(res[1]);
|
||||
strcpy_safe(shm()->rxHostname, hostname.c_str());
|
||||
if (port != 0) {
|
||||
shm()->rxTCPPort = port;
|
||||
}
|
||||
strcpy_safe(shm()->rxHostname, host.c_str());
|
||||
shm()->useReceiverFlag = true;
|
||||
|
||||
try {
|
||||
|
Reference in New Issue
Block a user