s1ap: run connect in background thread to avoid blocking

master
Pedro Alvarez 2 years ago committed by Andre Puschmann
parent dc8c85f330
commit 5d79e89a3d

@ -330,10 +330,14 @@ private:
bool success = false; bool success = false;
enum class cause_t { timeout, failure } cause; enum class cause_t { timeout, failure } cause;
}; };
struct s1connectresult {
bool success = false;
};
explicit s1_setup_proc_t(s1ap* s1ap_) : s1ap_ptr(s1ap_) {} explicit s1_setup_proc_t(s1ap* s1ap_) : s1ap_ptr(s1ap_) {}
srsran::proc_outcome_t init(); srsran::proc_outcome_t init();
srsran::proc_outcome_t step() { return srsran::proc_outcome_t::yield; } srsran::proc_outcome_t step() { return srsran::proc_outcome_t::yield; }
srsran::proc_outcome_t react(const s1connectresult& event);
srsran::proc_outcome_t react(const s1setupresult& event); srsran::proc_outcome_t react(const s1setupresult& event);
void then(const srsran::proc_state_t& result); void then(const srsran::proc_state_t& result);
const char* name() const { return "MME Connection"; } const char* name() const { return "MME Connection"; }

@ -237,21 +237,38 @@ srsran::proc_outcome_t s1ap::s1_setup_proc_t::start_mme_connection()
return srsran::proc_outcome_t::success; return srsran::proc_outcome_t::success;
} }
if (not s1ap_ptr->connect_mme()) { auto connect_callback = [this]() {
procInfo("Could not connect to MME"); bool connected = s1ap_ptr->connect_mme();
return srsran::proc_outcome_t::error;
} auto notify_result = [this, connected]() {
s1_setup_proc_t::s1connectresult res;
res.success = connected;
s1ap_ptr->s1setup_proc.trigger(res);
};
s1ap_ptr->task_sched.notify_background_task_result(notify_result);
};
srsran::get_background_workers().push_task(connect_callback);
return srsran::proc_outcome_t::yield;
}
srsran::proc_outcome_t s1ap::s1_setup_proc_t::react(const srsenb::s1ap::s1_setup_proc_t::s1connectresult& event)
{
if (event.success) {
procInfo("Connected to MME. Sending S1 setup request.");
s1ap_ptr->s1setup_timeout.run();
if (not s1ap_ptr->setup_s1()) { if (not s1ap_ptr->setup_s1()) {
procError("S1 setup failed. Exiting..."); procError("S1 setup failed. Exiting...");
srsran::console("S1 setup failed\n"); srsran::console("S1 setup failed\n");
s1ap_ptr->running = false; s1ap_ptr->running = false;
return srsran::proc_outcome_t::error; return srsran::proc_outcome_t::error;
} }
procInfo("S1 setup request sent. Waiting for response.");
s1ap_ptr->s1setup_timeout.run();
procInfo("S1SetupRequest sent. Waiting for response...");
return srsran::proc_outcome_t::yield; return srsran::proc_outcome_t::yield;
}
procInfo("Could not connected to MME. Aborting");
return srsran::proc_outcome_t::error;
} }
srsran::proc_outcome_t s1ap::s1_setup_proc_t::react(const srsenb::s1ap::s1_setup_proc_t::s1setupresult& event) srsran::proc_outcome_t s1ap::s1_setup_proc_t::react(const srsenb::s1ap::s1_setup_proc_t::s1setupresult& event)

Loading…
Cancel
Save