diff --git a/components/net/lwip-1.4.0/src/arch/include/arch/cc.h b/components/net/lwip-1.4.0/src/arch/include/arch/cc.h index cad3411cc9..1f18a8dd50 100644 --- a/components/net/lwip-1.4.0/src/arch/include/arch/cc.h +++ b/components/net/lwip-1.4.0/src/arch/include/arch/cc.h @@ -92,9 +92,6 @@ void sys_arch_assert(const char* file, int line); #define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0) #define LWIP_PLATFORM_ASSERT(x) { rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__); } -#define SYS_ARCH_DECL_PROTECT(x) -#define SYS_ARCH_PROTECT(x) -#define SYS_ARCH_UNPROTECT(x) #include "string.h" diff --git a/components/net/lwip-1.4.0/src/arch/sys_arch.c b/components/net/lwip-1.4.0/src/arch/sys_arch.c index a2a6336412..4c4c120670 100644 --- a/components/net/lwip-1.4.0/src/arch/sys_arch.c +++ b/components/net/lwip-1.4.0/src/arch/sys_arch.c @@ -491,12 +491,22 @@ sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, sys_prot_t sys_arch_protect(void) { + rt_base_t level; + /* disable interrupt */ - return rt_hw_interrupt_disable(); + level = rt_hw_interrupt_disable(); + + /* must also lock scheduler */ + rt_enter_critical(); + + return level; } void sys_arch_unprotect(sys_prot_t pval) { + /* unlock scheduler */ + rt_exit_critical(); + /* enable interrupt */ rt_hw_interrupt_enable(pval); diff --git a/components/net/lwip/src/arch/include/arch/cc.h b/components/net/lwip/src/arch/include/arch/cc.h index cad3411cc9..1f18a8dd50 100644 --- a/components/net/lwip/src/arch/include/arch/cc.h +++ b/components/net/lwip/src/arch/include/arch/cc.h @@ -92,9 +92,6 @@ void sys_arch_assert(const char* file, int line); #define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0) #define LWIP_PLATFORM_ASSERT(x) { rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__); } -#define SYS_ARCH_DECL_PROTECT(x) -#define SYS_ARCH_PROTECT(x) -#define SYS_ARCH_UNPROTECT(x) #include "string.h" diff --git a/components/net/lwip/src/arch/sys_arch.c b/components/net/lwip/src/arch/sys_arch.c index e878a70e30..57ead3d755 100644 --- a/components/net/lwip/src/arch/sys_arch.c +++ b/components/net/lwip/src/arch/sys_arch.c @@ -224,20 +224,29 @@ sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, i return t; } -sys_prot_t sys_arch_protect(void) -{ - /* disable interrupt */ - return rt_hw_interrupt_disable(); +sys_prot_t sys_arch_protect(void) +{ + rt_base_t level; + + /* disable interrupt */ + level = rt_hw_interrupt_disable(); + + /* must also lock scheduler */ + rt_enter_critical(); + + return level; +} + +void sys_arch_unprotect(sys_prot_t pval) +{ + /* unlock scheduler */ + rt_exit_critical(); + + /* enable interrupt */ + rt_hw_interrupt_enable(pval); + + return; } - -void sys_arch_unprotect(sys_prot_t pval) -{ - /* enable interrupt */ - rt_hw_interrupt_enable(pval); - - return; -} - void sys_arch_assert(const char* file, int line) { rt_kprintf("\nAssertion: %d in %s, thread %s\n", line, file,