Bug with dbus_pending_call_steal_reply?
bitfxed
bitfxed at disroot.org
Fri Aug 18 02:10:17 UTC 2023
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.
This is the code I was using:
#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 tohttps://dbus.freedesktop.org/doc/api/html/group__DBusPendingCall.html#ga5a738928c2369fef093ce00658903d06 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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dbus/attachments/20230818/c2c4c076/attachment.htm>
More information about the dbus
mailing list