Questions about g_dbus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm trying to do an implementation of rtkit make_realtime, using the
g_dbus API.

But I'm blocking on some issues I don't know how to solve.

I have attached a sample program. When I try to run it, I get:

./dbus 

** (process:16064): WARNING **: [::make_realtime] Failed to get
MaxRealtimePriority

** (process:16064): WARNING **: [::make_realtime] Failed to set realtime
scheduling using rtkit
(GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Operation not
permitted)

Why MaxRealtimePriority property is not returned ?

Why the dbus call returns 'Operation not permitted' (even as root) ?


Any ideas ?

	Thanks,

		Emmanuel.
#include <gio/gio.h>
#include <linux/sched.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <memory.h>
#include <errno.h>

gboolean
arv_make_realtime (void)
{
	struct sched_param p;

	memset (&p, 0, sizeof(p));
	p.sched_priority = 3;

	if (sched_setscheduler (0, SCHED_RR|SCHED_RESET_ON_FORK, &p) < 0 && errno == EPERM) {
		GDBusProxy *proxy;
		GVariant *answer;
		pid_t thread_id;
		GError *error = NULL;
		gint32 priority = p.sched_priority;

		thread_id = syscall(SYS_gettid);
		
		proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
						       G_DBUS_PROXY_FLAGS_NONE,
						       NULL,
						       "org.freedesktop.RealtimeKit1",
						       "/org/freedesktop/RealtimeKit1",
						       "org.freedesktop.RealtimeKit1",
						       NULL, &error);

		if (error != NULL) {
			g_warning ("[::make_realtime] Failed to create dbus proxy (%s)",
				   error->message);
			g_clear_pointer (&error, g_error_free);
		}

		answer = g_dbus_proxy_get_cached_property (proxy, "MaxRealtimePriority");

		if (answer == NULL) {
			g_warning ("[::make_realtime] Failed to get MaxRealtimePriority");
		} else {
			priority = g_variant_get_int32 (answer);
			g_variant_unref (answer);
		}

		answer = g_dbus_proxy_call_sync (proxy,
						 "MakeThreadRealtime",
						 g_variant_new ("(tu)", thread_id, priority),
						 G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);

		if (error != NULL) {
			g_warning ("[::make_realtime] Failed to set realtime scheduling using rtkit (%s)",
				   error->message);
			g_clear_pointer (&error, g_error_free);
		}

		g_object_unref (proxy);

		if (answer != NULL) 
			g_variant_unref (answer);
		else
			return FALSE;
	}

	return TRUE;
}

int
main (int argc, char **argv)
{
	arv_make_realtime ();
}
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux