mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-01 04:12:07 +00:00
Removed semaphores from memp, changed sys_sem_wait calls into sys_arch_sem_wait calls to prevent timers from running while waiting for the heap. This fixes bug #19167.
This commit is contained in:
parent
887077b5a4
commit
fd982597fe
@ -158,6 +158,11 @@ HISTORY
|
|||||||
|
|
||||||
++ Bug fixes:
|
++ Bug fixes:
|
||||||
|
|
||||||
|
2007-05-16 Simon Goldschmidt
|
||||||
|
* mem.c, memp.c: Removed semaphores from memp, changed sys_sem_wait calls
|
||||||
|
into sys_arch_sem_wait calls to prevent timers from running while waiting
|
||||||
|
for the heap. This fixes bug #19167.
|
||||||
|
|
||||||
2007-05-13 Simon Goldschmidt
|
2007-05-13 Simon Goldschmidt
|
||||||
* tcp.h, sockets.h, sockets.c: Fixed bug from patch #5865 by moving the defines
|
* tcp.h, sockets.h, sockets.c: Fixed bug from patch #5865 by moving the defines
|
||||||
for socket options (lwip_set/-getsockopt) used with level IPPROTO_TCP from
|
for socket options (lwip_set/-getsockopt) used with level IPPROTO_TCP from
|
||||||
|
@ -171,7 +171,7 @@ mem_free(void *rmem)
|
|||||||
LWIP_ASSERT("mem_free: sanity check alignment", (((mem_ptr_t)rmem) & (MEM_ALIGNMENT-1)) == 0);
|
LWIP_ASSERT("mem_free: sanity check alignment", (((mem_ptr_t)rmem) & (MEM_ALIGNMENT-1)) == 0);
|
||||||
|
|
||||||
/* protect the heap from concurrent access */
|
/* protect the heap from concurrent access */
|
||||||
sys_sem_wait(mem_sem);
|
sys_arch_sem_wait(mem_sem, 0);
|
||||||
|
|
||||||
LWIP_ASSERT("mem_free: legal memory", (u8_t *)rmem >= (u8_t *)ram &&
|
LWIP_ASSERT("mem_free: legal memory", (u8_t *)rmem >= (u8_t *)ram &&
|
||||||
(u8_t *)rmem < (u8_t *)ram_end);
|
(u8_t *)rmem < (u8_t *)ram_end);
|
||||||
@ -253,7 +253,7 @@ mem_realloc(void *rmem, mem_size_t newsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* protect the heap from concurrent access */
|
/* protect the heap from concurrent access */
|
||||||
sys_sem_wait(mem_sem);
|
sys_arch_sem_wait(mem_sem, 0);
|
||||||
|
|
||||||
#if MEM_STATS
|
#if MEM_STATS
|
||||||
lwip_stats.mem.used -= (size - newsize);
|
lwip_stats.mem.used -= (size - newsize);
|
||||||
@ -319,7 +319,7 @@ mem_malloc(mem_size_t size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sys_sem_wait(mem_sem);
|
sys_arch_sem_wait(mem_sem, 0);
|
||||||
|
|
||||||
for (ptr = (u8_t *)lfree - ram; ptr < MEM_SIZE_ALIGNED; ptr = ((struct mem *)&ram[ptr])->next) {
|
for (ptr = (u8_t *)lfree - ram; ptr < MEM_SIZE_ALIGNED; ptr = ((struct mem *)&ram[ptr])->next) {
|
||||||
mem = (struct mem *)&ram[ptr];
|
mem = (struct mem *)&ram[ptr];
|
||||||
@ -402,7 +402,7 @@ mem_malloc(mem_size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* protect the heap from concurrent access */
|
/* protect the heap from concurrent access */
|
||||||
sys_sem_wait(mem_sem);
|
sys_arch_sem_wait(mem_sem, 0);
|
||||||
|
|
||||||
/* Scan through the heap searching for a free block that is big enough,
|
/* Scan through the heap searching for a free block that is big enough,
|
||||||
* beginning with the lowest free block.
|
* beginning with the lowest free block.
|
||||||
|
@ -111,10 +111,6 @@ static u8_t memp_memory[MEM_ALIGNMENT - 1 +
|
|||||||
PBUF_POOL_SIZE * MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) +
|
PBUF_POOL_SIZE * MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) +
|
||||||
MEMP_TYPE_SIZE(MEMP_NUM_SYS_TIMEOUT, struct sys_timeo)];
|
MEMP_TYPE_SIZE(MEMP_NUM_SYS_TIMEOUT, struct sys_timeo)];
|
||||||
|
|
||||||
#if !SYS_LIGHTWEIGHT_PROT
|
|
||||||
static sys_sem_t mutex;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MEMP_SANITY_CHECK
|
#if MEMP_SANITY_CHECK
|
||||||
static int
|
static int
|
||||||
memp_sanity(void)
|
memp_sanity(void)
|
||||||
@ -159,27 +155,17 @@ memp_init(void)
|
|||||||
memp = (struct memp *)((u8_t *)memp + MEMP_SIZE + memp_sizes[i]);
|
memp = (struct memp *)((u8_t *)memp + MEMP_SIZE + memp_sizes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !SYS_LIGHTWEIGHT_PROT
|
|
||||||
mutex = sys_sem_new(1);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
memp_malloc(memp_t type)
|
memp_malloc(memp_t type)
|
||||||
{
|
{
|
||||||
struct memp *memp;
|
struct memp *memp;
|
||||||
#if SYS_LIGHTWEIGHT_PROT
|
|
||||||
SYS_ARCH_DECL_PROTECT(old_level);
|
SYS_ARCH_DECL_PROTECT(old_level);
|
||||||
#endif
|
|
||||||
|
|
||||||
LWIP_ASSERT("memp_malloc: type < MEMP_MAX", type < MEMP_MAX);
|
LWIP_ASSERT("memp_malloc: type < MEMP_MAX", type < MEMP_MAX);
|
||||||
|
|
||||||
#if SYS_LIGHTWEIGHT_PROT
|
|
||||||
SYS_ARCH_PROTECT(old_level);
|
SYS_ARCH_PROTECT(old_level);
|
||||||
#else /* SYS_LIGHTWEIGHT_PROT */
|
|
||||||
sys_sem_wait(mutex);
|
|
||||||
#endif /* SYS_LIGHTWEIGHT_PROT */
|
|
||||||
|
|
||||||
memp = memp_tab[type];
|
memp = memp_tab[type];
|
||||||
|
|
||||||
@ -201,11 +187,7 @@ memp_malloc(memp_t type)
|
|||||||
#endif /* MEMP_STATS */
|
#endif /* MEMP_STATS */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SYS_LIGHTWEIGHT_PROT
|
|
||||||
SYS_ARCH_UNPROTECT(old_level);
|
SYS_ARCH_UNPROTECT(old_level);
|
||||||
#else /* SYS_LIGHTWEIGHT_PROT */
|
|
||||||
sys_sem_signal(mutex);
|
|
||||||
#endif /* SYS_LIGHTWEIGHT_PROT */
|
|
||||||
|
|
||||||
return (void*)memp;
|
return (void*)memp;
|
||||||
}
|
}
|
||||||
@ -214,9 +196,7 @@ void
|
|||||||
memp_free(memp_t type, void *mem)
|
memp_free(memp_t type, void *mem)
|
||||||
{
|
{
|
||||||
struct memp *memp;
|
struct memp *memp;
|
||||||
#if SYS_LIGHTWEIGHT_PROT
|
|
||||||
SYS_ARCH_DECL_PROTECT(old_level);
|
SYS_ARCH_DECL_PROTECT(old_level);
|
||||||
#endif /* SYS_LIGHTWEIGHT_PROT */
|
|
||||||
|
|
||||||
if (mem == NULL) {
|
if (mem == NULL) {
|
||||||
return;
|
return;
|
||||||
@ -226,11 +206,7 @@ memp_free(memp_t type, void *mem)
|
|||||||
|
|
||||||
memp = (struct memp *)mem;
|
memp = (struct memp *)mem;
|
||||||
|
|
||||||
#if SYS_LIGHTWEIGHT_PROT
|
|
||||||
SYS_ARCH_PROTECT(old_level);
|
SYS_ARCH_PROTECT(old_level);
|
||||||
#else /* SYS_LIGHTWEIGHT_PROT */
|
|
||||||
sys_sem_wait(mutex);
|
|
||||||
#endif /* SYS_LIGHTWEIGHT_PROT */
|
|
||||||
|
|
||||||
#if MEMP_STATS
|
#if MEMP_STATS
|
||||||
lwip_stats.memp[type].used--;
|
lwip_stats.memp[type].used--;
|
||||||
@ -243,9 +219,5 @@ memp_free(memp_t type, void *mem)
|
|||||||
LWIP_ASSERT("memp sanity", memp_sanity());
|
LWIP_ASSERT("memp sanity", memp_sanity());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SYS_LIGHTWEIGHT_PROT
|
|
||||||
SYS_ARCH_UNPROTECT(old_level);
|
SYS_ARCH_UNPROTECT(old_level);
|
||||||
#else /* SYS_LIGHTWEIGHT_PROT */
|
|
||||||
sys_sem_signal(mutex);
|
|
||||||
#endif /* SYS_LIGHTWEIGHT_PROT */
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user