Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property method invoked with surprising object path #70

Closed
mulkieran opened this issue Jan 20, 2017 · 4 comments
Closed

Property method invoked with surprising object path #70

mulkieran opened this issue Jan 20, 2017 · 4 comments

Comments

@mulkieran
Copy link
Contributor

mulkieran commented Jan 20, 2017

This occurs when I invoke GetManagedObjects.

I have a property defined for an interface called Pool.
As the properties are being listed a method belonging to the Pool interface is invoked. It extracts the object path, but that object path is the object path that was used to call GetManagedObjects originally, and it is not an object path for an object that implements the Pool interface. This causes an error in my method as this situation is unexpected.

Obtaining the value of the property on an object path that does implement the Pool interface works fine.

Running dbus-0.4.1.

@diwic
Copy link
Owner

diwic commented Jan 20, 2017

Sorry, not sure I follow:

As the properties are being listed a method belonging to the Pool interface is invoked.

Exactly how is that method invoked? Calling GetManagedObjects should just list properties, not invoke (other) methods.

@mulkieran
Copy link
Contributor Author

The property is implemented by means of a method:

    let uuid_property = f.property::<&str, _>("Uuid", ())
        .access(Access::Read)
        .emits_changed(EmitsChangedSignal::Const)
        .on_get(get_pool_uuid);

and

let object_path = f.object_path(object_name, dbus_context.clone())
        .introspectable()
        .add(f.interface(interface_name, ())
            .add_m(create_filesystems_method)
            .add_m(destroy_filesystems_method)
            .add_m(add_cache_devs_method)
            .add_m(remove_cache_devs_method)
            .add_m(add_devs_method)
            .add_m(remove_devs_method)
            .add_m(rename_method)
            .add_p(name_property)
            .add_p(uuid_property));

and

fn get_pool_uuid(i: &mut IterAppend, p: &PropInfo<MTFn<TData>, TData>) -> Result<(), MethodErr> {
    let dbus_context = p.path.get_data();
    let object_path = p.path.get_name();
    let pools = dbus_context.pools.borrow();
    let name = try!(pools.get_by_first(object_path as &str)
        .ok_or(MethodErr::failed(&format!("no name for pool with object path {}", object_path))));
...

Currently the MethodError above is emitted when GetManagedObjects() is called, but not when the property is obtained directly from the pool.

The sequence below is:

  1. Call GetManagedObjects() with success.
  2. Create a Pool object.
  3. Call GetManagedObjects() with failure.
  4. Get the property directly from the pool with success.
[mulhern@dhcp-25-209 stratisd]$ busctl --user call org.storage.stratis1 /org/storage/stratis1 org.freedesktop.DBus.ObjectManager GetManagedObjects
a{oa{sa{sv}}} 1 "/org/storage/stratis1" 4 "org.freedesktop.DBus.Introspectable" 0 "org.freedesktop.DBus.ObjectManager" 0 "org.freedesktop.DBus.Properties" 0 "org.storage.stratis1.Manager" 3 "ErrorValues" a(sq) 17 "OK" 0 "ERROR" 1 "ALREADY_EXISTS" 2 "BAD_PARAM" 3 "BUSY" 4 "CACHE_NOTFOUND" 5 "DEV_NOTFOUND" 6 "FILESYSTEM_NOTFOUND" 7 "IO_ERROR" 8 "LIST_FAILURE" 9 "INTERNAL_ERROR" 10 "NIX_ERROR" 11 "NO_POOLS" 12 "NOTFOUND" 13 "NULL" 14 "NULL_NAME" 15 "POOL_NOTFOUND" 16 "RedundancyValues" a(sq) 1 "NONE" 0 "Version" s "0.1.0"
[mulhern@dhcp-25-209 stratisd]$ busctl --user call org.storage.stratis1 /org/storage/stratis1 org.storage.stratis1.Manager CreatePool "s(bq)bas" "deadpool" false 0 false 1 /dev/sdl
(oas)qs "/org/storage/stratis1/1" 1 "/dev/sdl"0 "Ok"
[mulhern@dhcp-25-209 stratisd]$ busctl --user call org.storage.stratis1 /org/storage/stratis1 org.freedesktop.DBus.ObjectManager GetManagedObjects
no name for pool with object path /org/storage/stratis1
[mulhern@dhcp-25-209 stratisd]$ busctl --user get-property org.storage.stratis1 /org/storage/stratis1/1 org.storage.stratis1.pool Uuid
s "2c19bce95dbf4b40b10212e408629af0

@diwic
Copy link
Owner

diwic commented Jan 20, 2017

Thanks, now I get it. I just pushed a commit to master, could you see if it fixes the issue?

@diwic diwic closed this as completed in 0d63f10 Jan 20, 2017
mulkieran added a commit to mulkieran/stratisd that referenced this issue Jan 20, 2017
diwic/dbus-rs#70

Fixed by dbus-rs commit: 0d63f1083765f2da9bb93de017b1f53f88ab281d

Signed-off-by: mulhern <amulhern@redhat.com>
@mulkieran
Copy link
Contributor Author

Confirmed, thanks!

mulkieran added a commit to mulkieran/stratisd that referenced this issue Jan 20, 2017
diwic/dbus-rs#70

Fixed by dbus-rs commit: 0d63f1083765f2da9bb93de017b1f53f88ab281d

Signed-off-by: mulhern <amulhern@redhat.com>
mulkieran added a commit to mulkieran/stratisd that referenced this issue Jan 20, 2017
diwic/dbus-rs#70

Fixed by dbus-rs commit: 0d63f1083765f2da9bb93de017b1f53f88ab281d

Signed-off-by: mulhern <amulhern@redhat.com>
mulkieran added a commit to mulkieran/stratisd that referenced this issue Jan 20, 2017
diwic/dbus-rs#70

Fixed by dbus-rs commit: 0d63f1083765f2da9bb93de017b1f53f88ab281d

Signed-off-by: mulhern <amulhern@redhat.com>
mulkieran added a commit to mulkieran/stratisd that referenced this issue Jan 20, 2017
diwic/dbus-rs#70

Fixed by dbus-rs commit: 0d63f1083765f2da9bb93de017b1f53f88ab281d

Signed-off-by: mulhern <amulhern@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants