aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/net/socket_darwin.odin4
-rw-r--r--core/net/socket_freebsd.odin4
-rw-r--r--core/net/socket_linux.odin3
-rw-r--r--core/net/socket_windows.odin4
4 files changed, 8 insertions, 7 deletions
diff --git a/core/net/socket_darwin.odin b/core/net/socket_darwin.odin
index ec9255c3b..e26c7407d 100644
--- a/core/net/socket_darwin.odin
+++ b/core/net/socket_darwin.odin
@@ -88,8 +88,8 @@ _dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_optio
sockaddr := _endpoint_to_sockaddr(endpoint)
res := os.connect(os.Socket(skt), (^os.SOCKADDR)(&sockaddr), i32(sockaddr.len))
if res != nil {
- err = Dial_Error(os.is_platform_error(res) or_else -1)
- return
+ close(skt)
+ return {}, Dial_Error(os.is_platform_error(res) or_else -1)
}
return
diff --git a/core/net/socket_freebsd.odin b/core/net/socket_freebsd.odin
index 0f3a85cbb..2c193b0d8 100644
--- a/core/net/socket_freebsd.odin
+++ b/core/net/socket_freebsd.odin
@@ -114,8 +114,8 @@ _dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_optio
sockaddr := _endpoint_to_sockaddr(endpoint)
errno := freebsd.connect(cast(Fd)socket, &sockaddr, cast(freebsd.socklen_t)sockaddr.len)
if errno != nil {
- err = cast(Dial_Error)errno
- return
+ close(socket)
+ return {}, cast(Dial_Error)errno
}
return
diff --git a/core/net/socket_linux.odin b/core/net/socket_linux.odin
index a3853874a..be189f5c1 100644
--- a/core/net/socket_linux.odin
+++ b/core/net/socket_linux.odin
@@ -147,7 +147,8 @@ _dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_optio
addr := _unwrap_os_addr(endpoint)
errno = linux.connect(linux.Fd(os_sock), &addr)
if errno != .NONE {
- return cast(TCP_Socket) os_sock, Dial_Error(errno)
+ close(cast(TCP_Socket) os_sock)
+ return {}, Dial_Error(errno)
}
// NOTE(tetra): Not vital to succeed; error ignored
no_delay: b32 = cast(b32) options.no_delay
diff --git a/core/net/socket_windows.odin b/core/net/socket_windows.odin
index 20f17619d..8e18f4f88 100644
--- a/core/net/socket_windows.odin
+++ b/core/net/socket_windows.odin
@@ -80,8 +80,8 @@ _dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_optio
sockaddr := _endpoint_to_sockaddr(endpoint)
res := win.connect(win.SOCKET(socket), &sockaddr, size_of(sockaddr))
if res < 0 {
- err = Dial_Error(win.WSAGetLastError())
- return
+ close(socket)
+ return {}, Dial_Error(win.WSAGetLastError())
}
if options.no_delay {