Skip to content

Commit

Permalink
Merge pull request #906 from zeenix/non-existant-method
Browse files Browse the repository at this point in the history
🚑️ zb: Handle non-existent method calls correctly
  • Loading branch information
zeenix authored Jul 18, 2024
2 parents 6b1b923 + 9283fc6 commit 8e3d2b3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 11 additions & 1 deletion zbus/src/object_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,19 @@ impl ObjectServer {
async move {
let server = connection.object_server();
let hdr = msg.header();
server
if let Err(e) = server
.dispatch_call_to_iface(iface, &connection, &msg, &hdr)
.await
{
// When not spawning a task, this error is handled by the caller.
debug!("Returning error: {}", e);
if let Err(e) = connection.reply_dbus_error(&hdr, e).await {
debug!(
"Error dispatching message. Message: {:?}, error: {:?}",
msg, e
);
}
}
}
.instrument(trace_span!("{}", task_name)),
&task_name,
Expand Down
10 changes: 10 additions & 0 deletions zbus/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,16 @@ async fn my_iface_test(conn: Connection, event: Event) -> zbus::Result<u32> {
.build()
.await?;
debug!("Created: {:?}", proxy);

// First let's call a non-existent method. It should immediately fail.
// There was a regression where object server would just not reply in this case:
// https://github.com/dbus2/zbus/issues/905
assert!(proxy
.inner()
.call::<_, _, ()>("NonExistantMethod", &())
.await
.is_err());

let props_proxy = zbus::fdo::PropertiesProxy::builder(&conn)
.destination("org.freedesktop.MyService")?
.path("/org/freedesktop/MyService")?
Expand Down

0 comments on commit 8e3d2b3

Please sign in to comment.