F1AP IDs: Add update method to fix concurrency bug
Introduce function cu_update_f1_ue_data() which does remove+add under one lock. This fixes a concurrency bug. For instance, during reestablishment, the CU needs to update the DU UE ID under which the UE is identified in the DU. Previously, the CU would remove, then add the DU UE ID info. At the same time, the PDCP thread might look up the information. This can lead to asserts. Use the above addmod functionality to do the remove-add under a mutex. Modify test to verify this works as expected.
This commit is contained in:
@@ -84,6 +84,18 @@ bool cu_exists_f1_ue_data(uint32_t ue_id)
|
||||
return ret == HASH_TABLE_OK;
|
||||
}
|
||||
|
||||
bool cu_update_f1_ue_data(uint32_t ue_id, const f1_ue_data_t *data)
|
||||
{
|
||||
pthread_mutex_lock(&cu2du_mutex);
|
||||
DevAssert(cu2du_ue_mapping != NULL);
|
||||
uint64_t key = ue_id;
|
||||
hashtable_rc_t retrm = hashtable_remove(cu2du_ue_mapping, key);
|
||||
AssertFatal(retrm == HASH_TABLE_OK, "could not remove UE %d, ret %d\n", ue_id, retrm);
|
||||
bool ret = add_hashtable_data(cu2du_ue_mapping, key, data);
|
||||
pthread_mutex_unlock(&cu2du_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
f1_ue_data_t cu_get_f1_ue_data(uint32_t ue_id)
|
||||
{
|
||||
pthread_mutex_lock(&cu2du_mutex);
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef struct f1_ue_data_t {
|
||||
void cu_init_f1_ue_data(void);
|
||||
bool cu_add_f1_ue_data(uint32_t ue_id, const f1_ue_data_t *data);
|
||||
bool cu_exists_f1_ue_data(uint32_t ue_id);
|
||||
bool cu_update_f1_ue_data(uint32_t ue_id, const f1_ue_data_t *data);
|
||||
f1_ue_data_t cu_get_f1_ue_data(uint32_t ue_id);
|
||||
bool cu_remove_f1_ue_data(uint32_t ue_id);
|
||||
|
||||
|
||||
@@ -49,10 +49,21 @@ void cu_data_test()
|
||||
DevAssert(ret);
|
||||
ret = cu_add_f1_ue_data(ue_id, &data);
|
||||
DevAssert(!ret);
|
||||
data.secondary_ue = 2;
|
||||
ret = cu_update_f1_ue_data(ue_id, &data);
|
||||
bool exists = cu_exists_f1_ue_data(ue_id);
|
||||
DevAssert(exists);
|
||||
f1_ue_data_t rdata = cu_get_f1_ue_data(ue_id);
|
||||
DevAssert(rdata.secondary_ue == data.secondary_ue);
|
||||
|
||||
rdata.secondary_ue = 3;
|
||||
// overwrite once more
|
||||
ret = cu_update_f1_ue_data(ue_id, &rdata);
|
||||
DevAssert(ret);
|
||||
exists = cu_exists_f1_ue_data(ue_id);
|
||||
DevAssert(exists);
|
||||
f1_ue_data_t r2data = cu_get_f1_ue_data(ue_id);
|
||||
DevAssert(r2data.secondary_ue == rdata.secondary_ue);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
Reference in New Issue
Block a user