Merge pull request #2103 from thomasonegd/master

fix socket nullptr bug
This commit is contained in:
Bernard Xiong 2019-01-02 10:47:52 +08:00 committed by GitHub
commit 9556288e54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 14 deletions

View File

@ -572,10 +572,16 @@ __exit:
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;
}
@ -699,24 +705,27 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
__exit:
if (recv_len > 0)
if (sock != RT_NULL)
{
result = recv_len;
at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE);
errno = 0;
if (!rt_slist_isempty(&sock->recvpkt_list))
if (recv_len > 0)
{
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
{
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;
}
@ -807,7 +816,10 @@ __exit:
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
{