Browse Source

Update net_sockets.c

修复创建socket失败仍然返回有效的fd
Bluebear233 7 years ago
parent
commit
ec81f44ff9
1 changed files with 10 additions and 0 deletions
  1. 10 0
      components/dfs/filesystems/net/net_sockets.c

+ 10 - 0
components/dfs/filesystems/net/net_sockets.c

@@ -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);