commit 37cd5dc23a96a58cc7524ba55b49594cc1a79fc8
Author: Svenja <skenneweg@techfak.uni-bielefeld.de>
Date:   Thu Jul 16 14:32:32 2020 +0200

    Several fixes, todos:
    Children and siblings of thread are now terminated in nodes main function.
    Finished Subscribe and Unsubscribe functions of the subscriber function.
    Added functions in the core

diff --git a/src/urt_subscriber.c b/src/urt_subscriber.c
index ea9883d..79f3a31 100644
--- a/src/urt_subscriber.c
+++ b/src/urt_subscriber.c
@@ -87,7 +87,7 @@ urt_status_t urtNrtSubscriberSubscribe (urt_nrtsubscriber_t* subscriber, urt_top
       return URT_STATUS_SUBSCRIBE_TOPICSET;
 
   subscriber->base.topic = topic;
-  //TODO: Lock topic
+  urtMutexLock(topic->lock);
 
   if (messages)
   {
@@ -109,7 +109,7 @@ urt_status_t urtNrtSubscriberSubscribe (urt_nrtsubscriber_t* subscriber, urt_top
     topic->numHrtSubscribers--;
 #endif /* URT_CFG_PUBSUB_PROFILING */
 
-  //TODO: Unlock topic
+  urtMutexUnlock(topic->lock);
   return URT_STATUS_OK;
 }
 
@@ -160,12 +160,12 @@ urt_status_t urtNrtSubscriberUnsubscribe (urt_nrtsubscriber_t* subscriber)
   if (subscriber->base.topic)
   {
 # if(URT_CFG_PUBSUB_PROFILING == true)
-      //TODO: LOCK TOPIC
+      urtMutexLock(topic->lock);
       subscriber->base.topic->numSubscribers--;
 # endif /* URT_CFG_PUBSUB_PROFILING */
     urtEventUnregister(subscriber->base.topic->evtSource, subscriber->base.evtListener);
 # if(URT_CFG_PUBSUB_PROFILING == true)
-      //TODO: Unlock TOPIC
+      urtMutexUnlock(topic->lock);
       subscriber->base.topic = NULL;
       subscriber->base.lastMessage = NULL;
       subscriber->base.lastMessageTime = 0;
@@ -238,7 +238,7 @@ urt_status_t urtSrtSubscriberSubscribe(urt_srtsubscriber_t* subscriber, urt_topi
   subscriber->maxLatency = URT_DELAY_IMMEDIATE;
 # endif  /* URT_CFG_PUBSUB_PROFILING */
 
-  //TODO: Lock topic
+  urtMutexLock(topic->lock);
   if (messages)
   {
     urt_message_t* lastMessageContribute = messages;
@@ -259,7 +259,7 @@ urt_status_t urtSrtSubscriberSubscribe(urt_srtsubscriber_t* subscriber, urt_topi
     topic->numHrtSubscribers--;
 # endif /* URT_CFG_PUBSUB_PROFILING */
 
-  //TODO: Unlock topic
+  urtMutexUnlock(topic->lock);
   return URT_STATUS_OK;
 }
 
@@ -323,12 +323,12 @@ urt_status_t urtSrtSubscriberUnsubscribe(urt_srtsubscriber_t* subscriber)
   if (subscriber->base.topic)
   {
 # if (URT_CFG_PUBSUB_PROFILING == true)
-    //TODO: lock topic
+    urtMutexLock(topic->lock);
     subscriber->base.topic->numSubscribers--;
 # endif /* URT_CFG_PUBSUB_PROFILING */
     urtEventUnregister(subscriber->base.topic->evtSource, subscriber->base.evtListener);
 # if (URT_CFG_PUBSUB_PROFILING == true)
-      //TODO: unlock topic
+      urtMutexUnlock(topic->lock);
 # endif /* URT_CFG_PUBSUB_PROFILING */
     subscriber->base.topic = NULL;
     subscriber->base.lastMessage = NULL;
@@ -418,7 +418,7 @@ urt_status_t urtFrtSubscriberSubscribe(urt_frtsubscriber_t* subscriber, urt_topi
   subscriber->maxLatency = URT_DELAY_IMMEDIATE;
 # endif /* URT_CFG_PUBSUB_QOS_JITTERCHECKS || URT_CFG_PUBSUB_PROFILING */
 
-  //TODO: Lock topic
+  urtMutexLock(topic->lock);
   if (messages)
   {
     urt_message_t* lastMessageContribute = messages;
@@ -439,7 +439,7 @@ urt_status_t urtFrtSubscriberSubscribe(urt_frtsubscriber_t* subscriber, urt_topi
   topic->numHrtSubscribers--;
 # endif /* URT_CFG_PUBSUB_PROFILING */
 
-  //TODO: Unlock topic
+  urtMutexUnlock(topic->lock);
   return URT_STATUS_OK;
 }
 
@@ -483,9 +483,17 @@ urt_status_t urtFrtSubscriberFetchLatestMessage(urt_frtsubscriber_t* subscriber,
  */
 bool urtFrtSubscriberCalculateValidity(urt_frtsubscriber_t* subscriber, urt_delay_t latency)
 {
-# if (URT_CFG_PUBSUB_QOS_DEADLINECHECKS == true && URT_CFG_PUBSUB_QOS_JITTERCHECKS == true)
-  if (latency < subscriber->deadlineOffset && latency < subscriber->maxJitter)
+#if (URT_CFG_PUBSUB_QOS_JITTERCHECKS == true || URT_CFG_PUBSUB_PROFILING == true)
+  if (latency > subscriber->minLatency && latency < subscriber->maxLatency)
     return true;
+#endif /* URT_CFG_PUBSUB_QOS_JITTERCHECKS || URT_CFG_PUBSUB_PROFILING */
+
+# if (URT_CFG_PUBSUB_QOS_JITTERCHECKS == true)
+  if (latency < subscriber->minLatency && subscriber->maxLatency-subscriber->maxJitter < latency)
+      return true;
+
+  if (latency > subscriber->maxLatency && subscriber->minLatency+subscriber->maxJitter > latency)
+      return true;
 # endif /* URT_CFG_PUBSUB_QOS_DEADLINECHECKS && URT_CFG_PUBSUB_QOS_JITTERCHECKS */
 
   return false;
@@ -505,7 +513,7 @@ urt_status_t urtFrtSubscriberUnsubscribe(urt_frtsubscriber_t* subscriber)
 
   if (subscriber->base.topic)
   {
-    //TODO: lock topic
+    urtMutexLock(topic->lock);
     urtEventUnregister(subscriber->base.topic->evtSource, subscriber->base.evtListener);
     //TODO: decrement topic's HRT counter
 # if (URT_CFG_PUBSUB_PROFILING == true)
@@ -514,7 +522,7 @@ urt_status_t urtFrtSubscriberUnsubscribe(urt_frtsubscriber_t* subscriber)
 //Hier weiter
 
 # if (URT_CFG_PUBSUB_PROFILING == true)
-    //TODO: unlock topic
+    urtMutexUnlock(topic->lock);
 # endif /* URT_CFG_PUBSUB_PROFILING */
     subscriber->base.topic = NULL;
     subscriber->base.lastMessage = NULL;
@@ -616,7 +624,7 @@ urt_status_t urtHrtSubscriberSubscribe(urt_hrtsubscriber_t* subscriber, urt_topi
   subscriber->expectedRate = rate;
 # endif /* URT_CFG_PUBSUB_QOS_RATECHECKS */
 
-  //TODO: Lock topic
+  urtMutexLock(topic->lock);
   if (messages)
   {
     urt_message_t* lastMessageContribute = messages;
@@ -642,7 +650,7 @@ urt_status_t urtHrtSubscriberSubscribe(urt_hrtsubscriber_t* subscriber, urt_topi
   topic->numSubscribers--;
 # endif /* URT_CFG_PUBSUB_PROFILING */
 
-  //TODO: Unlock topic
+  urtMutexUnlock(topic->lock);
   return URT_STATUS_OK;
 }
 
@@ -692,7 +700,7 @@ urt_status_t urtHrtSubscriberUnsubscribe(urt_hrtsubscriber_t* subscriber)
 
   if (subscriber->base.topic)
   {
-    //TODO: lock topic
+    urtMutexLock(topic->lock);
     urtEventUnregister(subscriber->base.topic->evtSource, subscriber->base.evtListener);
     subscriber->base.topic->numHrtSubscribers--;
 # if (URT_CFG_PUBSUB_PROFILING == true)
@@ -704,21 +712,25 @@ urt_status_t urtHrtSubscriberUnsubscribe(urt_hrtsubscriber_t* subscriber)
 # endif /* URT_CFG_PUBSUB_QOS_RATECHECKS */
 
     urt_message_t* messageTemp = subscriber->base.lastMessage;
+    bool hrtZero = false;
     while (messageTemp->next->originTime < messageTemp->originTime)
     {
         messageTemp = messageTemp->next;
         messageTemp->numHrtConsumersLeft--;
+        if (messageTemp->numHrtConsumersLeft == 0)
+        {
+            hrtZero = true;
+        }
 # if(URT_CFG_PUBSUB_PROFILING == true)
         messageTemp->numConsumersLeft--;
 # endif /* URT_CFG_PUBSUB_PROFILING */
     }
-    bool temp = false;
-    if (temp /*TODO: HRT counter of any message became 0?*/)
+    if (hrtZero)
     {
-      //TODO: signal topics condition variable
+      urtCondvarSignal(subscriber->base.topic->hrtReleased);
     }
 
-    //TODO: unlock topic
+    urtMutexUnlock(topic->lock);
     subscriber->base.topic = NULL;
     subscriber->base.lastMessage = NULL;
     subscriber->base.lastMessageTime = 0;
