Subject: bug#43251: 27.1; DBus signals error when GetManagedObjects received while waiting for dbus-call-method

From: Hugh Daschbach <[email-masked]>
Date: Mon, 28 Sep 2020 16:36:19 -0700

Michael Albinus writes:

> Hugh Daschbach <[email-masked]> writes:
>
> Hi Hugh,
>
>> But if that GetManagedObjects method call is received while a
>> dbus-call-method request is waiting for a reply message, processing the
>> GetManagedObjects request signals an error.
>
> Thanks, I will investigate.

I believe this issue is fixed on master.  The attached test fails on
27.1 and does not fail on master.

Feel free to close.

Thanks,
Hugh

>From 51eabb23d839827beccad86ba3755d1fc32c20b3 Mon Sep 17 00:00:00 2001
From: Hugh Daschbach <[email-masked]>
Date: Mon, 28 Sep 2020 14:34:54 -0700
Subject: [PATCH 4/4] Add D-Bus method call reentry test.

* test/lisp/net/dbus-tests.el (dbus--tests-method-reentry-handler): New defun.
(dbus-test04-method-reentry): New test.
---
 test/lisp/net/dbus-tests.el | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/test/lisp/net/dbus-tests.el b/test/lisp/net/dbus-tests.el
index 308f22eb6cc..a4305b5942a 100644
--- a/test/lisp/net/dbus-tests.el
+++ b/test/lisp/net/dbus-tests.el
@@ -581,6 +581,39 @@ dbus-test04-register-method
     ;; Cleanup.
     (dbus-unregister-service :session dbus--test-service)))
 
+(defun dbus--test-method-reentry-handler (&rest args)
+  "Method handler for `dbus-test04-method-reentry'."
+  (dbus-get-all-managed-objects :session dbus--test-service dbus--test-path)
+  42)
+
+(ert-deftest dbus-test04-method-reentry ()
+  "Check receiving method call while awaiting response.
+Ensure that incoming method calls are handled when call to `dbus-call-method'
+is in progress."
+  (skip-unless dbus--test-enabled-session-bus)
+  (dbus-ignore-errors (dbus-unregister-service :session dbus--test-service))
+
+  (unwind-protect
+      (let ((method "Rentry"))
+        (should
+         (equal
+          (dbus-register-method
+           :session dbus--test-service dbus--test-path
+           dbus--test-interface method #'dbus--test-method-reentry-handler)
+          `((:method :session ,dbus--test-interface ,method)
+            (,dbus--test-service ,dbus--test-path
+             dbus--test-method-reentry-handler))))
+
+        (should
+         (=
+          (dbus-call-method
+           :session dbus--test-service dbus--test-path
+           dbus--test-interface method)
+          42)))
+
+    ;; Cleanup.
+    (dbus-unregister-service :session dbus--test-service)))
+
 (ert-deftest dbus-test04-call-method-timeout ()
   "Verify `dbus-call-method' request timeout."
   :tags '(:expensive-test)
-- 
2.28.0