summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/test-bus-chat.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-03-22 00:08:58 +0100
committerLennart Poettering <lennart@poettering.net>2013-03-22 00:12:37 +0100
commitb9bf7e2be93fe25e0e96e06ad436d43a1e589ed5 (patch)
tree25e4529b2d9ec6619ecd1858d2ff46cb1ecdff8f /src/libsystemd-bus/test-bus-chat.c
parent25220239990c7859a65160d63277105d0c1de8a8 (diff)
bus: implicitly handle peer commands Ping() and GetMachineId()
Diffstat (limited to 'src/libsystemd-bus/test-bus-chat.c')
-rw-r--r--src/libsystemd-bus/test-bus-chat.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/libsystemd-bus/test-bus-chat.c b/src/libsystemd-bus/test-bus-chat.c
index 9e14824186..d8677cc9e8 100644
--- a/src/libsystemd-bus/test-bus-chat.c
+++ b/src/libsystemd-bus/test-bus-chat.c
@@ -264,8 +264,9 @@ static void* client2(void*p) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
sd_bus *bus = NULL;
sd_bus_error error = SD_BUS_ERROR_INIT;
- int r;
bool quit = false;
+ const char *mid;
+ int r;
r = sd_bus_open_user(&bus);
if (r < 0) {
@@ -277,6 +278,35 @@ static void* client2(void*p) {
bus,
"org.freedesktop.systemd.test",
"/",
+ "org.freedesktop.DBus.Peer",
+ "GetMachineId",
+ &m);
+ if (r < 0) {
+ log_error("Failed to allocate method call: %s", strerror(-r));
+ goto finish;
+ }
+
+ r = sd_bus_send_with_reply_and_block(bus, m, 0, &error, &reply);
+ if (r < 0) {
+ log_error("Failed to issue method call: %s", bus_error_message(&error, -r));
+ goto finish;
+ }
+
+ r = sd_bus_message_read(reply, "s", &mid);
+ if (r < 0) {
+ log_error("Failed to parse machine ID: %s", strerror(-r));
+ goto finish;
+ }
+
+ log_info("Machine ID is %s.", mid);
+
+ sd_bus_message_unref(m);
+ m = NULL;
+
+ r = sd_bus_message_new_method_call(
+ bus,
+ "org.freedesktop.systemd.test",
+ "/",
"org.freedesktop.systemd.test",
"Slow",
&m);
@@ -285,6 +315,9 @@ static void* client2(void*p) {
goto finish;
}
+ sd_bus_message_unref(reply);
+ reply = NULL;
+
r = sd_bus_send_with_reply_and_block(bus, m, 200 * USEC_PER_MSEC, &error, &reply);
if (r < 0)
log_info("Failed to issue method call: %s", bus_error_message(&error, -r));