Commit 33fd7fe9 authored by aligungr's avatar aligungr

Performance improvements

parent 83f7c740
...@@ -62,10 +62,6 @@ void UeAppTask::onLoop() ...@@ -62,10 +62,6 @@ void UeAppTask::onLoop()
m_base->nasTask->push(std::move(m)); m_base->nasTask->push(std::move(m));
break; break;
} }
case NmUeTunToApp::TUN_ERROR: {
m_logger->err("TUN failure [%s]", w.error.c_str());
break;
}
} }
break; break;
} }
......
...@@ -45,16 +45,12 @@ struct NmUeTunToApp : NtsMessage ...@@ -45,16 +45,12 @@ struct NmUeTunToApp : NtsMessage
enum PR enum PR
{ {
DATA_PDU_DELIVERY, DATA_PDU_DELIVERY,
TUN_ERROR
} present; } present;
// DATA_PDU_DELIVERY // DATA_PDU_DELIVERY
int psi{}; int psi{};
OctetString data{}; OctetString data{};
// TUN_ERROR
std::string error{};
explicit NmUeTunToApp(PR present) : NtsMessage(NtsMessageType::UE_TUN_TO_APP), present(present) explicit NmUeTunToApp(PR present) : NtsMessage(NtsMessageType::UE_TUN_TO_APP), present(present)
{ {
} }
......
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
// //
#include "task.hpp" #include "task.hpp"
#include <cstring> #include <cstring>
#include <unistd.h>
#include <ue/app/task.hpp> #include <ue/app/task.hpp>
#include <ue/nts.hpp> #include <ue/nts.hpp>
#include <unistd.h>
#include <utils/libc_error.hpp> #include <utils/libc_error.hpp>
#include <utils/scoped_thread.hpp> #include <utils/scoped_thread.hpp>
...@@ -35,13 +37,6 @@ static std::string GetErrorMessage(const std::string &cause) ...@@ -35,13 +37,6 @@ static std::string GetErrorMessage(const std::string &cause)
return what; return what;
} }
static std::unique_ptr<nr::ue::NmUeTunToApp> NmError(std::string &&error)
{
auto m = std::make_unique<nr::ue::NmUeTunToApp>(nr::ue::NmUeTunToApp::TUN_ERROR);
m->error = std::move(error);
return m;
}
static void ReceiverThread(ReceiverArgs *args) static void ReceiverThread(ReceiverArgs *args)
{ {
int fd = args->fd; int fd = args->fd;
...@@ -56,10 +51,7 @@ static void ReceiverThread(ReceiverArgs *args) ...@@ -56,10 +51,7 @@ static void ReceiverThread(ReceiverArgs *args)
{ {
ssize_t n = ::read(fd, buffer, RECEIVER_BUFFER_SIZE); ssize_t n = ::read(fd, buffer, RECEIVER_BUFFER_SIZE);
if (n < 0) if (n < 0)
{ throw std::runtime_error(GetErrorMessage("TUN device could not read"));
targetTask->push(NmError(GetErrorMessage("TUN device could not read")));
return; // Abort receiver thread
}
if (n > 0) if (n > 0)
{ {
...@@ -106,9 +98,9 @@ void TunTask::onLoop() ...@@ -106,9 +98,9 @@ void TunTask::onLoop()
auto &w = dynamic_cast<NmAppToTun &>(*msg); auto &w = dynamic_cast<NmAppToTun &>(*msg);
ssize_t res = ::write(m_fd, w.data.data(), w.data.length()); ssize_t res = ::write(m_fd, w.data.data(), w.data.length());
if (res < 0) if (res < 0)
push(NmError(GetErrorMessage("TUN device could not write"))); throw std::runtime_error(GetErrorMessage("TUN device could not write"));
else if (res != w.data.length()) if (res != w.data.length())
push(NmError(GetErrorMessage("TUN device partially written"))); throw std::runtime_error(GetErrorMessage("TUN device partially written"));
break; break;
} }
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment