<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<pre>I was trying to receive a reply from a method call I made using dbus_pending_call_steal_reply but the thing is it tells me I'm trying to use an incorrect argument during runtime.</pre>
<pre>This is the code I was using:</pre>
<pre>#include <stdio.h>
#include <dbus/dbus.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
DBusError err;
DBusConnection *con;
DBusMessage *msg;
DBusMessage *reply;
DBusPendingCall *pending;
dbus_error_init(&err);
con = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
if (dbus_error_is_set(&err)) {
fprintf(stderr, "ERROR: %s\n", err.message);
dbus_error_free(&err);
exit(EXIT_FAILURE);
}
msg = dbus_message_new_method_call("org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "GetUnit");
const char *msg_arg1 = "cron.service";
dbus_message_append_args(msg,
DBUS_TYPE_STRING, &msg_arg1,
DBUS_TYPE_INVALID);
dbus_connection_send_with_reply(con, msg, &pending, DBUS_TIMEOUT_USE_DEFAULT);
for (;;) {
if ((reply = dbus_pending_call_steal_reply(pending)) == NULL)
continue;
else
break;
}
return EXIT_SUCCESS;
}
And the error was:
dbus[6959]: arguments to dbus_pending_call_steal_reply() were incorrect, assertion "pending->completed" failed in file ../../../dbus/dbus-pending-call.c line 734.
This is normally a bug in some application using the D-Bus library.
D-Bus not built with -rdynamic so unable to print a backtrace
Aborted
If instead of that for loop I call dbus_pending_call_block() and then steal the reply it works fine.
According to <a class="moz-txt-link-freetext" href="https://dbus.freedesktop.org/doc/api/html/group__DBusPendingCall.html#ga5a738928c2369fef093ce00658903d06">https://dbus.freedesktop.org/doc/api/html/group__DBusPendingCall.html#ga5a738928c2369fef093ce00658903d06</a> dbus_pending_call_steal_reply should return NULL if the reply isn't there yet, so I don't know, is this a bug with that function or was I doing something wrong?
</pre>
</body>
</html>