From a10fdfa6a1e5769fdfbf18c6f05bb76a76833f9d Mon Sep 17 00:00:00 2001 From: number201724 Date: Tue, 9 Jul 2024 03:16:26 +0800 Subject: [PATCH] Fix socket_open when the connect fails, -1 is not set after closing sockfd --- modules/sockets/sockets.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/sockets/sockets.cpp b/modules/sockets/sockets.cpp index 16b26b0d..059d65f5 100644 --- a/modules/sockets/sockets.cpp +++ b/modules/sockets/sockets.cpp @@ -142,7 +142,10 @@ static cell AMX_NATIVE_CALL socket_open(AMX *amx, cell *params) if(nonblocking_socket && (errno == EINPROGRESS || errno == EWOULDBLOCK)) connect_inprogress = true; else + { close(sockfd); + sockfd = -1; + } } else {