Fix deadlock issue in rach_detect

This commit is contained in:
Ismael Gomez 2018-07-06 15:31:18 +02:00
parent a2615628aa
commit f394dc7aa6
3 changed files with 12 additions and 12 deletions

View File

@ -464,10 +464,6 @@ int mac::rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv)
{ {
log_h->step(tti); log_h->step(tti);
int ret = -1;
pthread_rwlock_rdlock(&rwlock);
// Find empty slot for pending rars // Find empty slot for pending rars
uint32_t ra_id=0; uint32_t ra_id=0;
while(pending_rars[ra_id].temp_crnti && ra_id<MAX_PENDING_RARS-1) { while(pending_rars[ra_id].temp_crnti && ra_id<MAX_PENDING_RARS-1) {
@ -475,9 +471,11 @@ int mac::rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv)
} }
if (ra_id == MAX_PENDING_RARS) { if (ra_id == MAX_PENDING_RARS) {
Error("Maximum number of pending RARs exceeded (%d)\n", MAX_PENDING_RARS); Error("Maximum number of pending RARs exceeded (%d)\n", MAX_PENDING_RARS);
goto unlock; return -1;
} }
pthread_rwlock_rdlock(&rwlock);
// Create new UE // Create new UE
ue_db[last_rnti] = new ue; ue_db[last_rnti] = new ue;
ue_db[last_rnti]->config(last_rnti, cell.nof_prb, &scheduler, rrc_h, rlc_h, log_h); ue_db[last_rnti]->config(last_rnti, cell.nof_prb, &scheduler, rrc_h, rlc_h, log_h);
@ -486,6 +484,9 @@ int mac::rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv)
if (pcap) { if (pcap) {
ue_db[last_rnti]->start_pcap(pcap); ue_db[last_rnti]->start_pcap(pcap);
} }
pthread_rwlock_unlock(&rwlock);
// Save RA info // Save RA info
pending_rars[ra_id].preamble_idx = preamble_idx; pending_rars[ra_id].preamble_idx = preamble_idx;
pending_rars[ra_id].ta_cmd = 2*time_adv; pending_rars[ra_id].ta_cmd = 2*time_adv;
@ -499,7 +500,7 @@ int mac::rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv)
// Release pending RAR // Release pending RAR
bzero(&pending_rars[ra_id], sizeof(pending_rar_t)); bzero(&pending_rars[ra_id], sizeof(pending_rar_t));
Error("Registering new user rnti=0x%x to SCHED\n", last_rnti); Error("Registering new user rnti=0x%x to SCHED\n", last_rnti);
goto unlock; return -1;
} }
// Register new user in RRC // Register new user in RRC
@ -517,11 +518,7 @@ int mac::rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv)
if (last_rnti >= 60000) { if (last_rnti >= 60000) {
last_rnti = 70; last_rnti = 70;
} }
ret = 0; return 0;
unlock:
pthread_rwlock_unlock(&rwlock);
return ret;
} }
int mac::get_dl_sched(uint32_t tti, dl_sched_t *dl_sched_res) int mac::get_dl_sched(uint32_t tti, dl_sched_t *dl_sched_res)

View File

@ -975,6 +975,10 @@ void sched::generate_cce_location(srslte_regs_t *regs_, sched_ue::sched_dci_cce_
bool sched::generate_dci(srslte_dci_location_t *sched_location, sched_ue::sched_dci_cce_t *locations, uint32_t aggr_level, sched_ue *user) bool sched::generate_dci(srslte_dci_location_t *sched_location, sched_ue::sched_dci_cce_t *locations, uint32_t aggr_level, sched_ue *user)
{ {
if (!locations->nof_loc[aggr_level]) {
Error("In generate_dci(): No locations for aggr_level=%d\n", aggr_level);
return false;
}
uint32_t nof_cand = 0; uint32_t nof_cand = 0;
uint32_t test_cand = rand()%locations->nof_loc[aggr_level]; uint32_t test_cand = rand()%locations->nof_loc[aggr_level];
bool allocated=false; bool allocated=false;

View File

@ -990,7 +990,6 @@ bool sched_ue::is_sr_triggered()
void sched_ue::reset_timeout_dl_harq(uint32_t tti) { void sched_ue::reset_timeout_dl_harq(uint32_t tti) {
for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) { for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) {
if (!(dl_harq[i].is_empty(0) && dl_harq[i].is_empty(1))) { if (!(dl_harq[i].is_empty(0) && dl_harq[i].is_empty(1))) {
log_h->info("SCHED: pid=%d is empty\n", i);
if (srslte_tti_interval(tti, dl_harq[i].get_tti()) > 50) { if (srslte_tti_interval(tti, dl_harq[i].get_tti()) > 50) {
log_h->info("SCHED: pid=%d is old. tti_pid=%d, now is %d, resetting\n", i, dl_harq[i].get_tti(), tti); log_h->info("SCHED: pid=%d is old. tti_pid=%d, now is %d, resetting\n", i, dl_harq[i].get_tti(), tti);
dl_harq[i].reset(0); dl_harq[i].reset(0);