Subject: bug#4239: 23.1.50; Pause during Emacs startup with recentf-mode

From: Michael Albinus <[email-masked]>
Date: Mon, 24 Aug 2009 12:22:31 +0200

Stephen Berman <[email-masked]> writes:

>> Could you, please, start Emacs from gdb? When it is stalled, interrupt
>> it, and show the backtrace.
>
> Here it is; I hope it helps shed some light on the problem.

It does, indeed:

> Lisp Backtrace:
> "dbus-call-method" (0xbfffc504)
> "byte-code" (0xbfffc5b0)
> "dbus-ping" (0xbfffc844)

So for whatever reasons, one of the three dbus-ping calls in
tramp-gvfs.el hangs (for the default 25 sec timeout of D-Bus calls).

Could you, please, check the following patch? It restricts every
dbus-ping to 0.1 sec. It will still leave a short delay for you, but
this might be tolerable.

Best regards, Michael.

*** /home_local/emacs/lisp/net/dbus.el.~1~	2009-08-21 10:35:54.000000000 +0200
--- /home_local/emacs/lisp/net/dbus.el	2009-08-24 12:04:29.000000000 +0200
***************
*** 493,505 ****
       bus dbus-service-dbus dbus-path-dbus
       dbus-interface-dbus "GetNameOwner" service)))
  
! (defun dbus-ping (bus service)
!   "Check whether SERVICE is registered for D-Bus BUS."
    ;; "Ping" raises a D-Bus error if SERVICE does not exist.
    ;; Otherwise, it returns silently with `nil'.
    (condition-case nil
        (not
!        (dbus-call-method bus service dbus-path-dbus dbus-interface-peer "Ping"))
      (dbus-error nil)))
  
  
--- 493,512 ----
       bus dbus-service-dbus dbus-path-dbus
       dbus-interface-dbus "GetNameOwner" service)))
  
! (defun dbus-ping (bus service &optional timeout)
!   "Check whether SERVICE is registered for D-Bus BUS.
! TIMEOUT, an nonnegative integer, specifies the maximum number of
! milliseconds `dbus-ping' must return.  The default value is 25.000."
    ;; "Ping" raises a D-Bus error if SERVICE does not exist.
    ;; Otherwise, it returns silently with `nil'.
    (condition-case nil
        (not
!        (if (natnump timeout)
! 	   (dbus-call-method
! 	    bus service dbus-path-dbus dbus-interface-peer
! 	    "Ping" :timeout timeout)
! 	 (dbus-call-method
! 	  bus service dbus-path-dbus dbus-interface-peer "Ping")))
      (dbus-error nil)))
  
  
*** /home_local/emacs/lisp/net/tramp-gvfs.el.~1~	2009-08-04 13:02:56.000000000 +0200
--- /home_local/emacs/lisp/net/tramp-gvfs.el	2009-08-24 12:05:39.000000000 +0200
***************
*** 144,150 ****
    "The well known name of the GVFS daemon.")
  
  ;; Check that GVFS is available.
! (unless (dbus-ping :session tramp-gvfs-service-daemon)
    (throw 'tramp-loading nil))
  
  (defconst tramp-gvfs-path-mounttracker "/org/gtk/vfs/mounttracker"
--- 144,150 ----
    "The well known name of the GVFS daemon.")
  
  ;; Check that GVFS is available.
! (unless (dbus-ping :session tramp-gvfs-service-daemon 100)
    (throw 'tramp-loading nil))
  
  (defconst tramp-gvfs-path-mounttracker "/org/gtk/vfs/mounttracker"
***************
*** 1177,1183 ****
     (tramp-bluez-list-devices)))
  
  ;; Add completion function for OBEX method.
! (when (dbus-ping :system tramp-bluez-service)
    (tramp-set-completion-function
     "obex" '((tramp-bluez-parse-device-names ""))))
  
--- 1177,1183 ----
     (tramp-bluez-list-devices)))
  
  ;; Add completion function for OBEX method.
! (when (dbus-ping :system tramp-bluez-service 100)
    (tramp-set-completion-function
     "obex" '((tramp-bluez-parse-device-names ""))))
  
***************
*** 1210,1216 ****
     (zeroconf-list-services "_webdav._tcp")))
  
  ;; Add completion function for DAV and DAVS methods.
! (when (dbus-ping :system zeroconf-service-avahi)
    (zeroconf-init tramp-gvfs-zeroconf-domain)
    (tramp-set-completion-function
     "sftp" '((tramp-zeroconf-parse-workstation-device-names "")))
--- 1210,1216 ----
     (zeroconf-list-services "_webdav._tcp")))
  
  ;; Add completion function for DAV and DAVS methods.
! (when (dbus-ping :system zeroconf-service-avahi 100)
    (zeroconf-init tramp-gvfs-zeroconf-domain)
    (tramp-set-completion-function
     "sftp" '((tramp-zeroconf-parse-workstation-device-names "")))