             (progn
               (when (functionp cb)
                 (setf cb (make-list (length url) cb)))
-              (setf elfeed-curl--requests (cl-mapcar #'cons url cb)))
-          (push (cons url cb) elfeed-curl--requests))
+              (setf elfeed-curl--requests (cl-mapcar #'cons url cb)
+                    elfeed-curl--refcount (length url)))
+          (push (cons url cb) elfeed-curl--requests)
+          (setf elfeed-curl--refcount 1))
         (setf (process-sentinel process) #'elfeed-curl--sentinel)))))
 
 (defun elfeed-curl--request-key (url headers)

                   initially do (elfeed-curl--parse-write-out)
                   for (url . cb) in elfeed-curl--requests
                   for n upfrom 0
                   do (run-at-time 0 nil handler buffer n url cb)
                   finally (run-at-time 0 nil #'kill-buffer buffer))
        (if (string-match "exited abnormally with code \\([0-9]+\\)" status)
            (let* ((code (string-to-number (match-string 1 status)))
                   (message (cdr (assoc code elfeed-curl--error-codes))))


(defvar-local elfeed-curl--requests ()
  "List of URL / callback pairs for the current buffer.")

(defvar-local elfeed-curl--refcount nil
  "Number of callbacks waiting on the current buffer.")

(defvar elfeed-curl--error-codes
  '((1 . "Unsupported protocol.")
