[systemd-commits] 3 commits - src/libsystemd src/systemd

Lennart Poettering lennart at kemper.freedesktop.org
Wed Jan 22 02:26:44 PST 2014


 src/libsystemd/libsystemd.sym           |    9 +++++----
 src/libsystemd/sd-bus/bus-dump.c        |    4 +++-
 src/libsystemd/sd-bus/bus-kernel.c      |    1 +
 src/libsystemd/sd-bus/bus-message.c     |   23 +++++++++++++++++++----
 src/libsystemd/sd-bus/bus-message.h     |    1 +
 src/libsystemd/sd-bus/sd-bus.c          |    4 ++--
 src/libsystemd/sd-bus/test-bus-kernel.c |    8 ++++----
 src/systemd/sd-bus.h                    |   10 ++++++----
 8 files changed, 41 insertions(+), 19 deletions(-)

New commits:
commit 1fedcf59e0959b5e20bcd5a0ee9073e1185af315
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 22 11:25:39 2014 +0100

    bus: rename sd_bus_get_realtime_timestamp() to sd_bus_get_realtime_usec()
    
    This brings the calls into similar style as the respective functions in
    libsystemd-journal, and also is a bi shorter and more descriptive since
    it clarifies the time unit used.

diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym
index bb3c1ab..951166a 100644
--- a/src/libsystemd/libsystemd.sym
+++ b/src/libsystemd/libsystemd.sym
@@ -92,8 +92,8 @@ global:
         sd_bus_message_get_sender;
         sd_bus_message_get_error;
         sd_bus_message_get_errno;
-        sd_bus_message_get_monotonic_timestamp;
-        sd_bus_message_get_realtime_timestamp;
+        sd_bus_message_get_monotonic_usec;
+        sd_bus_message_get_realtime_usec;
         sd_bus_message_get_seqnum;
         sd_bus_message_get_creds;
         sd_bus_message_is_signal;
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 0c3913e..2c25b3f 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -880,19 +880,23 @@ _public_ const sd_bus_error *sd_bus_message_get_error(sd_bus_message *m) {
         return &m->error;
 }
 
