[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] infinite loop in sys_mbox_fetch
From: |
E.F.Spijksma |
Subject: |
[lwip-users] infinite loop in sys_mbox_fetch |
Date: |
Tue, 11 Apr 2006 08:57:33 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.7 (Windows/20050923) |
Hi,
I'm using freertos (since last week version 4.0.0) with the lwip stack
demo, which I upgraded to 1.1.1.
I use the at91sam7x-ek develepmentboard. In the os I implemented EFSL so
I could use a sd-card for the site.
My webserver got blocked everytime it got a timeout. When a timout
occured there was een infinite loop in the function
sys_mbox_fetch(...) in the file sys.c checking the mbox for messages at
the point goto again; . I fixed this at the moment by adding a counter
on wich after a timeout occurs it will check the mbox 2 times for a
message and then leave the function.
See below for source.
Regards
Edwin
void sys_mbox_fetch(sys_mbox_t mbox, void **msg)
{
u32_t time;
struct sys_timeouts *timeouts;
struct sys_timeout *tmptimeout;
sys_timeout_handler h;
void *arg;
u8_t iCounter = 0;
again:
timeouts = sys_arch_timeouts();
if (!timeouts || !timeouts->next)
{
sys_arch_mbox_fetch(mbox, msg, 0);
}
else
{
if (timeouts->next->time > 0)
{
time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time);
}
else
{
time = SYS_ARCH_TIMEOUT;
}
if (time == SYS_ARCH_TIMEOUT)
{
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message
could be fetched. We should now call the timeout handler and
deallocate the memory allocated for the timeout. */
tmptimeout = timeouts->next;
timeouts->next = tmptimeout->next;
h = tmptimeout->h;
arg = tmptimeout->arg;
memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
if (h != NULL)
{
LWIP_DEBUGF(SYS_DEBUG, ("smf calling h=%p(%p)\n", (void
*)h, (void *)arg));
h(arg);
}
/* We try again to fetch a message from the mbox. */
iCounter++;
if(iCounter < 2)
goto again;
}
else
{
/* If time != SYS_ARCH_TIMEOUT, a message was received
before the timeout
occured. The time variable is set to the number of
milliseconds we waited for the message. */
if (time <= timeouts->next->time)
{
timeouts->next->time -= time;
}
else
{
timeouts->next->time = 0;
}
}
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-users] infinite loop in sys_mbox_fetch,
E.F.Spijksma <=