From e2706c14b11c0e86bc38df9852f8b3948061aad0 Mon Sep 17 00:00:00 2001 From: chenyong <1521761801@qq.com> Date: Mon, 17 Sep 2018 18:01:26 +0800 Subject: [PATCH] [net][at] Fix AT Socket select send data issue. --- components/net/at/at_socket/at_socket.c | 34 +++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index 43913498f..6f12c1d22 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -200,7 +200,7 @@ static void at_do_event_changes(struct at_socket *sock, at_event_t event, rt_boo { if (is_plus) { - sock->sendevent++; + sock->sendevent = 1; #ifdef SAL_USING_POSIX rt_wqueue_wakeup(&sock->wait_head, (void*) POLLOUT); @@ -209,7 +209,7 @@ static void at_do_event_changes(struct at_socket *sock, at_event_t event, rt_boo } else if (sock->sendevent) { - sock->sendevent --; + sock->sendevent = 0; } break; } @@ -252,6 +252,30 @@ static void at_do_event_changes(struct at_socket *sock, at_event_t event, rt_boo } } +static void at_do_event_clean(struct at_socket *sock, at_event_t event) +{ + switch (event) + { + case AT_EVENT_SEND: + { + sock->sendevent = 0; + break; + } + case AT_EVENT_RECV: + { + sock->rcvevent = 0; + break; + } + case AT_EVENT_ERROR: + { + sock->errevent = 0; + break; + } + default: + LOG_E("Not supported event (%d)", event); + } +} + static struct at_socket *alloc_socket(void) { static rt_mutex_t at_slock = RT_NULL; @@ -565,6 +589,8 @@ __exit: at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); } + at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE); + return result; } @@ -688,6 +714,10 @@ __exit: { at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE); } + else + { + at_do_event_clean(sock, AT_EVENT_RECV); + } } else { -- GitLab