-_public_ int sd_bus_message_get_monotonic_timestamp(sd_bus_message *m, uint64_t *usec) {
+_public_ int sd_bus_message_get_monotonic_usec(sd_bus_message *m, uint64_t *usec) {
         assert_return(m, -EINVAL);
         assert_return(usec, -EINVAL);
-        assert_return(m->monotonic > 0, -ENODATA);
+
+        if (m->monotonic <= 0)
+                return -ENODATA;
 
         *usec = m->monotonic;
         return 0;
 }
 
-_public_ int sd_bus_message_get_realtime_timestamp(sd_bus_message *m, uint64_t *usec) {
+_public_ int sd_bus_message_get_realtime_usec(sd_bus_message *m, uint64_t *usec) {
         assert_return(m, -EINVAL);
         assert_return(usec, -EINVAL);
-        assert_return(m->realtime > 0, -ENODATA);
+
+        if (m->realtime <= 0)
+                return -ENODATA;
 
         *usec = m->realtime;
         return 0;
@@ -901,7 +905,9 @@ _public_ int sd_bus_message_get_realtime_timestamp(sd_bus_message *m, uint64_t *
 _public_ int sd_bus_message_get_seqnum(sd_bus_message *m, uint64_t *seqnum) {
         assert_return(m, -EINVAL);
         assert_return(seqnum, -EINVAL);
-        assert_return(m->seqnum > 0, -ENODATA);
+
+        if (m->seqnum <= 0)
+                return -ENODATA;
 
         *seqnum = m->seqnum;
         return 0;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 52627f6..4e6c321 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -200,8 +200,8 @@ const char *sd_bus_message_get_sender(sd_bus_message *m);
 const sd_bus_error *sd_bus_message_get_error(sd_bus_message *m);
 int sd_bus_message_get_errno(sd_bus_message *m);
 
-int sd_bus_message_get_monotonic_timestamp(sd_bus_message *m, uint64_t *usec);
-int sd_bus_message_get_realtime_timestamp(sd_bus_message *m, uint64_t *usec);
+int sd_bus_message_get_monotonic_usec(sd_bus_message *m, uint64_t *usec);
+int sd_bus_message_get_realtime_usec(sd_bus_message *m, uint64_t *usec);
 int sd_bus_message_get_seqnum(sd_bus_message *m, uint64_t* seqnum);
 
 sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m); /* do not unref the result */

commit 4fc319887efb4c68ec5a308d583a94510382f686
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 22 11:21:51 2014 +0100

    bus: simplify naming of feature negotation calls
    
    Two verbs in a function name suck, so let's simplify this a bit.

diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym
index 723546a..bb3c1ab 100644
--- a/src/libsystemd/libsystemd.sym
+++ b/src/libsystemd/libsystemd.sym
@@ -27,8 +27,8 @@ global:
         sd_bus_set_anonymous;
         sd_bus_set_trusted;
         sd_bus_negotiate_fds;
-        sd_bus_negotiate_attach_timestamp;
-        sd_bus_negotiate_attach_creds;
+        sd_bus_negotiate_timestamp;
+        sd_bus_negotiate_creds;
         sd_bus_start;
         sd_bus_close;
         sd_bus_try_close;
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 2c458f3..edea7c0 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -284,7 +284,7 @@ _public_ int sd_bus_negotiate_fds(sd_bus *bus, int b) {
         return 0;
 }
 
-_public_ int sd_bus_negotiate_attach_timestamp(sd_bus *bus, int b) {
+_public_ int sd_bus_negotiate_timestamp(sd_bus *bus, int b) {
         assert_return(bus, -EINVAL);
         assert_return(bus->state == BUS_UNSET, -EPERM);
         assert_return(!bus_pid_changed(bus), -ECHILD);
@@ -293,7 +293,7 @@ _public_ int sd_bus_negotiate_attach_timestamp(sd_bus *bus, int b) {
         return 0;
 }
 
-_public_ int sd_bus_negotiate_attach_creds(sd_bus *bus, uint64_t mask) {
+_public_ int sd_bus_negotiate_creds(sd_bus *bus, uint64_t mask) {
         assert_return(bus, -EINVAL);
         assert_return(mask <= _SD_BUS_CREDS_ALL, -EINVAL);
         assert_return(bus->state == BUS_UNSET, -EPERM);
diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c
index 9b17a35..3dcc5d3 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel.c
@@ -65,11 +65,11 @@ int main(int argc, char *argv[]) {
         r = sd_bus_set_address(b, address);
         assert_se(r >= 0);
 
-        assert_se(sd_bus_negotiate_attach_timestamp(a, 1) >= 0);
-        assert_se(sd_bus_negotiate_attach_creds(a, _SD_BUS_CREDS_ALL) >= 0);
+        assert_se(sd_bus_negotiate_timestamp(a, 1) >= 0);
+        assert_se(sd_bus_negotiate_creds(a, _SD_BUS_CREDS_ALL) >= 0);
 
-        assert_se(sd_bus_negotiate_attach_timestamp(b, 1) >= 0);
-        assert_se(sd_bus_negotiate_attach_creds(b, _SD_BUS_CREDS_ALL) >= 0);
+        assert_se(sd_bus_negotiate_timestamp(b, 1) >= 0);
+        assert_se(sd_bus_negotiate_creds(b, _SD_BUS_CREDS_ALL) >= 0);
 
         r = sd_bus_start(a);
         assert_se(r >= 0);
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index fc9a809..52627f6 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -111,8 +111,8 @@ int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id);
 int sd_bus_set_anonymous(sd_bus *bus, int b);
 int sd_bus_set_trusted(sd_bus *bus, int b);
 int sd_bus_negotiate_fds(sd_bus *bus, int b);
-int sd_bus_negotiate_attach_timestamp(sd_bus *bus, int b);
-int sd_bus_negotiate_attach_creds(sd_bus *bus, uint64_t creds_mask);
+int sd_bus_negotiate_timestamp(sd_bus *bus, int b);
+int sd_bus_negotiate_creds(sd_bus *bus, uint64_t creds_mask);
 int sd_bus_start(sd_bus *ret);
 
 int sd_bus_try_close(sd_bus *bus);

commit 6a0e376c1cd303ff09777e5d18f070fe43e6b915
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 22 10:57:12 2014 +0100

    bus: add API for querying the kdbus message sequence number

diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym
index cda10ea..723546a 100644
--- a/src/libsystemd/libsystemd.sym
+++ b/src/libsystemd/libsystemd.sym
@@ -94,6 +94,7 @@ global:
         sd_bus_message_get_errno;
         sd_bus_message_get_monotonic_timestamp;
         sd_bus_message_get_realtime_timestamp;
+        sd_bus_message_get_seqnum;
         sd_bus_message_get_creds;
         sd_bus_message_is_signal;
         sd_bus_message_is_method_call;
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index 78e7597..d2c0684 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -100,8 +100,10 @@ int bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) {
                         fprintf(f, "  Monotonic=%llu", (unsigned long long) m->monotonic);
                 if (m->realtime != 0)
                         fprintf(f, "  Realtime=%llu", (unsigned long long) m->realtime);
+                if (m->seqnum != 0)
+                        fprintf(f, "  SequenceNumber=%llu", (unsigned long long) m->seqnum);
 
-                if (m->monotonic != 0 || m->realtime != 0)
+                if (m->monotonic != 0 || m->realtime != 0 || m->seqnum != 0)
                         fputs("\n", f);
 
                 bus_creds_dump(&m->creds, f);
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 99ac5b1..fdb4dab 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -501,6 +501,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
                 case KDBUS_ITEM_TIMESTAMP:
                         m->realtime = d->timestamp.realtime_ns / NSEC_PER_USEC;
                         m->monotonic = d->timestamp.monotonic_ns / NSEC_PER_USEC;
+                        m->seqnum = d->timestamp.seqnum;
                         break;
 
                 case KDBUS_ITEM_PID_COMM:
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 1a2039b..0c3913e 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -898,6 +898,15 @@ _public_ int sd_bus_message_get_realtime_timestamp(sd_bus_message *m, uint64_t *
         return 0;
 }
 
+_public_ int sd_bus_message_get_seqnum(sd_bus_message *m, uint64_t *seqnum) {
+        assert_return(m, -EINVAL);
+        assert_return(seqnum, -EINVAL);
+        assert_return(m->seqnum > 0, -ENODATA);
+
+        *seqnum = m->seqnum;
+        return 0;
+}
+
 _public_ sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m) {
         assert_return(m, NULL);
 
diff --git a/src/libsystemd/sd-bus/bus-message.h b/src/libsystemd/sd-bus/bus-message.h
index 5322375..0c90e72 100644
--- a/src/libsystemd/sd-bus/bus-message.h
+++ b/src/libsystemd/sd-bus/bus-message.h
@@ -98,6 +98,7 @@ struct sd_bus_message {
 
         usec_t monotonic;
         usec_t realtime;
+        uint64_t seqnum;
 
         bool sealed:1;
         bool dont_send:1;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index a6c29d4..fc9a809 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -202,6 +202,8 @@ int sd_bus_message_get_errno(sd_bus_message *m);
 
 int sd_bus_message_get_monotonic_timestamp(sd_bus_message *m, uint64_t *usec);
 int sd_bus_message_get_realtime_timestamp(sd_bus_message *m, uint64_t *usec);
+int sd_bus_message_get_seqnum(sd_bus_message *m, uint64_t* seqnum);
+
 sd_bus_creds *sd_bus_message_get_creds(sd_bus_message *m); /* do not unref the result */
 
 int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member);



More information about the systemd-commits mailing list