未验证 提交 3a8c6f32 编写于 作者: H HubretXie 提交者: GitHub

Update at_socket.c

修改socket读取遗留数据逻辑
上级 7ac5bd99
......@@ -627,6 +627,15 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
at_dev_ops->at_set_event_cb(AT_SOCKET_EVT_CLOSED, at_closed_notice_cb);
}
/* receive packet list last transmission of remaining data */
rt_mutex_take(sock->recv_lock, RT_WAITING_FOREVER);
if((recv_len = at_recvpkt_get(&(sock->recvpkt_list), (char *)mem, len)) > 0)
{
rt_mutex_release(sock->recv_lock);
goto __exit;
}
rt_mutex_release(sock->recv_lock);
/* socket passively closed, receive function return 0 */
if (sock->state == AT_SOCKET_CLOSED)
{
......@@ -640,15 +649,6 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
goto __exit;
}
/* receive packet list last transmission of remaining data */
rt_mutex_take(sock->recv_lock, RT_WAITING_FOREVER);
if((recv_len = at_recvpkt_get(&(sock->recvpkt_list), (char *)mem, len)) > 0)
{
rt_mutex_release(sock->recv_lock);
goto __exit;
}
rt_mutex_release(sock->recv_lock);
/* non-blocking sockets receive data */
if (flags & MSG_DONTWAIT)
{
......@@ -715,19 +715,7 @@ __exit:
}
else
{
/* try to read Legacy data */
/* receive packet list last transmission of remaining data */
rt_mutex_take(sock->recv_lock, RT_WAITING_FOREVER);
recv_len = at_recvpkt_get(&(sock->recvpkt_list), (char *)mem, len);
rt_mutex_release(sock->recv_lock);
if(recv_len<=0)
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
else
{
result = recv_len;
}
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
return result;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册