net: fix leaking sockets in listen_tcp if an error occurs

This commit is contained in:
Laytan Laats
2024-10-08 21:08:14 +02:00
parent d8af35f01e
commit 5c63617191
4 changed files with 24 additions and 13 deletions
+1
View File
@@ -120,6 +120,7 @@ _listen_tcp :: proc(interface_endpoint: Endpoint, backlog := 1000) -> (skt: TCP_
family := family_from_endpoint(interface_endpoint)
sock := create_socket(family, .TCP) or_return
skt = sock.(TCP_Socket)
defer if err != nil { close(skt) }
// NOTE(tetra): This is so that if we crash while the socket is open, we can
// bypass the cooldown period, and allow the next run of the program to