diff --git a/CMakeLists.txt b/CMakeLists.txt index ab0c1dac6..575e3c693 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,11 +102,10 @@ endif() if(SLS_USE_SANITIZER) - target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer) - #target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined) - target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined) - # target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread) - # target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) + # target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer) + # target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined) + target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread) + target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) endif() #rapidjson diff --git a/slsReceiverSoftware/include/DataProcessor.h b/slsReceiverSoftware/include/DataProcessor.h index 9c5febfdb..496c9ab5f 100755 --- a/slsReceiverSoftware/include/DataProcessor.h +++ b/slsReceiverSoftware/include/DataProcessor.h @@ -17,6 +17,7 @@ class File; class DataStreamer; #include +#include class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { @@ -310,7 +311,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { static const std::string TypeName; /** Object running status */ - bool runningFlag; + std::atomic runningFlag; /** GeneralData (Detector Data) object */ const GeneralData* generalData; diff --git a/slsReceiverSoftware/include/Listener.h b/slsReceiverSoftware/include/Listener.h index 2ee15c75a..efdb3a1e6 100755 --- a/slsReceiverSoftware/include/Listener.h +++ b/slsReceiverSoftware/include/Listener.h @@ -10,7 +10,7 @@ */ #include - +#include #include "ThreadObject.h" class GeneralData; @@ -39,7 +39,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { * @param depaden pointer to deactivated padding enable * @param sm pointer to silent mode */ - Listener(int ind, detectorType dtype, Fifo* f, runStatus* s, + Listener(int ind, detectorType dtype, Fifo* f, std::atomic* s, uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr, int64_t* us, int64_t* as, uint32_t* fpf, frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm); @@ -151,7 +151,6 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { void SetHardCodedPosition(uint16_t r, uint16_t c); - private: /** @@ -201,7 +200,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { static const std::string TypeName; /** Object running status */ - bool runningFlag; + std::atomic runningFlag; /** GeneralData (Detector Data) object */ GeneralData* generalData; @@ -214,7 +213,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { detectorType myDetectorType; /** Receiver Status */ - runStatus* status; + std::atomic* status; /** UDP Socket - Detector to Receiver */ std::unique_ptr udpSocket; @@ -264,10 +263,10 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { // acquisition start /** Aquisition Started flag */ - bool acquisitionStartedFlag; + std::atomic acquisitionStartedFlag; /** Measurement Started flag */ - bool measurementStartedFlag; + std::atomic measurementStartedFlag; /** Frame Number of First Frame of an entire Acquisition (including all scans) */ uint64_t firstAcquisitionIndex; @@ -278,10 +277,10 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { // for acquisition summary /** Number of complete Packets caught for each real time acquisition (eg. for each scan (start& stop of receiver)) */ - volatile uint64_t numPacketsCaught; + std::atomic numPacketsCaught; /** Last Frame Index caught from udp network */ - uint64_t lastCaughtFrameIndex; + std::atomic lastCaughtFrameIndex; // parameters to acquire image @@ -300,12 +299,11 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { std::unique_ptr listeningPacket; /** if the udp socket is connected */ - bool udpSocketAlive; + std::atomic udpSocketAlive; /** Semaphore to synchonize deleting udp socket */ sem_t semaphore_socket; - // for print progress during acqusition /** number of packets for statistic */ uint32_t numPacketsStatistic; diff --git a/slsReceiverSoftware/include/slsReceiverImplementation.h b/slsReceiverSoftware/include/slsReceiverImplementation.h index aacab85cb..1fb3b7b15 100755 --- a/slsReceiverSoftware/include/slsReceiverImplementation.h +++ b/slsReceiverSoftware/include/slsReceiverImplementation.h @@ -21,6 +21,7 @@ class DataStreamer; class Fifo; class slsDetectorDefs; +#include #include #include #include @@ -910,7 +911,7 @@ class slsReceiverImplementation : private virtual slsDetectorDefs { /** Maximum Number of Listening Threads/ UDP Ports */ const static int MAX_NUMBER_OF_LISTENING_THREADS = 2; /** Receiver Status */ - runStatus status; + std::atomic status; /** Activated/Deactivated */ bool activated; /** Deactivated padding enable */ diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index 4ffccbd32..bd34d246e 100755 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -20,7 +20,7 @@ const std::string Listener::TypeName = "Listener"; -Listener::Listener(int ind, detectorType dtype, Fifo* f, runStatus* s, +Listener::Listener(int ind, detectorType dtype, Fifo* f, std::atomic* s, uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr, int64_t* us, int64_t* as, uint32_t* fpf, frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm) : @@ -476,9 +476,6 @@ uint32_t Listener::ListenToAnImage(char* buf) { } - - - //until last packet isHeaderEmpty to account for gotthard short frame, else never entering this loop) while ( numpackets < pperFrame) { //listen to new packet diff --git a/slsSupportLib/include/genericSocket.h b/slsSupportLib/include/genericSocket.h index 220aa5e8f..1b7e7d00f 100755 --- a/slsSupportLib/include/genericSocket.h +++ b/slsSupportLib/include/genericSocket.h @@ -44,7 +44,6 @@ class sockaddr_in; #include #include "logger.h" - #define DEFAULT_PACKET_SIZE 1286 #define SOCKET_BUFFER_SIZE (100*1024*1024) //100 MB #define DEFAULT_BACKLOG 5