> On Wed, 06.01.10 05:53, David Henningsson ([email protected])
> wrote:
>
>> Thanks for the pointers, they were most helpful.
>>
>> First, RtKit version is 0.4-0ubuntu2, OS is Ubuntu 10.04 (the
>> development
>> version). If that matters.
>>
>> I had trouble getting rtkit-test succeeding at first, and a long story
>> short, I was likely affected by this bug:
>> http://www.spinics.net/lists/linux-fsdevel/msg28757.html
>> ...so I had to try an bleeding edge kernel, in which rtkit-test works.
>>
>> After some additional debugging, I found that my original problem was
>> that
>> the rt-priority I requested was too high for rtkit to accept. So the
>> permission problem comes from rtkit, the process_set_realtime() call
>> returns -EPERM. So an additional question: would it be possible to
>> either
>> detect that highest value rtkit can deliver, or say "hey, I want x, but
>> if
>> you only can give me y, do that instead of failing"? In worst case, I
>> could do a binary search, but I'm glad if that could be avoided :-)
>> The same would be nice for the maximum value of RLIMIT_RTTIME.
>
> Hmm, yes, I guess that would make sense indeed. Adding this as props
> should be very simple.
It wasn't that difficult even for a dbus newbie as myself. I took the
liberty of stealing a few lines from pulseaudio's reserve.c [1].
>> This is one of the things I love most about Linux/FOSS, the ability to
>> debug wherever you want. I ended up inserting some debug prints in
>> rtkit-daemon to nail the problem down - had rtkit been a Windows system
>> service delivered by Microsoft, I'd probably still be stuck!
>
> He. Free Software also lives from contributions. So if you want to see
> these properties added quickly, then prep a clean patch and I'll merge
> it. ;-)
Hopefully the patch attached will do the job and be clean enough for you!
// David
[1] You, Lennart, is the only copyright holder and it's BSD license. I
assume you don't mind :-)
>From 7d5295d2be44be1e1c55acee0e278e9de79d1b38 Mon Sep 17 00:00:00 2001
From: David Henningsson <[email protected]>
Date: Sun, 17 Jan 2010 19:38:11 +0100
Subject: [PATCH] Add dbus properties for returning rttime-nsec-max, max-realtime-priority and min-nice-level
---
rtkit-daemon.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/rtkit-daemon.c b/rtkit-daemon.c
index e2eba15..2d7c5ff 100644
--- a/rtkit-daemon.c
+++ b/rtkit-daemon.c
@@ -79,7 +79,17 @@
" <method name=\"ResetKnown\"/>\n" \
" <method name=\"ResetAll\"/>\n" \
" <method name=\"Exit\"/>\n" \
+ " <property name=\"rttime-nsec-max\" type=\"x\" access=\"read\"/>\n" \
+ " <property name=\"max-realtime-priority\" type=\"i\" access=\"read\"/>\n" \
+ " <property name=\"min-nice-level\" type=\"i\" access=\"read\"/>\n" \
" </interface>\n" \
+ " <interface name=\"org.freedesktop.DBus.Properties\">\n"\
+ " <method name=\"Get\">" \
+ " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
+ " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
+ " <arg name=\"value\" direction=\"out\" type=\"v\"/>\n" \
+ " </method>\n" \
+ " </interface>\n" \
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \
" <method name=\"Introspect\">\n" \
" <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" \
@@ -87,6 +97,7 @@
" </interface>\n" \
"</node>\n"
+
/* Similar to assert(), but has side effects, and hence shall never be optimized away, regardless of NDEBUG */
#define assert_se(expr) \
do { \
@@ -1248,6 +1259,46 @@ static int verify_canary_refusal(void) {
return 0;
}
+static dbus_bool_t add_variant(
+ DBusMessage *m,
+ int type,
+ const void *data) {
+
+ DBusMessageIter iter, sub;
+ char t[2];
+
+ t[0] = (char) type;
+ t[1] = 0;
+
+ dbus_message_iter_init_append(m, &iter);
+
+ if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, t, &sub))
+ return FALSE;
+
+ if (!dbus_message_iter_append_basic(&sub, type, data))
+ return FALSE;
+
+ if (!dbus_message_iter_close_container(&iter, &sub))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+static int handle_dbus_prop_get(const char* property, DBusMessage *r)
+{
+ if (strcmp(property, "rttime-nsec-max") == 0) {
+ assert_se(add_variant(r, DBUS_TYPE_INT64, &rttime_nsec_max));
+ } else if (strcmp(property, "max-realtime-priority") == 0) {
+ assert_se(add_variant(r, DBUS_TYPE_INT32, &max_realtime_priority));
+ } else if (strcmp(property, "min-nice-level") == 0) {
+ assert_se(add_variant(r, DBUS_TYPE_INT32, &min_nice_level));
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
static DBusHandlerResult dbus_handler(DBusConnection *c, DBusMessage *m, void *userdata) {
DBusError error;
DBusMessage *r = NULL;
@@ -1362,6 +1413,34 @@ static DBusHandlerResult dbus_handler(DBusConnection *c, DBusMessage *m, void *u
dbus_connection_close(c);
+ } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "Get")) {
+ const char *interface, *property;
+ if (!dbus_message_get_args(m, &error,
+ DBUS_TYPE_STRING, &interface,
+ DBUS_TYPE_STRING, &property,
+ DBUS_TYPE_INVALID)) {
+
+ syslog(LOG_DEBUG, "Failed to parse property get call: %s\n", error.message);
+ assert_se(r = dbus_message_new_error(m, error.name, error.message));
+ goto finish;
+ }
+
+ if (strcmp(interface, "org.freedesktop.RealtimeKit1") == 0) {
+ assert_se(r = dbus_message_new_method_return(m));
+ if (!handle_dbus_prop_get(property, r)) {
+
+ dbus_message_unref(r);
+ assert_se(r = dbus_message_new_error_printf(
+ m,
+ DBUS_ERROR_UNKNOWN_METHOD,
+ "Unknown property %s",
+ property));
+ }
+ }
+ else {
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
} else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
const char *xml = INTROSPECT_XML;
--
1.6.5
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss