Author: psmith
Date: Sat Sep 30 16:08:51 2006
New Revision: 2
Modified:
async-fd.lisp
Log:
Applied mem leak patch
Modified: async-fd.lisp
==============================================================================
--- async-fd.lisp (original)
+++ async-fd.lisp Sat Sep 30 16:08:51 2006
@@ -181,12 +181,13 @@
(defun close-async-fd (async-fd)
"Close ASYNC-FD's fd after everything has been written from write-queue."
- (with-slots (write-queue read-fd write-fd) async-fd
+ (with-slots (write-queue read-fd write-fd foreign-read-buffer) async-fd
(cond
;; if write-queue is emtpy, close now
((null write-queue)
(close-fd read-fd)
+ (foreign-free foreign-read-buffer)
(unless (= read-fd write-fd) (close-fd write-fd)))
;; data in write-queue, mark as closing
@@ -213,11 +214,16 @@
(unless (= written size)
(return)))))
- ;; remove entries that have been fully written
- (setf write-queue (remove-if #'(lambda (x)
- (with-slots (size written) x
- (= size written)))
- write-queue))
+ ;; remove (and dealloc buffers) of entries that have been fully written
+ (let ((unfinished-entries NIL))
+ (setf write-queue
+ (nreverse
+ (dolist (entry write-queue unfinished-entries)
+ (with-slots (size written) entry
+ (if (= size written)
+ (with-slots (buffer) entry
+ (foreign-free buffer))
+ (push entry unfinished-entries)))))))
;; if queue empty and close pending, close fd
(if (and (null write-queue) (slot-value async-fd 'close-pending))