From 771b1e78772f62c078d3ad67dda82f2782a07ff6 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil <33750417+thattil@users.noreply.github.com> Date: Fri, 4 Feb 2022 10:12:57 +0100 Subject: [PATCH] rx_arping for 10g mode (#359) * test for rx_arping * arping ip and interface from client interface * apring thread added to thread ids * clean code for thread for arping * removing the assumption that udpip1 fill be updated along with udpip2 * review, replacing syscall(sys_gettid) with gettid() --- RELEASE.txt | 2 + python/slsdet/detector.py | 13 +- python/src/detector.cpp | 7 ++ slsDetectorSoftware/include/sls/Detector.h | 12 +- slsDetectorSoftware/src/CmdProxy.h | 18 +-- slsDetectorSoftware/src/Detector.cpp | 8 ++ slsDetectorSoftware/src/Module.cpp | 8 ++ slsDetectorSoftware/src/Module.h | 2 + .../tests/test-CmdProxy-rx.cpp | 24 ++++ slsReceiverSoftware/CMakeLists.txt | 1 + slsReceiverSoftware/src/Arping.cpp | 114 ++++++++++++++++++ slsReceiverSoftware/src/Arping.h | 35 ++++++ slsReceiverSoftware/src/ClientInterface.cpp | 32 ++++- slsReceiverSoftware/src/ClientInterface.h | 4 + slsReceiverSoftware/src/Implementation.cpp | 25 ++++ slsReceiverSoftware/src/Implementation.h | 5 + slsReceiverSoftware/src/MultiReceiverApp.cpp | 12 +- slsReceiverSoftware/src/Receiver.cpp | 4 +- slsReceiverSoftware/src/ReceiverApp.cpp | 5 +- slsReceiverSoftware/src/ThreadObject.cpp | 3 +- slsReceiverSoftware/src/ThreadObject.h | 15 ++- slsSupportLib/include/sls/sls_detector_defs.h | 2 +- .../include/sls/sls_detector_funcs.h | 4 + 23 files changed, 316 insertions(+), 39 deletions(-) create mode 100644 slsReceiverSoftware/src/Arping.cpp create mode 100644 slsReceiverSoftware/src/Arping.h diff --git a/RELEASE.txt b/RELEASE.txt index 2b04fe263..1bc71e576 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -28,6 +28,8 @@ This document describes the differences between v6.1.0 and v6.0.0. - changed default vref of adc9257 to 2V for moench (from 1.33V) - moench and ctb - can set the starting frame number of next acquisition - mythen server kernel check incompatible (cet timezone) +- rx_arping +- rx_threadsids max is now 9 (breaking api) - m3 server crash (vthrehsold) - allow vtrim to be interpolated for Eiger settings diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 0a16ab8b0..1efa837e5 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -258,7 +258,7 @@ class Detector(CppDetectorApi): @element def rx_threads(self): """ - Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1]. + Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1, arping]. Note ----- @@ -268,6 +268,17 @@ class Detector(CppDetectorApi): """ return self.getRxThreadIds() + @property + @element + def rx_arping(self): + """Starts a thread in slsReceiver to arping the interface it is listening every minute. Useful in 10G mode. """ + return self.getRxArping() + + @rx_arping.setter + def rx_arping(self, value): + ut.set_using_dict(self.setRxArping, value) + + @property @element def dr(self): diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 7677fbae4..9f1d6937c 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -768,6 +768,13 @@ void init_det(py::module &m) { (Result>(Detector::*)(sls::Positions) const) & Detector::getRxThreadIds, py::arg() = Positions{}) + .def("getRxArping", + (Result(Detector::*)(sls::Positions) const) & + Detector::getRxArping, + py::arg() = Positions{}) + .def("setRxArping", + (void (Detector::*)(bool, sls::Positions)) & Detector::setRxArping, + py::arg(), py::arg() = Positions{}) .def("getFileFormat", (Result(Detector::*)(sls::Positions) const) & Detector::getFileFormat, diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index bc62319e8..1f16b7269 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -878,10 +878,18 @@ class Detector { Result getRxLastClientIP(Positions pos = {}) const; /** Get thread ids from the receiver in order of [parent, tcp, listener 0, - * processor 0, streamer 0, listener 1, processor 1, streamer 1]. If no - * streamer yet or there is no second interface, it gives 0 in its place. */ + * processor 0, streamer 0, listener 1, processor 1, streamer 1, arping]. If + * no streamer yet or there is no second interface, it gives 0 in its place. + */ Result> getRxThreadIds(Positions pos = {}) const; + + Result getRxArping(Positions pos = {}) const; + + /** Starts a thread in slsReceiver to arping the interface it is listening + * every minute. Useful in 10G mode. */ + void setRxArping(bool value, Positions pos = {}); + ///@} /** @name File */ diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 673fd5fd8..ac1afb4ad 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -903,6 +903,7 @@ class CmdProxy { {"rx_lock", &CmdProxy::rx_lock}, {"rx_lastclient", &CmdProxy::rx_lastclient}, {"rx_threads", &CmdProxy::rx_threads}, + {"rx_arping", &CmdProxy::rx_arping}, /* File */ {"fformat", &CmdProxy::fformat}, @@ -1738,13 +1739,16 @@ class CmdProxy { rx_lastclient, getRxLastClientIP, "\n\tClient IP Address that last communicated with the receiver."); - GET_COMMAND( - rx_threads, getRxThreadIds, - "\n\tGet thread ids from the receiver in order of [parent, tcp, " - "listener 0, " - "processor 0, streamer 0, listener 1, processor 1, streamer 1]. If no " - "streamer yet or there is no second interface, it gives 0 in its " - "place."); + GET_COMMAND(rx_threads, getRxThreadIds, + "\n\tGet thread ids from the receiver in order of [parent, " + "tcp, listener 0, processor 0, streamer 0, listener 1, " + "processor 1, streamer 1, arping]. If no streamer yet or there " + "is no second interface, it gives 0 in its place."); + + INTEGER_COMMAND_VEC_ID(rx_arping, getRxArping, setRxArping, StringTo, + "[0, 1]\n\tStarts a thread in slsReceiver to arping " + "the interface it is " + "listening to every minute. Useful in 10G mode."); /* File */ diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index f9335a195..801193e78 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1170,6 +1170,14 @@ Detector::getRxThreadIds(Positions pos) const { return pimpl->Parallel(&Module::getReceiverThreadIds, pos); } +Result Detector::getRxArping(Positions pos) const { + return pimpl->Parallel(&Module::getRxArping, pos); +} + +void Detector::setRxArping(bool value, Positions pos) { + pimpl->Parallel(&Module::setRxArping, pos, value); +} + // File Result Detector::getFileFormat(Positions pos) const { diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 0be33cf3f..ef2c1633c 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -1318,6 +1318,14 @@ std::array Module::getReceiverThreadIds() const { F_GET_RECEIVER_THREAD_IDS); } +bool Module::getRxArping() const { + return sendToReceiver(F_GET_RECEIVER_ARPING); +} + +void Module::setRxArping(bool enable) { + sendToReceiver(F_SET_RECEIVER_ARPING, static_cast(enable), nullptr); +} + // File slsDetectorDefs::fileFormat Module::getFileFormat() const { return sendToReceiver(F_GET_RECEIVER_FILE_FORMAT); diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index ed553378d..22ea7b030 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -283,6 +283,8 @@ class Module : public virtual slsDetectorDefs { void setReceiverLock(bool lock); sls::IpAddr getReceiverLastClientIP() const; std::array getReceiverThreadIds() const; + bool getRxArping() const; + void setRxArping(bool enable); /************************************************** * * diff --git a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp index ca7cecfe7..ca3c94a95 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp @@ -385,6 +385,30 @@ TEST_CASE("rx_threads", "[.cmd][.rx]") { REQUIRE_NOTHROW(proxy.Call("rx_threads", {}, -1, GET, oss)); } +TEST_CASE("rx_arping", "[.cmd][.rx]") { + Detector det; + CmdProxy proxy(&det); + auto prev_val = det.getRxArping(); + { + std::ostringstream oss; + proxy.Call("rx_arping", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_arping 1\n"); + } + { + std::ostringstream oss; + proxy.Call("rx_arping", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_arping 1\n"); + } + { + std::ostringstream oss; + proxy.Call("rx_arping", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_arping 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxArping(prev_val[i], {i}); + } +} + /* File */ TEST_CASE("fformat", "[.cmd]") { diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt index 14efab277..d93a2c027 100755 --- a/slsReceiverSoftware/CMakeLists.txt +++ b/slsReceiverSoftware/CMakeLists.txt @@ -12,6 +12,7 @@ set(SOURCES src/DataProcessor.cpp src/DataStreamer.cpp src/Fifo.cpp + src/Arping.cpp ) set(PUBLICHEADERS diff --git a/slsReceiverSoftware/src/Arping.cpp b/slsReceiverSoftware/src/Arping.cpp new file mode 100644 index 000000000..ca78f11c1 --- /dev/null +++ b/slsReceiverSoftware/src/Arping.cpp @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package + +#include "Arping.h" + +#include +#include + +void Arping::SetInterfacesAndIps(const int index, const std::string &interface, + const std::string &ip) { + + if (interface.empty() || ip.empty()) { + throw sls::RuntimeError("Could not arping. Interface name and ip not " + "set up for interface " + + std::to_string(index)); + } + // create commands to arping + std::ostringstream os; + os << "arping -c 1 -U -I " << interface << " " << ip; + // to read error messages + os << " 2>&1"; + std::string cmd = os.str(); + commands[index] = cmd; +} + +pid_t Arping::GetThreadId() const { return threadId; } + +bool Arping::IsRunning() const { return runningFlag; } + +void Arping::StartThread() { + TestCommands(); + try { + t = std::thread(&Arping::ThreadExecution, this); + } catch (...) { + throw sls::RuntimeError("Could not start arping thread"); + } + runningFlag = true; +} + +void Arping::StopThread() { + runningFlag = false; + t.join(); +} + +void Arping::ThreadExecution() { + threadId = gettid(); + LOG(logINFOBLUE) << "Created [ Arping Thread, Tid: " << threadId << " ]"; + + while (runningFlag) { + std::string error = ExecuteCommands(); + // just print (was already tested at thread start) + if (!error.empty()) { + LOG(logERROR) << error; + } + + // wait for 60s as long as thread not killed + int nsecs = 0; + while (runningFlag && nsecs != 60) { + std::this_thread::sleep_for(std::chrono::seconds(1)); + ++nsecs; + } + } + + LOG(logINFOBLUE) << "Exiting [ Arping Thread, Tid: " << threadId << " ]"; + threadId = 0; +} + +void Arping::TestCommands() { + // atleast one interface must be set up + if (commands[0].empty()) { + throw sls::RuntimeError( + "Could not arping. Interface not set up in apring thread"); + } + // test if arping commands throw an error + std::string error = ExecuteCommands(); + if (!error.empty()) { + throw sls::RuntimeError(error); + } +} + +std::string Arping::ExecuteCommands() { + for (auto cmd : commands) { + + // empty if 2nd interface not enabled + if (cmd.empty()) + continue; + + LOG(logDEBUG) << "Executing Arping Command: " << cmd; + + // execute command + FILE *sysFile = popen(cmd.c_str(), "r"); + if (sysFile == NULL) { + std::ostringstream os; + os << "Could not Arping [" << cmd << " ] : Popen fail"; + return os.str(); + } + + // copy output + char output[MAX_STR_LENGTH] = {0}; + fgets(output, sizeof(output), sysFile); + output[sizeof(output) - 1] = '\0'; + + // check exit status of command + if (pclose(sysFile)) { + std::ostringstream os; + os << "Could not arping[" << cmd << "] : " << output; + return os.str(); + } else { + LOG(logDEBUG) << output; + } + } + + return std::string(); +} \ No newline at end of file diff --git a/slsReceiverSoftware/src/Arping.h b/slsReceiverSoftware/src/Arping.h new file mode 100644 index 000000000..3c84a398b --- /dev/null +++ b/slsReceiverSoftware/src/Arping.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#pragma once +/** + *@short creates/destroys an ARPing thread to arping the interfaces slsReceiver +is listening to. + */ + +#include "receiver_defs.h" +#include "sls/logger.h" + +#include +#include + +class Arping { + + public: + void SetInterfacesAndIps(const int index, const std::string &interface, + const std::string &ip); + pid_t GetThreadId() const; + bool IsRunning() const; + void StartThread(); + void StopThread(); + + private: + void TestCommands(); + std::string ExecuteCommands(); + void ThreadExecution(); + + std::vector commands = + std::vector(MAX_NUMBER_OF_LISTENING_THREADS); + std::atomic runningFlag{false}; + std::thread t; + std::atomic threadId{0}; +}; diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 5dbc4b3a9..600b00d70 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -41,7 +40,7 @@ ClientInterface::ClientInterface(int portNumber) portNumber(portNumber > 0 ? portNumber : DEFAULT_PORTNO + 2), server(portNumber) { functionTable(); - parentThreadId = syscall(SYS_gettid); + parentThreadId = gettid(); tcpThread = sls::make_unique(&ClientInterface::startTCPServer, this); } @@ -76,7 +75,7 @@ void ClientInterface::registerCallBackRawDataModifyReady( } void ClientInterface::startTCPServer() { - tcpThreadId = syscall(SYS_gettid); + tcpThreadId = gettid(); LOG(logINFOBLUE) << "Created [ TCP server Tid: " << tcpThreadId << "]"; LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber << '\n'; @@ -210,7 +209,8 @@ int ClientInterface::functionTable(){ flist[F_SET_RECEIVER_STREAMING_HWM] = &ClientInterface::set_streaming_hwm; flist[F_RECEIVER_SET_ALL_THRESHOLD] = &ClientInterface::set_all_threshold; flist[F_RECEIVER_SET_DATASTREAM] = &ClientInterface::set_detector_datastream; - + flist[F_GET_RECEIVER_ARPING] = &ClientInterface::get_arping; + flist[F_SET_RECEIVER_ARPING] = &ClientInterface::set_arping; for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) { LOG(logDEBUG1) << "function fnum: " << i << " (" << @@ -1398,6 +1398,10 @@ sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) { if (detType == EIGER) { impl()->setEthernetInterface2(eth); } + + // update locally to use for arping + udpips[0] = arg.str(); + // get mac address auto retval = sls::InterfaceNameToMac(eth); if (retval == 0) { @@ -1430,6 +1434,9 @@ sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) { } impl()->setEthernetInterface2(eth); + // update locally to use for arping + udpips[1] = arg.str(); + // get mac address auto retval = sls::InterfaceNameToMac(eth); if (retval == 0) { @@ -1697,3 +1704,20 @@ int ClientInterface::set_detector_datastream(Interface &socket) { impl()->setDetectorDataStream(port, enable); return socket.Send(OK); } + +int ClientInterface::get_arping(Interface &socket) { + auto retval = static_cast(impl()->getArping()); + LOG(logDEBUG1) << "arping thread status:" << retval; + return socket.sendResult(retval); +} + +int ClientInterface::set_arping(Interface &socket) { + auto value = socket.Receive(); + if (value < 0) { + throw RuntimeError("Invalid arping value: " + std::to_string(value)); + } + verifyIdle(socket); + LOG(logDEBUG1) << "Starting/ Killing arping thread:" << value; + impl()->setArping(value, udpips); + return socket.Send(OK); +} diff --git a/slsReceiverSoftware/src/ClientInterface.h b/slsReceiverSoftware/src/ClientInterface.h index 6fd30cb98..6671c4592 100644 --- a/slsReceiverSoftware/src/ClientInterface.h +++ b/slsReceiverSoftware/src/ClientInterface.h @@ -163,6 +163,8 @@ class ClientInterface : private virtual slsDetectorDefs { int set_streaming_hwm(sls::ServerInterface &socket); int set_all_threshold(sls::ServerInterface &socket); int set_detector_datastream(sls::ServerInterface &socket); + int get_arping(sls::ServerInterface &socket); + int set_arping(sls::ServerInterface &socket); Implementation *impl() { if (receiver != nullptr) { @@ -190,4 +192,6 @@ class ClientInterface : private virtual slsDetectorDefs { pid_t parentThreadId{0}; pid_t tcpThreadId{0}; + std::vector udpips = + std::vector(MAX_NUMBER_OF_LISTENING_THREADS); }; diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 92c4cae00..6a7b7d896 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -107,6 +107,7 @@ void Implementation::SetupFifoStructure() { * ************************************************/ void Implementation::setDetectorType(const detectorType d) { + detType = d; switch (detType) { case GOTTHARD: @@ -320,9 +321,33 @@ std::array Implementation::getThreadIds() const { retval[id++] = 0; } } + retval[NUM_RX_THREAD_IDS - 1] = arping.GetThreadId(); return retval; } +bool Implementation::getArping() const { return arping.IsRunning(); } + +pid_t Implementation::getArpingThreadId() const { return arping.GetThreadId(); } + +void Implementation::setArping(const bool i, + const std::vector ips) { + if (i != arping.IsRunning()) { + if (!i) { + arping.StopThread(); + } else { + // setup interface + for (int i = 0; i != numUDPInterfaces; ++i) { + // ignore eiger with 2 interfaces (only udp port) + if (i == 1 && (numUDPInterfaces == 1 || detType == EIGER)) { + break; + } + arping.SetInterfacesAndIps(i, eth[i], ips[i]); + } + arping.StartThread(); + } + } +} + /************************************************** * * * File Parameters * diff --git a/slsReceiverSoftware/src/Implementation.h b/slsReceiverSoftware/src/Implementation.h index 4b80a0012..442f1b4db 100644 --- a/slsReceiverSoftware/src/Implementation.h +++ b/slsReceiverSoftware/src/Implementation.h @@ -1,6 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package #pragma once +#include "Arping.h" #include "receiver_defs.h" #include "sls/container_utils.h" #include "sls/logger.h" @@ -49,6 +50,9 @@ class Implementation : private virtual slsDetectorDefs { void setFramePaddingEnable(const bool i); void setThreadIds(const pid_t parentTid, const pid_t tcpTid); std::array getThreadIds() const; + bool getArping() const; + pid_t getArpingThreadId() const; + void setArping(const bool i, const std::vector ips); /************************************************** * * @@ -379,6 +383,7 @@ class Implementation : private virtual slsDetectorDefs { std::vector> dataProcessor; std::vector> dataStreamer; std::vector> fifo; + Arping arping; std::mutex hdf5Lib; }; diff --git a/slsReceiverSoftware/src/MultiReceiverApp.cpp b/slsReceiverSoftware/src/MultiReceiverApp.cpp index 991555ffc..10a059a14 100644 --- a/slsReceiverSoftware/src/MultiReceiverApp.cpp +++ b/slsReceiverSoftware/src/MultiReceiverApp.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include //wait #include @@ -172,8 +171,7 @@ int main(int argc, char *argv[]) { (!sscanf(argv[3], "%d", &withCallback)))) printHelp(); - cprintf(BLUE, "Parent Process Created [ Tid: %ld ]\n", - (long)syscall(SYS_gettid)); + cprintf(BLUE, "Parent Process Created [ Tid: %ld ]\n", (long)gettid()); cprintf(RESET, "Number of Receivers: %d\n", numReceivers); cprintf(RESET, "Start TCP Port: %d\n", startTCPPort); cprintf(RESET, "Callback Enable: %d\n", withCallback); @@ -215,16 +213,14 @@ int main(int argc, char *argv[]) { /** - if child process */ else if (pid == 0) { - cprintf(BLUE, "Child process %d [ Tid: %ld ]\n", i, - (long)syscall(SYS_gettid)); + cprintf(BLUE, "Child process %d [ Tid: %ld ]\n", i, (long)gettid()); std::unique_ptr receiver = nullptr; try { receiver = sls::make_unique(startTCPPort + i); } catch (...) { LOG(logINFOBLUE) - << "Exiting Child Process [ Tid: " << syscall(SYS_gettid) - << " ]"; + << "Exiting Child Process [ Tid: " << gettid() << " ]"; throw; } /** - register callbacks. remember to set file write enable to 0 @@ -254,7 +250,7 @@ int main(int argc, char *argv[]) { sem_wait(&semaphore); sem_destroy(&semaphore); cprintf(BLUE, "Exiting Child Process [ Tid: %ld ]\n", - (long)syscall(SYS_gettid)); + (long)gettid()); exit(EXIT_SUCCESS); break; } diff --git a/slsReceiverSoftware/src/Receiver.cpp b/slsReceiverSoftware/src/Receiver.cpp index ea140981d..08f01d421 100644 --- a/slsReceiverSoftware/src/Receiver.cpp +++ b/slsReceiverSoftware/src/Receiver.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include namespace sls { @@ -68,8 +67,7 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) { case 'v': std::cout << "SLS Receiver Version: " << GITBRANCH << " (0x" << std::hex << APIRECEIVER << ")" << std::endl; - LOG(logINFOBLUE) - << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]"; + LOG(logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]"; exit(EXIT_SUCCESS); case 'h': diff --git a/slsReceiverSoftware/src/ReceiverApp.cpp b/slsReceiverSoftware/src/ReceiverApp.cpp index 3980b01a1..6fe2884c6 100644 --- a/slsReceiverSoftware/src/ReceiverApp.cpp +++ b/slsReceiverSoftware/src/ReceiverApp.cpp @@ -8,7 +8,6 @@ #include //SIGINT #include -#include #include sem_t semaphore; @@ -19,7 +18,7 @@ int main(int argc, char *argv[]) { sem_init(&semaphore, 1, 0); - LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]"; + LOG(logINFOBLUE) << "Created [ Tid: " << gettid() << " ]"; // Catch signal SIGINT to close files and call destructors properly struct sigaction sa; @@ -50,7 +49,7 @@ int main(int argc, char *argv[]) { } catch (...) { // pass } - LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]"; + LOG(logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]"; LOG(logINFO) << "Exiting Receiver"; return 0; } diff --git a/slsReceiverSoftware/src/ThreadObject.cpp b/slsReceiverSoftware/src/ThreadObject.cpp index 16d17eaf9..8a4516c0c 100644 --- a/slsReceiverSoftware/src/ThreadObject.cpp +++ b/slsReceiverSoftware/src/ThreadObject.cpp @@ -8,7 +8,6 @@ #include "ThreadObject.h" #include "sls/container_utils.h" #include -#include #include ThreadObject::ThreadObject(int threadIndex, std::string threadType) @@ -39,7 +38,7 @@ void ThreadObject::StartRunning() { runningFlag = true; } void ThreadObject::StopRunning() { runningFlag = false; } void ThreadObject::RunningThread() { - threadId = syscall(SYS_gettid); + threadId = gettid(); LOG(logINFOBLUE) << "Created [ " << type << "Thread " << index << ", Tid: " << threadId << "]"; while (!killThread) { diff --git a/slsReceiverSoftware/src/ThreadObject.h b/slsReceiverSoftware/src/ThreadObject.h index d57857548..c708b960b 100644 --- a/slsReceiverSoftware/src/ThreadObject.h +++ b/slsReceiverSoftware/src/ThreadObject.h @@ -21,14 +21,6 @@ class ThreadObject : private virtual slsDetectorDefs { protected: const int index{0}; - private: - std::atomic killThread{false}; - std::atomic runningFlag{false}; - std::thread threadObject; - sem_t semaphore; - const std::string type; - pid_t threadId{0}; - public: ThreadObject(int threadIndex, std::string threadType); virtual ~ThreadObject(); @@ -47,4 +39,11 @@ class ThreadObject : private virtual slsDetectorDefs { * Then it exits the thread on its own if killThread is true */ void RunningThread(); + + std::atomic killThread{false}; + std::atomic runningFlag{false}; + std::thread threadObject; + sem_t semaphore; + const std::string type; + std::atomic threadId{0}; }; diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index e92e6b0f5..06203310f 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -73,7 +73,7 @@ #define DEFAULT_STREAMING_TIMER_IN_MS 500 -#define NUM_RX_THREAD_IDS 8 +#define NUM_RX_THREAD_IDS 9 #ifdef __cplusplus class slsDetectorDefs { diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index a0b3f71cb..ca7a19de2 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -361,6 +361,8 @@ enum detFuncs { F_SET_RECEIVER_STREAMING_HWM, F_RECEIVER_SET_ALL_THRESHOLD, F_RECEIVER_SET_DATASTREAM, + F_GET_RECEIVER_ARPING, + F_SET_RECEIVER_ARPING, NUM_REC_FUNCTIONS }; @@ -720,6 +722,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_RECEIVER_STREAMING_HWM: return "F_SET_RECEIVER_STREAMING_HWM"; case F_RECEIVER_SET_ALL_THRESHOLD: return "F_RECEIVER_SET_ALL_THRESHOLD"; case F_RECEIVER_SET_DATASTREAM: return "F_RECEIVER_SET_DATASTREAM"; + case F_GET_RECEIVER_ARPING: return "F_GET_RECEIVER_ARPING"; + case F_SET_RECEIVER_ARPING: return "F_SET_RECEIVER_ARPING"; case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS"; default: return "Unknown Function";