[usocket-devel] Re: usocket-devel post from larsnostdal@gmail.com requires approval

Hi Lars! Thanks for the report. Sorry for the delay; I finally committed your fix. I've applied a similar fix to SOCKET-LISTEN. Bye, Erik. On Tue, Aug 26, 2008 at 2:10 PM, <usocket-devel-owner@common-lisp.net> wrote:
As list administrator, your authorization is requested for the following mailing list posting:
List: usocket-devel@common-lisp.net From: larsnostdal@gmail.com Subject: [Fwd: Don't want FD leaks (patch)] Reason: Post by non-member to a members-only list
At your convenience, visit:
http://common-lisp.net/cgi-bin/mailman/admindb/usocket-devel
to approve or deny the request.
---------- Forwarded message ---------- From: Lars Rune Nøstdal <larsnostdal@gmail.com> To: usocket-devel@common-lisp.net Date: Tue, 26 Aug 2008 14:11:33 +0200 Subject: [Fwd: Don't want FD leaks (patch)]
---------- Forwarded message ---------- From: Lars Rune Nøstdal <larsnostdal@gmail.com> To: Date: Tue, 26 Aug 2008 14:04:09 +0200 Subject: Don't want FD leaks (patch) Hi, Noticed that FDs leak in some cases. Quick test and a patch:
(defun test () (loop (handler-case (let ((socket (usocket:socket-connect "aoeuaoeu.com" 80))) (princ socket) (terpri)) (t (c) (format t "do i leak? ~A~%" c)))))
I use lsof to test for leaks while this is running: lnostdal@blackbox:~/programming/lisp/usocket$ lsof -a -p 25803 | nl
Here is the patch; not tested much but seems to work for me:
lnostdal@blackbox:~/programming/lisp/usocket$ svn diff Index: backend/sbcl.lisp =================================================================== --- backend/sbcl.lisp (revision 423) +++ backend/sbcl.lisp (working copy) @@ -213,27 +213,32 @@ (not (fboundp 'sb-bsd-sockets::sockopt-tcp-nodelay))) (unsupported 'nodelay 'socket-connect))
- (let* ((socket (make-instance 'sb-bsd-sockets:inet-socket - :type :stream :protocol :tcp)) - (stream (sb-bsd-sockets:socket-make-stream socket - :input t - :output t - :buffering :full - :element-type element-type)) - ;;###FIXME: The above line probably needs an :external-format - (usocket (make-stream-socket :stream stream :socket socket)) - (ip (host-to-vector-quad host))) - (when (and nodelay-specified - (fboundp 'sb-bsd-sockets::sockopt-tcp-nodelay)) - (setf (sb-bsd-sockets:sockopt-tcp-nodelay socket) nodelay)) - (when (or local-host local-port) - (sb-bsd-sockets:socket-bind socket - (host-to-vector-quad - (or local-host *wildcard-host*)) - (or local-port *auto-port*))) - (with-mapped-conditions (usocket) - (sb-bsd-sockets:socket-connect socket ip port)) - usocket)) + (let ((socket (make-instance 'sb-bsd-sockets:inet-socket + :type :stream :protocol :tcp))) + (handler-case + (let* ((stream (sb-bsd-sockets:socket-make-stream socket + :input t + :output t + :buffering :full + :element-type element-type)) + ;;###FIXME: The above line probably needs an :external-format + (usocket (make-stream-socket :stream stream :socket socket)) + (ip (host-to-vector-quad host))) + (when (and nodelay-specified + (fboundp 'sb-bsd-sockets::sockopt-tcp-nodelay)) + (setf (sb-bsd-sockets:sockopt-tcp-nodelay socket) nodelay)) + (when (or local-host local-port) + (sb-bsd-sockets:socket-bind socket + (host-to-vector-quad + (or local-host *wildcard-host*)) + (or local-port *auto-port*))) + (with-mapped-conditions (usocket) + (sb-bsd-sockets:socket-connect socket ip port)) + usocket) + (t (c) + ;; Make sure we don't leak filedescriptors. + (sb-bsd-sockets:socket-close socket) + (error c)))))
(defun socket-listen (host port &key reuseaddress
-- Lars Rune Nøstdal || AJAX/Comet GUI type stuff for Common Lisp http://nostdal.org/ || http://groups.google.com/group/symbolicweb
---------- Forwarded message ---------- From: usocket-devel-request@common-lisp.net To: Date: Subject: confirm c133299de2b1ebf623d1c8e5ce04db0e85ab23b7 If you reply to this message, keeping the Subject: header intact, Mailman will discard the held message. Do this if the message is spam. If you reply to this message and include an Approved: header with the list password in it, the message will be approved for posting to the list. The Approved: header can also appear in the first line of the body of the reply.
participants (1)
-
Erik Huelsmann