From 6da41d24fc7753600551b72eb683d69987f43dc2 Mon Sep 17 00:00:00 2001
From: thomasl <thomasl@eurecom.fr>
Date: Wed, 4 Mar 2015 18:02:47 +0000
Subject: [PATCH] some warnings in gtpv1u and one bug in itti: task killer was
 sending signal USR1 to wrong threads

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6670 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 common/utils/itti/intertask_interface.c         | 12 +++++++-----
 openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c     |  2 +-
 openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1uMsg.c  |  4 ++--
 openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1uTrxn.c | 10 +++++-----
 4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c
index 2fc036bdf5..5b15f6e4f8 100644
--- a/common/utils/itti/intertask_interface.c
+++ b/common/utils/itti/intertask_interface.c
@@ -166,7 +166,8 @@ typedef struct itti_desc_s {
     task_id_t task_max;
     MessagesIds messages_id_max;
 
-    pthread_t thread_handling_signals;
+    boolean_t thread_handling_signals;
+    pthread_t thread_ref;
 
     const task_info_t *tasks_info;
     const message_info_t *messages_info;
@@ -791,8 +792,8 @@ void itti_terminate_tasks(task_id_t task_id) {
     // Sends Terminate signals to all tasks.
     itti_send_terminate_message (task_id);
 
-    if (itti_desc.thread_handling_signals >= 0) {
-        pthread_kill (itti_desc.thread_handling_signals, SIGUSR1);
+    if (itti_desc.thread_handling_signals) {
+        pthread_kill (itti_desc.thread_ref, SIGUSR1);
     }
 
     pthread_exit (NULL);
@@ -856,7 +857,7 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i
     itti_desc.task_max = task_max;
     itti_desc.thread_max = thread_max;
     itti_desc.messages_id_max = messages_id_max;
-    itti_desc.thread_handling_signals = -1;
+    itti_desc.thread_handling_signals = FALSE;
     itti_desc.tasks_info = tasks_info;
     itti_desc.messages_info = messages_info;
 
@@ -975,7 +976,8 @@ void itti_wait_tasks_end(void) {
     int result;
     int retries = 10;
 
-    itti_desc.thread_handling_signals = pthread_self ();
+    itti_desc.thread_handling_signals = TRUE;
+    itti_desc.thread_ref=pthread_self ();
 
     /* Handle signals here */
     while (end == 0) {
diff --git a/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c b/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c
index 67e4e3bd34..0ee4e0a844 100644
--- a/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c
+++ b/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c
@@ -362,7 +362,7 @@ NwGtpv1uCreateTunnelEndPoint( NW_IN  NwGtpv1uStackT *thiz,
                    "Tunnel already exists", teid);
             rc = nwGtpTunnelEndPointDestroy(thiz, pTunnelEndPoint);
             NW_ASSERT(rc == NW_GTPV1U_OK);
-            *phStackSession = (NwGtpv1uStackSessionHandleT) 0;
+            *phStackSession = (NwGtpv1uStackSessionHandleT) NULL;
             NW_ASSERT(0);
             rc = NW_GTPV1U_FAILURE;
         } else {
diff --git a/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1uMsg.c b/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1uMsg.c
index bfc48bd6ea..021042d24e 100644
--- a/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1uMsg.c
+++ b/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1uMsg.c
@@ -495,8 +495,8 @@ nwGtpv1uMsgHexDump(NwGtpv1uMsgHandleT hMsg, FILE *fp)
     for(n=1; n<=size; n++) {
         if (n%16 == 1) {
             /* store address for this line */
-            snprintf(addrstr, sizeof(addrstr), "%.4x",
-                     ((unsigned int)p-(unsigned int)data) );
+            snprintf(addrstr, sizeof(addrstr), "%.4lx",
+                     (p-data) );
         }
 
         c = *p;
diff --git a/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1uTrxn.c b/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1uTrxn.c
index d4116b6217..0f90acd715 100644
--- a/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1uTrxn.c
+++ b/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1uTrxn.c
@@ -92,8 +92,8 @@ nwGtpv1uTrxnPeerRspTimeout(void *arg)
 
     NW_ASSERT(pStack);
 
-    NW_LOG(pStack, NW_LOG_LEVEL_WARN, "T3 timer expired for transaction 0x%x",
-           (unsigned int)thiz);
+    NW_LOG(pStack, NW_LOG_LEVEL_WARN, "T3 timer expired for transaction 0x%p",
+           thiz);
 
     rc = nwGtpv1uTrxnSendMsgRetransmission(thiz);
 
@@ -213,7 +213,7 @@ nwGtpv1uTrxnNew( NW_IN  NwGtpv1uStackT *thiz,
         rc = NW_GTPV1U_FAILURE;
     }
 
-    NW_LOG(thiz, NW_LOG_LEVEL_DEBG, "Created transaction 0x%X", (unsigned int)pTrxn);
+    NW_LOG(thiz, NW_LOG_LEVEL_DEBG, "Created transaction 0x%p", pTrxn);
 
     *ppTrxn = pTrxn;
 
@@ -254,7 +254,7 @@ nwGtpv1uTrxnWithSeqNew( NW_IN  NwGtpv1uStackT *thiz,
         rc = NW_GTPV1U_FAILURE;
     }
 
-    NW_LOG(thiz, NW_LOG_LEVEL_DEBG, "Created transaction 0x%X", (unsigned int)pTrxn);
+    NW_LOG(thiz, NW_LOG_LEVEL_DEBG, "Created transaction 0x%p", pTrxn);
 
     *ppTrxn = pTrxn;
 
@@ -290,7 +290,7 @@ nwGtpv1uTrxnDelete( NW_INOUT NwGtpv1uTrxnT **pthiz)
     thiz->next = gpGtpv1uTrxnPool;
     gpGtpv1uTrxnPool = thiz;
 
-    NW_LOG(pStack, NW_LOG_LEVEL_DEBG, "Purged transaction 0x%X", (unsigned int)thiz);
+    NW_LOG(pStack, NW_LOG_LEVEL_DEBG, "Purged transaction 0x%p", thiz);
 
     *pthiz = NULL;
     return rc;
-- 
GitLab