aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-02-08 17:13:01 +1100
committerLars Ingebrigtsen2016-02-08 17:13:01 +1100
commitda66e5585083c2c357e960144fd4ae0e75310f74 (patch)
treeef8f3dd3eb3123927754b7e48fe3c915a25a7b5e
parent8b50ae8b2284b5652c2843a9d0d076f4f657be28 (diff)
downloademacs-da66e5585083c2c357e960144fd4ae0e75310f74.tar.gz
emacs-da66e5585083c2c357e960144fd4ae0e75310f74.zip
Ensure progress when fetching from the queue
* lisp/url/url-queue.el (url-queue-check-progress): Ensure that we have progress when fetching queued requests (bug#22576).
-rw-r--r--lisp/url/url-queue.el18
1 files changed, 16 insertions, 2 deletions
diff --git a/lisp/url/url-queue.el b/lisp/url/url-queue.el
index 0ff4ad1556c..8972d0b056c 100644
--- a/lisp/url/url-queue.el
+++ b/lisp/url/url-queue.el
@@ -1,4 +1,4 @@
1;;; url-queue.el --- Fetching web pages in parallel 1;;; url-queue.el --- Fetching web pages in parallel -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2011-2016 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
4 4
@@ -47,6 +47,7 @@
47;;; Internal variables. 47;;; Internal variables.
48 48
49(defvar url-queue nil) 49(defvar url-queue nil)
50(defvar url-queue-progress-timer nil)
50 51
51(cl-defstruct url-queue 52(cl-defstruct url-queue
52 url callback cbargs silentp 53 url callback cbargs silentp
@@ -90,7 +91,13 @@ The variable `url-queue-timeout' sets a timeout."
90 (when (and waiting 91 (when (and waiting
91 (< running url-queue-parallel-processes)) 92 (< running url-queue-parallel-processes))
92 (setf (url-queue-pre-triggered waiting) t) 93 (setf (url-queue-pre-triggered waiting) t)
93 (run-with-idle-timer 0.01 nil 'url-queue-run-queue)))) 94 ;; We start fetching from this idle timer...
95 (run-with-idle-timer 0.01 nil #'url-queue-run-queue)
96 ;; And then we set up a separate timer to ensure progress when a
97 ;; web server is unresponsive.
98 (unless url-queue-progress-timer
99 (setq url-queue-progress-timer
100 (run-with-idle-timer 1 1 #'url-queue-check-progress))))))
94 101
95(defun url-queue-run-queue () 102(defun url-queue-run-queue ()
96 (url-queue-prune-old-entries) 103 (url-queue-prune-old-entries)
@@ -107,6 +114,13 @@ The variable `url-queue-timeout' sets a timeout."
107 (setf (url-queue-start-time waiting) (float-time)) 114 (setf (url-queue-start-time waiting) (float-time))
108 (url-queue-start-retrieve waiting)))) 115 (url-queue-start-retrieve waiting))))
109 116
117(defun url-queue-check-progress ()
118 (when url-queue-progress-timer
119 (if url-queue
120 (url-queue-run-queue)
121 (cancel-timer url-queue-progress-timer)
122 (setq url-queue-progress-timer nil))))
123
110(defun url-queue-callback-function (status job) 124(defun url-queue-callback-function (status job)
111 (setq url-queue (delq job url-queue)) 125 (setq url-queue (delq job url-queue))
112 (when (and (eq (car status) :error) 126 (when (and (eq (car status) :error)