From 300a6db75f8074a935ca6665478f1ebf97a86e8d Mon Sep 17 00:00:00 2001 From: Adam Michalski Date: Thu, 3 Feb 2022 18:09:28 +0100 Subject: [PATCH] libdbus, gdbus, p2p-gdbus: Add flushing connection after send Added flushing connection, that writes all queued outgoing messages to the transport. Without flushing the connection, there is no guarantee that messages have been sent to the networking buffers in the kernel before the server sends the messages asynchronously and then exits immediately. It also prevents latencies from stacking during measurements under heavy load. Change-Id: I5383f0bb4e32c91542c887f2e55eb7bdd030d738 --- benchmark/gdbus.c | 4 ++++ benchmark/libdbus.c | 2 +- benchmark/p2p-gdbus.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/benchmark/gdbus.c b/benchmark/gdbus.c index 75dc701..f7de0ce 100644 --- a/benchmark/gdbus.c +++ b/benchmark/gdbus.c @@ -225,6 +225,10 @@ void Send(register int size, const char *name, const char *path, bool is_lt) g_printerr("Error=%s\n", error->message); g_error_free (error); }*/ + g_dbus_connection_flush(conn, + NULL, /* GCancellable */ + NULL, /* GAsyncReadyCallback */ + NULL); /* user_data */ if(is_lt) { if(size <= ONE_PAGE_SIZE) usleep(5000); diff --git a/benchmark/libdbus.c b/benchmark/libdbus.c index ec34c93..57dcbec 100644 --- a/benchmark/libdbus.c +++ b/benchmark/libdbus.c @@ -188,6 +188,7 @@ void Send(register int size, const char *name, const char *path, const char *cli DBUS_TYPE_INVALID); dbus_connection_send (conn, msg, NULL); dbus_message_unref(msg); + dbus_connection_flush(conn); if(is_lt) { if(size <= ONE_PAGE_SIZE) @@ -201,7 +202,6 @@ void Send(register int size, const char *name, const char *path, const char *cli } } - dbus_connection_flush(conn); free(cptr); } diff --git a/benchmark/p2p-gdbus.c b/benchmark/p2p-gdbus.c index 01d28ed..542382e 100644 --- a/benchmark/p2p-gdbus.c +++ b/benchmark/p2p-gdbus.c @@ -392,6 +392,10 @@ void Send(int size, const char *name, const char *path, const char *number, bool NULL, NULL, NULL); + g_dbus_connection_flush(connection, + NULL, /* GCancellable */ + NULL, /* GAsyncReadyCallback */ + NULL); /* user_data */ if (is_lt) { if (size <= ONE_PAGE_SIZE) usleep(5000); -- 2.34.1