fix(lwip): Fix lwip sync error to let sending task block

This commit is contained in:
Dong Heng
2018-09-25 10:02:29 +08:00
parent be28244ac0
commit e193bd3f1d

View File

@ -164,16 +164,17 @@ typedef struct _sock_mt {
#define SOCK_MT_EXIT_CHECK(s, l, st) \ #define SOCK_MT_EXIT_CHECK(s, l, st) \
{ \ { \
if (st != SOCK_MT_STATE_ILL) \
_sock_set_state(s, SOCK_MT_STATE_SOCK); \
if (_sock_unlock(s, l) != ERR_OK) \ if (_sock_unlock(s, l) != ERR_OK) \
return -1; \ return -1; \
_sock_set_state(s, SOCK_MT_STATE_SOCK); \
} }
static sock_mt_t DRAM_ATTR sockets_mt[NUM_SOCKETS]; static volatile sock_mt_t DRAM_ATTR sockets_mt[NUM_SOCKETS];
static inline void _sock_mt_init(int s) static inline void _sock_mt_init(int s)
{ {
memset(&sockets_mt[s], 0, sizeof(sock_mt_t)); memset((void *)&sockets_mt[s], 0, sizeof(sock_mt_t));
} }
static inline int _sock_is_opened(int s) static inline int _sock_is_opened(int s)
@ -463,11 +464,11 @@ static void lwip_sync_mt(int s, int how)
int lock = SOCK_MT_LOCK_MIN; int lock = SOCK_MT_LOCK_MIN;
struct lwip_sock *sock; struct lwip_sock *sock;
while (lock < SOCK_MT_LOCK_MAX) { do {
if (_sock_is_lock(s, lock)) {
int need_wait = 0; int need_wait = 0;
extern void sys_arch_msleep(int ms); extern void sys_arch_msleep(int ms);
if (_sock_is_lock(s, lock)) {
if (!_sock_get_select(s, SOCK_MT_SELECT_RECV | SOCK_MT_SELECT_SEND)) { if (!_sock_get_select(s, SOCK_MT_SELECT_RECV | SOCK_MT_SELECT_SEND)) {
switch (lock) { switch (lock) {
case SOCK_MT_LOCK_SEND: case SOCK_MT_LOCK_SEND:
@ -485,13 +486,12 @@ static void lwip_sync_mt(int s, int how)
lwip_sync_select_mt(s); lwip_sync_select_mt(s);
need_wait = 1; need_wait = 1;
} }
}
if (need_wait) if (need_wait)
sys_arch_msleep(LWIP_SYNC_MT_SLEEP_MS); sys_arch_msleep(LWIP_SYNC_MT_SLEEP_MS);
} else
lock = _sock_next_lock(lock); lock = _sock_next_lock(lock);
} } while (lock < SOCK_MT_LOCK_MAX);
sock = tryget_socket(s); sock = tryget_socket(s);
if (sock) { if (sock) {