client: stop and control port get fixed

This commit is contained in:
maliakal_d 2019-02-25 09:35:07 +01:00
parent 4c35dd9b5b
commit 43ad8b69b3

View File

@ -851,31 +851,31 @@ std::string slsDetector::checkOnline() {
} }
int slsDetector::setControlPort(int port_number) { int slsDetector::setControlPort(int port_number) {
int fnum = F_SET_PORT; int fnum = F_SET_PORT;
int ret = FAIL; int ret = FAIL;
int retval = -1; int retval = -1;
FILE_LOG(logDEBUG1) << "Setting control port " FILE_LOG(logDEBUG1) << "Setting control port "
<< " to " << port_number; << " to " << port_number;
if (port_number != thisDetector->controlPort) { if (port_number >= 0 && port_number != thisDetector->controlPort) {
if (thisDetector->onlineFlag == ONLINE_FLAG) { if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort); auto client = sls::ClientSocket(false, thisDetector->hostname, thisDetector->controlPort);
ret = client.sendCommandThenRead(fnum, &port_number, sizeof(port_number), &retval, sizeof(retval)); ret = client.sendCommandThenRead(fnum, &port_number, sizeof(port_number), &retval, sizeof(retval));
if (ret == FAIL) { if (ret == FAIL) {
setErrorMask((getErrorMask()) | (COULDNOT_SET_CONTROL_PORT)); setErrorMask((getErrorMask()) | (COULDNOT_SET_CONTROL_PORT));
} else { } else {
thisDetector->controlPort = retval; thisDetector->controlPort = retval;
FILE_LOG(logDEBUG1) << "Control port: " << retval; FILE_LOG(logDEBUG1) << "Control port: " << retval;
} }
} else { if (ret == FORCE_UPDATE) {
thisDetector->controlPort = port_number; ret = updateDetector();
} }
} } else {
if (ret == FORCE_UPDATE) { thisDetector->controlPort = port_number;
ret = updateDetector(); }
} }
return thisDetector->controlPort; return thisDetector->controlPort;
} }
int slsDetector::setStopPort(int port_number) { int slsDetector::setStopPort(int port_number) {
@ -885,7 +885,7 @@ int slsDetector::setStopPort(int port_number) {
FILE_LOG(logDEBUG1) << "Setting stop port " FILE_LOG(logDEBUG1) << "Setting stop port "
<< " to " << port_number; << " to " << port_number;
if (port_number != thisDetector->stopPort) { if (port_number >= 0 && port_number != thisDetector->stopPort) {
if (thisDetector->onlineFlag == ONLINE_FLAG) { if (thisDetector->onlineFlag == ONLINE_FLAG) {
auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort); auto stop = sls::ClientSocket(false, thisDetector->hostname, thisDetector->stopPort);
ret = stop.sendCommandThenRead(fnum, &port_number, sizeof(port_number), &retval, sizeof(retval)); ret = stop.sendCommandThenRead(fnum, &port_number, sizeof(port_number), &retval, sizeof(retval));
@ -895,13 +895,13 @@ int slsDetector::setStopPort(int port_number) {
thisDetector->stopPort = retval; thisDetector->stopPort = retval;
FILE_LOG(logDEBUG1) << "Stop port: " << retval; FILE_LOG(logDEBUG1) << "Stop port: " << retval;
} }
if (ret == FORCE_UPDATE) {
ret = updateDetector();
}
} else { } else {
thisDetector->stopPort = port_number; thisDetector->stopPort = port_number;
} }
} }
if (ret == FORCE_UPDATE) {
ret = updateDetector();
}
return thisDetector->stopPort; return thisDetector->stopPort;
} }