4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-19 17:13:31 +08:00

Update net_sockets.c

修复创建socket失败仍然返回有效的fd
This commit is contained in:
Bluebear233 2018-05-27 21:37:08 +08:00 committed by GitHub
parent 51db86ca52
commit ec81f44ff9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -316,6 +316,16 @@ int socket(int domain, int type, int protocol)
rt_list_init(&(lwsock->wait_head));
lwsock->conn->callback = event_callback;
}
else
{
/* release fd */
fd_put(d);
fd_put(d);
rt_set_errno(-ENOMEM);
return -1;
}
/* release the ref-count of fd */
fd_put(d);