This commit is contained in:
Erik Frojdh 2020-08-05 10:17:47 +02:00
parent ab05da4d0e
commit 69d9680034

View File

@ -37,7 +37,6 @@ ClientInterface::ClientInterface(int portNumber)
server(portNumber) { server(portNumber) {
functionTable(); functionTable();
parentThreadId = syscall(SYS_gettid); parentThreadId = syscall(SYS_gettid);
// start up tcp thread
tcpThread = tcpThread =
sls::make_unique<std::thread>(&ClientInterface::startTCPServer, this); sls::make_unique<std::thread>(&ClientInterface::startTCPServer, this);
} }
@ -76,7 +75,7 @@ void ClientInterface::startTCPServer() {
LOG(logINFOBLUE) << "Created [ TCP server Tid: " << tcpThreadId << "]"; LOG(logINFOBLUE) << "Created [ TCP server Tid: " << tcpThreadId << "]";
LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber
<< '\n'; << '\n';
// server = sls::make_unique<sls::ServerSocket>(portNumber);
while (!killTcpThread) { while (!killTcpThread) {
LOG(logDEBUG1) << "Start accept loop"; LOG(logDEBUG1) << "Start accept loop";
try { try {
@ -502,9 +501,7 @@ void ClientInterface::setDetectorType(detectorType arg) {
} }
int ClientInterface::set_roi(Interface &socket) { int ClientInterface::set_roi(Interface &socket) {
static_assert(sizeof(ROI) == 2 * sizeof(int), "ROI not packed"); auto arg = socket.Receive<ROI>();
ROI arg;
socket.Receive(arg);
LOG(logDEBUG1) << "Set ROI: [" << arg.xmin << ", " << arg.xmax << "]"; LOG(logDEBUG1) << "Set ROI: [" << arg.xmin << ", " << arg.xmax << "]";
if (myDetectorType != GOTTHARD) if (myDetectorType != GOTTHARD)
@ -1051,23 +1048,11 @@ int ClientInterface::get_streaming_port(Interface &socket) {
} }
int ClientInterface::set_streaming_source_ip(Interface &socket) { int ClientInterface::set_streaming_source_ip(Interface &socket) {
sls::IpAddr arg; auto ip = socket.Receive<sls::IpAddr>();
socket.Receive(arg); if (ip == 0)
if (arg == 0) { throw RuntimeError("Invalid zmq ip " + ip.str());
throw RuntimeError("Invalid zmq ip " + arg.str());
}
verifyIdle(socket); verifyIdle(socket);
LOG(logDEBUG1) << "Setting streaming source ip:" << arg; impl()->setStreamingSourceIP(ip);
impl()->setStreamingSourceIP(arg);
sls::IpAddr retval = impl()->getStreamingSourceIP();
LOG(logDEBUG1) << "streaming IP:" << retval;
if (retval != arg && arg != 0) {
std::ostringstream os;
os << "Could not set streaming ip. Set " << arg << ", but read "
<< retval << '\n';
throw RuntimeError(os.str());
}
return socket.Send(OK); return socket.Send(OK);
} }
@ -1135,9 +1120,8 @@ int ClientInterface::get_additional_json_header(Interface &socket) {
auto buff = oss.str(); auto buff = oss.str();
auto size = static_cast<int>(buff.size()); auto size = static_cast<int>(buff.size());
socket.sendResult(size); socket.sendResult(size);
if (size > 0) { if (size > 0)
socket.Send(&buff[0], buff.size()); socket.Send(buff);
}
return OK; return OK;
} }