From e063d6e06dc14c1dab4246a1de8d66226309392e Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Mon, 8 Jun 2015 12:56:32 +0100 Subject: [PATCH] Notifying mac handler correctly, using proper error codes for threads --- srsapps/common/src/threads.c | 3 ++- srsapps/ue/mac/src/demux.cc | 17 +++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/srsapps/common/src/threads.c b/srsapps/common/src/threads.c index 25b5d42f6..d8922394f 100644 --- a/srsapps/common/src/threads.c +++ b/srsapps/common/src/threads.c @@ -26,6 +26,7 @@ */ +#include #include #include #include @@ -66,7 +67,7 @@ bool threads_new_rt_cpu(pthread_t *thread, void *(*start_routine) (void*), void } int err = pthread_create(thread, &attr, start_routine, arg); if (err) { - if (1 == err) { + if (EPERM == err) { perror("Failed to create thread - permission error. Running with root permissions?"); } perror("pthread_create"); diff --git a/srsapps/ue/mac/src/demux.cc b/srsapps/ue/mac/src/demux.cc index 4a3bf5570..acaf73103 100644 --- a/srsapps/ue/mac/src/demux.cc +++ b/srsapps/ue/mac/src/demux.cc @@ -148,8 +148,14 @@ void demux::process_pdu(sch_pdu *pdu_msg) qbuff *dest_lch = mac_io_h->get(pdu_msg->get()->get_sdu_lcid()); if (dest_lch) { dest_lch->send(pdu_msg->get()->get_sdu_ptr(), pdu_msg->get()->get_sdu_nbytes()*8); - Info("Sent MAC SDU len=%d bytes to lchid=%d\n", + Info("Sent MAC SDU len=%d bytes to lchid=%d\n", pdu_msg->get()->get_sdu_nbytes(), pdu_msg->get()->get_sdu_lcid()); + if (sdu_handler_) { + sdu_handler_->notify_new_sdu(pdu_msg->get()->get_sdu_lcid()); + Info("Notified SDU handler len=%d bytes to lchid=%d\n", + pdu_msg->get()->get_sdu_nbytes(), pdu_msg->get()->get_sdu_lcid()); + } + } else { Error("Getting destination channel LCID=%d\n", pdu_msg->get()->get_sdu_lcid()); } @@ -163,15 +169,6 @@ void demux::process_pdu(sch_pdu *pdu_msg) } } } - /* notify handler if registred */ - if (sdu_handler_) { - pdu_msg->reset(); - while(pdu_msg->next()) { - if (pdu_msg->get()->is_sdu()) { - sdu_handler_->notify_new_sdu(pdu_msg->get()->get_sdu_lcid()); - } - } - } }