From 5621e22e298cfb94075cde173809a78a3bcda7aa Mon Sep 17 00:00:00 2001 From: Adam Michalski Date: Thu, 17 Feb 2022 19:18:24 +0100 Subject: [PATCH] gdbus, p2p-gdbus: Replace asynchronous flushing function calls with their synchronous counterparts More in-depth tests have shown that synchronous connection flushing produces more predictable results under heavy load. Moreover, it seems to be the only way to ensure stable and predictable execution flow, where under heavy load the server can become starved even for a few seconds. Change-Id: Ia99618b83a3b9d86fd132554583e6d3250b099f9 --- benchmark/gdbus.c | 17 ++++++++--------- benchmark/p2p-gdbus.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/benchmark/gdbus.c b/benchmark/gdbus.c index 158027f..96b82ef 100644 --- a/benchmark/gdbus.c +++ b/benchmark/gdbus.c @@ -212,7 +212,6 @@ void Send(register int size, const char *name, const char *path, bool is_lt) else start = 0; - //GError *error = NULL; g_dbus_connection_call(conn, name, path, @@ -225,14 +224,14 @@ void Send(register int size, const char *name, const char *path, bool is_lt) NULL, NULL, NULL); - /*if(error != NULL) { - g_printerr("Error=%s\n", error->message); - g_error_free (error); - }*/ - g_dbus_connection_flush(conn, - NULL, /* GCancellable */ - NULL, /* GAsyncReadyCallback */ - NULL); /* user_data */ + GError *error = NULL; + g_dbus_connection_flush_sync(conn, + NULL, + &error); + if (error != NULL) { + g_printerr("Error=%s\n", error->message); + g_error_free (error); + } if(is_lt) { if(size <= ONE_PAGE_SIZE) usleep(5000); diff --git a/benchmark/p2p-gdbus.c b/benchmark/p2p-gdbus.c index 407a3d7..3269e3b 100644 --- a/benchmark/p2p-gdbus.c +++ b/benchmark/p2p-gdbus.c @@ -396,10 +396,14 @@ 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 */ + GError *error = NULL; + g_dbus_connection_flush_sync(connection, + NULL, + &error); + if (error != NULL) { + g_printerr("Error=%s\n", error->message); + g_error_free (error); + } if (is_lt) { if (size <= ONE_PAGE_SIZE) usleep(5000); -- 2.34.1