fix socket nullptr bug

This commit is contained in:
thomasonegd 2018-12-24 08:31:54 +08:00
parent 6db31e30c7
commit 71c3c35c3c
1 changed files with 26 additions and 14 deletions

View File

@ -571,11 +571,17 @@ int at_connect(int socket, const struct sockaddr *name, socklen_t namelen)
__exit:
if (result < 0)
{
if (sock != RT_NULL)
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
}
if (sock)
{
at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE);
}
return result;
}
@ -699,6 +705,8 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
__exit:
if (sock != RT_NULL)
{
if (recv_len > 0)
{
result = recv_len;
@ -717,6 +725,7 @@ __exit:
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
}
return result;
}
@ -806,9 +815,12 @@ int at_sendto(int socket, const void *data, size_t size, int flags, const struct
__exit:
if (result < 0)
{
if (sock != RT_NULL)
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
}
else
{
result = len;