mirror of https://github.com/PentHertz/srsLTE.git
Fix race condition in phy recv
This commit is contained in:
parent
e1870963c7
commit
aaeec591b6
|
@ -309,6 +309,10 @@ private:
|
|||
state_t run_state() {
|
||||
pthread_mutex_lock(&inside);
|
||||
cur_state = next_state;
|
||||
if (state_setting) {
|
||||
state_setting = false;
|
||||
state_changing = true;
|
||||
}
|
||||
pthread_cond_broadcast(&cvar);
|
||||
pthread_mutex_unlock(&inside);
|
||||
return cur_state;
|
||||
|
@ -322,6 +326,8 @@ private:
|
|||
} else {
|
||||
next_state = IDLE;
|
||||
}
|
||||
state_changing = false;
|
||||
pthread_cond_broadcast(&cvar);
|
||||
pthread_mutex_unlock(&inside);
|
||||
}
|
||||
void force_sfn_sync() {
|
||||
|
@ -383,13 +389,16 @@ private:
|
|||
pthread_cond_init(&cvar, NULL);
|
||||
cur_state = IDLE;
|
||||
next_state = IDLE;
|
||||
state_setting = false;
|
||||
state_changing = false;
|
||||
}
|
||||
private:
|
||||
|
||||
void go_state(state_t s) {
|
||||
pthread_mutex_lock(&inside);
|
||||
next_state = s;
|
||||
while(cur_state != s) {
|
||||
state_setting = true;
|
||||
while(state_setting) {
|
||||
pthread_cond_wait(&cvar, &inside);
|
||||
}
|
||||
pthread_mutex_unlock(&inside);
|
||||
|
@ -398,12 +407,13 @@ private:
|
|||
/* Waits until there is a call to set_state() and then run_state(). Returns when run_state() returns */
|
||||
void wait_state_change(state_t prev_state) {
|
||||
pthread_mutex_lock(&inside);
|
||||
while(cur_state == prev_state) {
|
||||
while(state_changing) {
|
||||
pthread_cond_wait(&cvar, &inside);
|
||||
}
|
||||
pthread_mutex_unlock(&inside);
|
||||
}
|
||||
|
||||
bool state_changing, state_setting;
|
||||
state_t cur_state, next_state;
|
||||
pthread_mutex_t inside, outside;
|
||||
pthread_cond_t cvar;
|
||||
|
|
|
@ -135,7 +135,6 @@ void phch_recv::reset()
|
|||
current_earfcn = -1;
|
||||
sfn_p.reset();
|
||||
search_p.reset();
|
||||
phy_state.go_idle();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue