Skip to content

Commit

Permalink
Fixed Ticket#29: undefined method `get_node' for nil:NilClass.
Browse files Browse the repository at this point in the history
Call RequestName asynchronously so that we can dispatch method calls
that arrive before the reply for RequestName. That happens when the
service is activated by the DBus daemon.

https://trac.luon.net/ruby-dbus/ticket/29
  • Loading branch information
mvidner committed Jan 24, 2010
1 parent 9e5a782 commit 19ebcb4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/dbus/bus.rb
Expand Up @@ -394,9 +394,17 @@ class NameRequestError < Exception
end

# Attempt to request a service _name_.
#
# FIXME, NameRequestError cannot really be rescued as it will be raised
# when dispatching a later call. Rework the API to better match the spec.
def request_service(name)
r = proxy.RequestName(name, NAME_FLAG_REPLACE_EXISTING)
raise NameRequestError if r[0] != REQUEST_NAME_REPLY_PRIMARY_OWNER
# Use RequestName, but asynchronously!
# A synchronous call would not work with service activation, where
# method calls to be serviced arrive before the reply for RequestName
# (Ticket#29).
proxy.RequestName(name, NAME_FLAG_REPLACE_EXISTING) do |rmsg, r|
raise NameRequestError if r != REQUEST_NAME_REPLY_PRIMARY_OWNER
end
@service = Service.new(name, self)
@service
end
Expand Down

0 comments on commit 19ebcb4

Please sign in to comment.