diff options
| author | Daniel Colascione | 2014-02-17 03:41:42 -0800 |
|---|---|---|
| committer | Daniel Colascione | 2014-02-17 03:41:42 -0800 |
| commit | 26ea164c7e18b893a661eea9436338cbbab557e1 (patch) | |
| tree | cedf0cf671daf4f9916d6fe253763c1a494d6f86 | |
| parent | 2830e9b6b957642be4b6ac65e99620bac1fd4960 (diff) | |
| download | emacs-26ea164c7e18b893a661eea9436338cbbab557e1.tar.gz emacs-26ea164c7e18b893a661eea9436338cbbab557e1.zip | |
Improve dbus performance on synchronous calls
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/net/dbus.el | 19 |
2 files changed, 20 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7783f7fc424..7bea4f37278 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-02-17 Daniel Colascione <dancol@dancol.org> | ||
| 2 | |||
| 3 | * net/dbus.el (dbus-call-method): Work around bug#16775 by having | ||
| 4 | dbus-call-method check for completion using a busy-wait loop with | ||
| 5 | gradual backoff. | ||
| 6 | |||
| 1 | 2013-10-02 Michael Albinus <michael.albinus@gmx.de> | 7 | 2013-10-02 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 8 | ||
| 3 | Sync with Tramp 2.2.9. | 9 | Sync with Tramp 2.2.9. |
diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index 032315c363c..6214505ad86 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el | |||
| @@ -260,6 +260,7 @@ object is returned instead of a list containing this single Lisp object. | |||
| 260 | (signal 'wrong-type-argument (list 'stringp method))) | 260 | (signal 'wrong-type-argument (list 'stringp method))) |
| 261 | 261 | ||
| 262 | (let ((timeout (plist-get args :timeout)) | 262 | (let ((timeout (plist-get args :timeout)) |
| 263 | (check-interval 0.001) | ||
| 263 | (key | 264 | (key |
| 264 | (apply | 265 | (apply |
| 265 | 'dbus-message-internal dbus-message-type-method-call | 266 | 'dbus-message-internal dbus-message-type-method-call |
| @@ -270,13 +271,21 @@ object is returned instead of a list containing this single Lisp object. | |||
| 270 | ;; default 25". Events which are not from D-Bus must be restored. | 271 | ;; default 25". Events which are not from D-Bus must be restored. |
| 271 | ;; `read-event' performs a redisplay. This must be suppressed; it | 272 | ;; `read-event' performs a redisplay. This must be suppressed; it |
| 272 | ;; hurts when reading D-Bus events asynchronously. | 273 | ;; hurts when reading D-Bus events asynchronously. |
| 274 | |||
| 275 | ;; Work around bug#16775 by busy-waiting with gradual backoff for | ||
| 276 | ;; dbus calls to complete. A better aproach would involve either | ||
| 277 | ;; adding arbitrary wait condition support to read-event or | ||
| 278 | ;; restructuring dbus as a kind of process object. Poll at most | ||
| 279 | ;; about once per second for completion. | ||
| 280 | |||
| 273 | (with-timeout ((if timeout (/ timeout 1000.0) 25)) | 281 | (with-timeout ((if timeout (/ timeout 1000.0) 25)) |
| 274 | (while (eq (gethash key dbus-return-values-table :ignore) :ignore) | 282 | (while (eq (gethash key dbus-return-values-table :ignore) :ignore) |
| 275 | (let ((event (let ((inhibit-redisplay t) unread-command-events) | 283 | (let ((event (let ((inhibit-redisplay t) unread-command-events) |
| 276 | (read-event nil nil 0.1)))) | 284 | (read-event nil nil check-interval)))) |
| 277 | (when (and event (not (ignore-errors (dbus-check-event event)))) | 285 | (when event |
| 278 | (setq unread-command-events | 286 | (push event unread-command-events)) |
| 279 | (append unread-command-events (list event))))))) | 287 | (when (< check-interval 1) |
| 288 | (setf check-interval (* check-interval 1.05)))))) | ||
| 280 | 289 | ||
| 281 | ;; Cleanup `dbus-return-values-table'. Return the result. | 290 | ;; Cleanup `dbus-return-values-table'. Return the result. |
| 282 | (prog1 | 291 | (prog1 |