提交 71c3c35c 编写于 作者: QThomas's avatar QThomas

fix socket nullptr bug

上级 6db31e30
...@@ -572,10 +572,16 @@ __exit: ...@@ -572,10 +572,16 @@ __exit:
if (result < 0) if (result < 0)
{ {
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); if (sock != RT_NULL)
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
} }
at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE); if (sock)
{
at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE);
}
return result; return result;
} }
...@@ -699,24 +705,27 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f ...@@ -699,24 +705,27 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
__exit: __exit:
if (recv_len > 0) if (sock != RT_NULL)
{ {
result = recv_len; if (recv_len > 0)
at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE);
errno = 0;
if (!rt_slist_isempty(&sock->recvpkt_list))
{ {
at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE); result = recv_len;
at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE);
errno = 0;
if (!rt_slist_isempty(&sock->recvpkt_list))
{
at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE);
}
else
{
at_do_event_clean(sock, AT_EVENT_RECV);
}
} }
else else
{ {
at_do_event_clean(sock, AT_EVENT_RECV); at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
} }
} }
else
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
return result; return result;
} }
...@@ -807,7 +816,10 @@ __exit: ...@@ -807,7 +816,10 @@ __exit:
if (result < 0) if (result < 0)
{ {
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); if (sock != RT_NULL)
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
} }
else else
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册