Skip to content

Commit 97375f4

Browse files
committed
esp8266/ets_alt_task: Be sure to "pop" event before calling its handler.
Otherwise, if handler calls recursive event loop, there's infinite recursion (because the loop calls the same handler on same event again).
1 parent 7261f17 commit 97375f4

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

esp8266/ets_alt_task.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,17 @@ bool ets_loop_iter(void) {
111111
progress = true;
112112
//printf("#%d Calling task %d(%p) (%x, %x)\n", cnt++,
113113
// t - emu_tasks + FIRST_PRIO, t->task, t->queue[t->i_get].sig, t->queue[t->i_get].par);
114-
//ets_intr_unlock();
115-
t->task(&t->queue[t->i_get]);
116-
//ets_intr_lock();
117-
//printf("Done calling task %d\n", t - emu_tasks + FIRST_PRIO);
114+
int idx = t->i_get;
118115
if (t->i_put == -1) {
119116
t->i_put = t->i_get;
120117
}
121118
if (++t->i_get == t->qlen) {
122119
t->i_get = 0;
123120
}
121+
//ets_intr_unlock();
122+
t->task(&t->queue[idx]);
123+
//ets_intr_lock();
124+
//printf("Done calling task %d\n", t - emu_tasks + FIRST_PRIO);
124125
}
125126
ets_intr_unlock();
126127
}

0 commit comments

Comments
 (0)