Skip to content

Commit fc2f26e

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'bugfix/eloop_lock_v5.5' into 'release/v5.5'
Made changes related to registering eloop timeout for eloop lock(backports v5.5) See merge request espressif/esp-idf!42135
2 parents 690e83d + 61d4f44 commit fc2f26e

File tree

1 file changed

+4
-10
lines changed
  • components/wpa_supplicant/port

1 file changed

+4
-10
lines changed

components/wpa_supplicant/port/eloop.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,27 +137,23 @@ int eloop_register_timeout(unsigned int secs, unsigned int usecs,
137137
#endif
138138

139139
/* Maintain timeouts in order of increasing time */
140+
ELOOP_LOCK();
140141
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
141142
if (os_reltime_before(&timeout->time, &tmp->time)) {
142-
ELOOP_LOCK();
143143
dl_list_add(tmp->list.prev, &timeout->list);
144-
ELOOP_UNLOCK();
145144
goto run;
146145
}
147146
#ifdef ELOOP_DEBUG
148147
count++;
149148
#endif
150149
}
151-
ELOOP_LOCK();
152150
dl_list_add_tail(&eloop.timeout, &timeout->list);
153-
ELOOP_UNLOCK();
154151

155152
run:
156153
#ifdef ELOOP_DEBUG
157154
wpa_printf(MSG_DEBUG, "ELOOP: Added one timer from %s:%d to call %p, current order=%d",
158155
timeout->func_name, line, timeout->handler, count);
159156
#endif
160-
ELOOP_LOCK();
161157
os_timer_disarm(&eloop.eloop_timer);
162158
os_timer_arm(&eloop.eloop_timer, 0, 0);
163159
ELOOP_UNLOCK();
@@ -227,27 +223,23 @@ int eloop_register_timeout_blocking(eloop_blocking_timeout_handler handler,
227223
}
228224
timeout->sync_semph = eloop.eloop_semph;
229225
/* Maintain timeouts in order of increasing time */
226+
ELOOP_LOCK();
230227
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
231228
if (os_reltime_before(&timeout->time, &tmp->time)) {
232-
ELOOP_LOCK();
233229
dl_list_add(tmp->list.prev, &timeout->list);
234-
ELOOP_UNLOCK();
235230
goto run;
236231
}
237232
#ifdef ELOOP_DEBUG
238233
count++;
239234
#endif
240235
}
241-
ELOOP_LOCK();
242236
dl_list_add_tail(&eloop.timeout, &timeout->list);
243-
ELOOP_UNLOCK();
244237

245238
run:
246239
#ifdef ELOOP_DEBUG
247240
wpa_printf(MSG_DEBUG, "ELOOP: Added one blocking timer from %s:%d to call %p, current order=%d",
248241
timeout->func_name, line, timeout->handler, count);
249242
#endif
250-
ELOOP_LOCK();
251243
os_timer_disarm(&eloop.eloop_timer);
252244
os_timer_arm(&eloop.eloop_timer, 0, 0);
253245
ELOOP_UNLOCK();
@@ -447,8 +439,10 @@ void eloop_run(void)
447439
while (!dl_list_empty(&eloop.timeout)) {
448440
struct eloop_timeout *timeout;
449441

442+
ELOOP_LOCK();
450443
timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
451444
list);
445+
ELOOP_UNLOCK();
452446
if (timeout) {
453447
os_get_reltime(&now);
454448
if (os_reltime_before(&now, &timeout->time)) {

0 commit comments

Comments
 (0)