From 97375f4576ee0637d4a3452a411900f224beeb44 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 3 Jan 2016 12:48:29 +0200 Subject: [PATCH] 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). --- esp8266/ets_alt_task.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/esp8266/ets_alt_task.c b/esp8266/ets_alt_task.c index ece7727f0b..d408175ddc 100644 --- a/esp8266/ets_alt_task.c +++ b/esp8266/ets_alt_task.c @@ -111,16 +111,17 @@ bool ets_loop_iter(void) { progress = true; //printf("#%d Calling task %d(%p) (%x, %x)\n", cnt++, // t - emu_tasks + FIRST_PRIO, t->task, t->queue[t->i_get].sig, t->queue[t->i_get].par); - //ets_intr_unlock(); - t->task(&t->queue[t->i_get]); - //ets_intr_lock(); - //printf("Done calling task %d\n", t - emu_tasks + FIRST_PRIO); + int idx = t->i_get; if (t->i_put == -1) { t->i_put = t->i_get; } if (++t->i_get == t->qlen) { t->i_get = 0; } + //ets_intr_unlock(); + t->task(&t->queue[idx]); + //ets_intr_lock(); + //printf("Done calling task %d\n", t - emu_tasks + FIRST_PRIO); } ets_intr_unlock(); }