From 1844f40ad1284322ff0ce00004802e762059f719 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Tue, 28 Jan 2014 21:05:37 +0100 Subject: [PATCH] Fix map-push-queue to ensure we send an :end-of-data message no matter what. --- src/queue.lisp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/queue.lisp b/src/queue.lisp index ee75650..94dd4bb 100644 --- a/src/queue.lisp +++ b/src/queue.lisp @@ -61,12 +61,15 @@ "Apply MAP-ROWS on the COPY instance and a function of ROW that will push the row into the QUEUE. When MAP-ROWS returns, push :end-of-data in the queue." - (setf *current-batch* (make-batch)) (unwind-protect - (map-rows copy :process-row-fn (lambda (row) (batch-row row copy queue))) - (with-slots (data count) *current-batch* - (when (< 0 count) - (lq:push-queue (list :batch data count nil) queue))) + (let ((*current-batch* (make-batch))) + (map-rows copy :process-row-fn (lambda (row) + (batch-row row copy queue))) + + ;; we might have the last batch to send over now + (with-slots (data count) *current-batch* + (when (< 0 count) + (lq:push-queue (list :batch data count nil) queue)))) ;; signal we're done (lq:push-queue (list :end-of-data nil nil nil) queue)))