Commit 4badf669 authored by Robert Schmidt's avatar Robert Schmidt

Add mutexes to CreateF1Inst(), only save data if provided

parent a2419226
......@@ -49,13 +49,17 @@ f1ap_cudu_inst_t *getCxt(instance_t instanceP)
return f1_inst[instanceP];
}
static pthread_mutex_t f1_inst_mtx = PTHREAD_MUTEX_INITIALIZER;
void createF1inst(instance_t instanceP, f1ap_setup_req_t *req, f1ap_net_config_t *nc)
{
DevAssert(instanceP == 0);
DevAssert(req != NULL);
AssertFatal(f1_inst[0] == NULL, "Double call to F1 DU init\n");
pthread_mutex_lock(&f1_inst_mtx);
AssertFatal(f1_inst[0] == NULL, "Attempted to initialize multiple F1 instances\n");
f1_inst[0] = calloc(1, sizeof(f1ap_cudu_inst_t));
AssertFatal(f1_inst[0] != NULL, "out of memory\n");
if (req)
f1_inst[0]->setupReq = *req;
if (nc)
f1_inst[0]->net_config = *nc;
pthread_mutex_unlock(&f1_inst_mtx);
}
......@@ -52,6 +52,7 @@ static void cu_task_handle_sctp_association_ind(instance_t instance,
sctp_new_association_ind_t *sctp_new_association_ind,
eth_params_t *IPaddrs)
{
createF1inst(instance, NULL, NULL);
// save the assoc id
f1ap_cudu_inst_t *f1ap_cu_data = getCxt(instance);
f1ap_cu_data->assoc_id = sctp_new_association_ind->assoc_id;
......
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