Commit 5367c220 authored by Chun Tian (binghe)'s avatar Chun Tian (binghe)
Browse files

Fix "usocket leaks file descriptors on sb-int:broken-pipe conditions" (#64)

parent d0f34586
...@@ -271,7 +271,7 @@ ...@@ -271,7 +271,7 @@
(defmethod socket-close ((usocket stream-usocket)) (defmethod socket-close ((usocket stream-usocket))
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
(close (socket-stream usocket)) (close (socket-stream usocket) :abort t) ; see "sbcl.lisp" for (:abort t)
(jcall $@close/Socket/0 (socket usocket)))) (jcall $@close/Socket/0 (socket usocket))))
(defmethod socket-close ((usocket datagram-usocket)) (defmethod socket-close ((usocket datagram-usocket))
......
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
(defmethod socket-close ((usocket usocket)) (defmethod socket-close ((usocket usocket))
"Close socket." "Close socket."
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
(close (socket usocket)))) (close (socket usocket) :abort t))) ; see "sbcl.lisp" for (:abort t)
(defmethod socket-shutdown ((usocket stream-usocket) direction) (defmethod socket-shutdown ((usocket stream-usocket) direction)
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
......
...@@ -191,7 +191,7 @@ ...@@ -191,7 +191,7 @@
(defmethod socket-close ((usocket usocket)) (defmethod socket-close ((usocket usocket))
"Close socket." "Close socket."
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
(close (socket usocket)))) (close (socket usocket) :abort t))) ; see "sbcl.lisp" for (:abort t)
(defmethod socket-close ((usocket stream-server-usocket)) (defmethod socket-close ((usocket stream-server-usocket))
(socket:socket-server-close (socket usocket))) (socket:socket-server-close (socket usocket)))
......
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
(defmethod socket-close ((usocket stream-usocket)) (defmethod socket-close ((usocket stream-usocket))
"Close socket." "Close socket."
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
(close (socket-stream usocket)))) (close (socket-stream usocket) :abort t))) ; see "sbcl.lisp" for (:abort t)
(defmethod socket-close ((usocket usocket)) (defmethod socket-close ((usocket usocket))
"Close socket." "Close socket."
......
...@@ -510,7 +510,7 @@ ...@@ -510,7 +510,7 @@
;; are correctly flushed and the socket closed. ;; are correctly flushed and the socket closed.
(defmethod socket-close ((usocket stream-usocket)) (defmethod socket-close ((usocket stream-usocket))
"Close socket." "Close socket."
(close (socket-stream usocket))) (close (socket-stream usocket) :abort t)) ; see "sbcl.lisp" for (:abort t)
(defmethod socket-close ((usocket usocket)) (defmethod socket-close ((usocket usocket))
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
......
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
;; by the same object. ;; by the same object.
(defmethod socket-close ((usocket usocket)) (defmethod socket-close ((usocket usocket))
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
(close (socket usocket)))) (close (socket usocket) :abort t))) ; see "sbcl.lisp" for (:abort t)
(defmethod socket-shutdown ((usocket usocket) direction) (defmethod socket-shutdown ((usocket usocket) direction)
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
......
...@@ -467,9 +467,18 @@ happen. Use with care." ...@@ -467,9 +467,18 @@ happen. Use with care."
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
(sb-bsd-sockets:socket-close (socket usocket)))) (sb-bsd-sockets:socket-close (socket usocket))))
;; usocket leaks file descriptors on sb-int:broken-pipe conditions (#64)
;;
;; "If abort is true, an attempt is made to clean up any side effects of having
;; created stream. If stream performs output to a file that was created when
;; the stream was created, the file is deleted and any previously existing file
;; is not superseded. ... If abort is true and the stream is an output file stream,
;; its associated file might be deleted." (ANSI)
;;
;; adding (:abort t) fixes the potential leaks of socket fds.
(defmethod socket-close ((usocket stream-usocket)) (defmethod socket-close ((usocket stream-usocket))
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
(close (socket-stream usocket)))) (close (socket-stream usocket) :abort t)))
#+sbcl #+sbcl
(defmethod socket-shutdown ((usocket stream-usocket) direction) (defmethod socket-shutdown ((usocket stream-usocket) direction)
......
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
(defmethod socket-close ((usocket stream-usocket)) (defmethod socket-close ((usocket stream-usocket))
"Close socket." "Close socket."
(with-mapped-conditions (usocket) (with-mapped-conditions (usocket)
(close (socket-stream usocket)))) (close (socket-stream usocket) :abort t)))
(defmethod socket-close :after ((socket datagram-usocket)) (defmethod socket-close :after ((socket datagram-usocket))
(setf (%open-p socket) nil)) (setf (%open-p socket) nil))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment