chiark / gitweb /
sd-bus: sync kdbus.h (API change: switch to absolute timeouts)
authorDaniel Mack <daniel@zonque.org>
Tue, 21 Oct 2014 20:14:03 +0000 (22:14 +0200)
committerDaniel Mack <daniel@zonque.org>
Tue, 21 Oct 2014 20:14:03 +0000 (22:14 +0200)
kdbus_msg.timeout_ns now takes an absolute value, based on CLOCK_MONOTONIC,
in order to eventually support automatically restarted syscalls.

Signed-off-by: Daniel Mack <daniel@zonque.org>
src/libsystemd/sd-bus/bus-kernel.c
src/libsystemd/sd-bus/kdbus.h

index 6b5a3d3..136c90f 100644 (file)
@@ -270,10 +270,20 @@ static int bus_message_setup_kmsg(sd_bus *b, sd_bus_message *m) {
         m->kdbus->cookie = (uint64_t) m->header->serial;
         m->kdbus->priority = m->priority;
 
-        if (m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
+        if (m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) {
                 m->kdbus->cookie_reply = m->reply_cookie;
-        else
-                m->kdbus->timeout_ns = m->timeout * NSEC_PER_USEC;
+        } else {
+                struct timespec now;
+
+                r = clock_gettime(CLOCK_MONOTONIC_COARSE, &now);
+                if (r < 0) {
+                        r = -errno;
+                        goto fail;
+                }
+
+                m->kdbus->timeout_ns = now.tv_sec * NSEC_PER_SEC + now.tv_nsec +
+                                       m->timeout * NSEC_PER_USEC;
+        }
 
         d = m->kdbus->items;
 
index 087d50a..50b4ec4 100644 (file)
@@ -384,7 +384,8 @@ enum kdbus_payload_type {
  * @timeout_ns:                The time to wait for a message reply from the peer.
  *                     If there is no reply, a kernel-generated message
  *                     with an attached KDBUS_ITEM_REPLY_TIMEOUT item
- *                     is sent to @src_id.
+ *                     is sent to @src_id. The timeout is expected in
+ *                     nanoseconds and as absolute CLOCK_MONOTONIC value.
  * @cookie_reply:      A reply to the requesting message with the same
  *                     cookie. The requesting connection can match its
  *                     request and the reply with this value