1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
From 2cf933915ccd21ccecb791484ad91a9ee6089336 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Mon, 16 May 2016 10:11:56 +0300
Subject: [PATCH] Fix dbus message handling problems
- make sure dbus messages are released after handling
- return error to unknown method calls to avoid timeouts
---
OMXControl.cpp | 24 ++++++++++++++++++++++++
OMXControl.h | 2 ++
2 files changed, 26 insertions(+)
diff --git a/OMXControl.cpp b/OMXControl.cpp
index 834461f..7188834 100644
--- a/OMXControl.cpp
+++ b/OMXControl.cpp
@@ -158,7 +158,14 @@ OMXControlResult OMXControl::getEvent()
return KeyConfig::ACTION_BLANK;
CLog::Log(LOGDEBUG, "Popped message member: %s interface: %s type: %d path: %s", dbus_message_get_member(m), dbus_message_get_interface(m), dbus_message_get_type(m), dbus_message_get_path(m) );
+ OMXControlResult result = handle_event(m);
+ dbus_message_unref(m);
+ return result;
+}
+
+OMXControlResult OMXControl::handle_event(DBusMessage *m)
+{
if (dbus_message_is_method_call(m, OMXPLAYER_DBUS_INTERFACE_ROOT, "Quit"))
{
dbus_respond_ok(m);
@@ -649,11 +656,28 @@ OMXControlResult OMXControl::getEvent()
}
else {
CLog::Log(LOGWARNING, "Unhandled dbus message, member: %s interface: %s type: %d path: %s", dbus_message_get_member(m), dbus_message_get_interface(m), dbus_message_get_type(m), dbus_message_get_path(m) );
+ if (dbus_message_get_type(m) == DBUS_MESSAGE_TYPE_METHOD_CALL)
+ dbus_respond_error(m);
}
return KeyConfig::ACTION_BLANK;
}
+DBusHandlerResult OMXControl::dbus_respond_error(DBusMessage *m)
+{
+ DBusMessage *reply;
+
+ reply = dbus_message_new_error(m, DBUS_ERROR_UNKNOWN_METHOD, "Unknown method");
+
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ dbus_connection_send(bus, reply, NULL);
+ dbus_message_unref(reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
DBusHandlerResult OMXControl::dbus_respond_ok(DBusMessage *m)
{
DBusMessage *reply;
diff --git a/OMXControl.h b/OMXControl.h
index b2786d5..b0c9a06 100644
--- a/OMXControl.h
+++ b/OMXControl.h
@@ -38,6 +38,8 @@ class OMXControl
private:
int dbus_connect(std::string& dbus_name);
void dbus_disconnect();
+ OMXControlResult handle_event(DBusMessage *m);
+ DBusHandlerResult dbus_respond_error(DBusMessage *m);
DBusHandlerResult dbus_respond_ok(DBusMessage *m);
DBusHandlerResult dbus_respond_int64(DBusMessage *m, int64_t i);
DBusHandlerResult dbus_respond_double(DBusMessage *m, double d);
|