Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In make-tcp-socket, close stream (not just fd) when connect fails #505

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion library/sockets.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,19 @@ the socket is not connected."))
:port remote-port
:allow-other-keys t
keys))))
(%socket-connect fd socket-address timeout-in-milliseconds)))
(handler-bind
((socket-creation-error
(lambda (c)
(declare (ignore c))
;; When connect fails, the fd is no longer usable,
;; and must be closed. Because we've already made
;; a stream using this fd, close the fd by closing
;; the stream.
(close socket)
;; Don't try to close fd again in the unwind-protect
;; cleanup form.
(setq fd -1))))
(%socket-connect fd socket-address timeout-in-milliseconds))))
(setq fd -1)
socket))
(unless (< fd 0)
Expand Down