* [PATCH BlueZ] gdbus: Force service to start if proxy is created while not connected
@ 2017-11-28 10:57 Luiz Augusto von Dentz
2017-11-28 13:47 ` Bastien Nocera
0 siblings, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2017-11-28 10:57 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Because GetAll is no longer send right away the service may never be
started.
---
gdbus/client.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/gdbus/client.c b/gdbus/client.c
index 9b0f7f7a9..3d7105ef8 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -484,6 +484,28 @@ static void proxy_remove(GDBusClient *client, const char *path,
}
}
+static void start_service(GDBusProxy *proxy)
+{
+ GDBusClient *client = proxy->client;
+ const char *service_name = client->service_name;
+ dbus_uint32_t flags = 0;
+ DBusMessage *msg;
+
+ msg = dbus_message_new_method_call(DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ "StartServiceByName");
+ if (msg == NULL)
+ return;
+
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &service_name,
+ DBUS_TYPE_UINT32, &flags,
+ DBUS_TYPE_INVALID);
+
+ g_dbus_send_message(client->dbus_conn, msg);
+ dbus_message_unref(msg);
+ return;
+}
+
GDBusProxy *g_dbus_proxy_new(GDBusClient *client, const char *path,
const char *interface)
{
@@ -500,7 +522,13 @@ GDBusProxy *g_dbus_proxy_new(GDBusClient *client, const char *path,
if (proxy == NULL)
return NULL;
- if (client->connected && !client->get_objects_call)
+ if (!client->connected) {
+ /* Force service to start */
+ start_service(proxy);
+ return g_dbus_proxy_ref(proxy);
+ }
+
+ if (!client->get_objects_call)
get_all_properties(proxy);
return g_dbus_proxy_ref(proxy);
--
2.13.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ] gdbus: Force service to start if proxy is created while not connected
2017-11-28 10:57 [PATCH BlueZ] gdbus: Force service to start if proxy is created while not connected Luiz Augusto von Dentz
@ 2017-11-28 13:47 ` Bastien Nocera
2017-11-28 13:49 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 5+ messages in thread
From: Bastien Nocera @ 2017-11-28 13:47 UTC (permalink / raw)
To: Luiz Augusto von Dentz, linux-bluetooth
On Tue, 2017-11-28 at 12:57 +0200, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> Because GetAll is no longer send right away the service may never be
> started.
Causes an assertion on startup on my machine.
dbus[12994]: arguments to dbus_message_unref() were incorrect, assertion "!message->in_cache" failed in file ../../dbus/dbus-message.c line 1718.
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffff6b752a7 in __GI_abort () at abort.c:90
#2 0x00007ffff76618c4 in _dbus_abort () from /lib64/libdbus-1.so.3
#3 0x00007ffff7658150 in _dbus_warn_check_failed () from /lib64/libdbus-1.so.3
#4 0x000000000048b281 in start_service (proxy=0x70a4f0) at gdbus/client.c:505
#5 g_dbus_proxy_new (client=<optimized out>, path=path@entry=0x49bcad "/org/freedesktop/hostname1", interface=interface@entry=0x49bcc8 "org.freedesktop.hostname1") at gdbus/client.c:527
#6 0x000000000040cb9d in hostname_init () at plugins/hostname.c:287
#7 0x000000000045617a in plugin_init (enable=<optimized out>, disable=<optimized out>) at src/plugin.c:200
#8 0x000000000040bc9e in main (argc=<optimized out>, argv=<optimized out>) at src/main.c:744
Looks like g_dbus_send_message() takes ownership of the reference to
the message. Removing that call in your patch makes it work.
Might want to double-check though.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ] gdbus: Force service to start if proxy is created while not connected
2017-11-28 13:47 ` Bastien Nocera
@ 2017-11-28 13:49 ` Luiz Augusto von Dentz
2017-11-28 13:58 ` Bastien Nocera
0 siblings, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2017-11-28 13:49 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-bluetooth@vger.kernel.org
Hi Bastien,
On Tue, Nov 28, 2017 at 3:47 PM, Bastien Nocera <hadess@hadess.net> wrote:
> On Tue, 2017-11-28 at 12:57 +0200, Luiz Augusto von Dentz wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> Because GetAll is no longer send right away the service may never be
>> started.
>
> Causes an assertion on startup on my machine.
>
> dbus[12994]: arguments to dbus_message_unref() were incorrect, assertion "!message->in_cache" failed in file ../../dbus/dbus-message.c line 1718.
>
> #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
> #1 0x00007ffff6b752a7 in __GI_abort () at abort.c:90
> #2 0x00007ffff76618c4 in _dbus_abort () from /lib64/libdbus-1.so.3
> #3 0x00007ffff7658150 in _dbus_warn_check_failed () from /lib64/libdbus-1.so.3
> #4 0x000000000048b281 in start_service (proxy=0x70a4f0) at gdbus/client.c:505
> #5 g_dbus_proxy_new (client=<optimized out>, path=path@entry=0x49bcad "/org/freedesktop/hostname1", interface=interface@entry=0x49bcc8 "org.freedesktop.hostname1") at gdbus/client.c:527
> #6 0x000000000040cb9d in hostname_init () at plugins/hostname.c:287
> #7 0x000000000045617a in plugin_init (enable=<optimized out>, disable=<optimized out>) at src/plugin.c:200
> #8 0x000000000040bc9e in main (argc=<optimized out>, argv=<optimized out>) at src/main.c:744
>
> Looks like g_dbus_send_message() takes ownership of the reference to
> the message. Removing that call in your patch makes it work.
>
> Might want to double-check though.
Does it fixes the problem after that?
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ] gdbus: Force service to start if proxy is created while not connected
2017-11-28 13:49 ` Luiz Augusto von Dentz
@ 2017-11-28 13:58 ` Bastien Nocera
2017-11-28 14:23 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 5+ messages in thread
From: Bastien Nocera @ 2017-11-28 13:58 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
On Tue, 2017-11-28 at 15:49 +0200, Luiz Augusto von Dentz wrote:
> Hi Bastien,
>
> On Tue, Nov 28, 2017 at 3:47 PM, Bastien Nocera <hadess@hadess.net>
> wrote:
> > On Tue, 2017-11-28 at 12:57 +0200, Luiz Augusto von Dentz wrote:
> > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> > >
> > > Because GetAll is no longer send right away the service may never
> > > be
> > > started.
> >
> > Causes an assertion on startup on my machine.
> >
> > dbus[12994]: arguments to dbus_message_unref() were incorrect,
> > assertion "!message->in_cache" failed in file ../../dbus/dbus-
> > message.c line 1718.
> >
> > #0 __GI_raise (sig=sig@entry=6) at
> > ../sysdeps/unix/sysv/linux/raise.c:51
> > #1 0x00007ffff6b752a7 in __GI_abort () at abort.c:90
> > #2 0x00007ffff76618c4 in _dbus_abort () from /lib64/libdbus-1.so.3
> > #3 0x00007ffff7658150 in _dbus_warn_check_failed () from
> > /lib64/libdbus-1.so.3
> > #4 0x000000000048b281 in start_service (proxy=0x70a4f0) at
> > gdbus/client.c:505
> > #5 g_dbus_proxy_new (client=<optimized out>, path=path@entry=0x49b
> > cad "/org/freedesktop/hostname1", interface=interface@entry=0x49bcc
> > 8 "org.freedesktop.hostname1") at gdbus/client.c:527
> > #6 0x000000000040cb9d in hostname_init () at
> > plugins/hostname.c:287
> > #7 0x000000000045617a in plugin_init (enable=<optimized out>,
> > disable=<optimized out>) at src/plugin.c:200
> > #8 0x000000000040bc9e in main (argc=<optimized out>,
> > argv=<optimized out>) at src/main.c:744
> >
> > Looks like g_dbus_send_message() takes ownership of the reference
> > to
> > the message. Removing that call in your patch makes it work.
> >
> > Might want to double-check though.
>
> Does it fixes the problem after that?
Yes, the hostname plugin works correctly, and the adapter name matches
the hostname.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ] gdbus: Force service to start if proxy is created while not connected
2017-11-28 13:58 ` Bastien Nocera
@ 2017-11-28 14:23 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2017-11-28 14:23 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-bluetooth@vger.kernel.org
Hi,
On Tue, Nov 28, 2017 at 3:58 PM, Bastien Nocera <hadess@hadess.net> wrote:
> On Tue, 2017-11-28 at 15:49 +0200, Luiz Augusto von Dentz wrote:
>> Hi Bastien,
>>
>> On Tue, Nov 28, 2017 at 3:47 PM, Bastien Nocera <hadess@hadess.net>
>> wrote:
>> > On Tue, 2017-11-28 at 12:57 +0200, Luiz Augusto von Dentz wrote:
>> > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>> > >
>> > > Because GetAll is no longer send right away the service may never
>> > > be
>> > > started.
>> >
>> > Causes an assertion on startup on my machine.
>> >
>> > dbus[12994]: arguments to dbus_message_unref() were incorrect,
>> > assertion "!message->in_cache" failed in file ../../dbus/dbus-
>> > message.c line 1718.
>> >
>> > #0 __GI_raise (sig=sig@entry=6) at
>> > ../sysdeps/unix/sysv/linux/raise.c:51
>> > #1 0x00007ffff6b752a7 in __GI_abort () at abort.c:90
>> > #2 0x00007ffff76618c4 in _dbus_abort () from /lib64/libdbus-1.so.3
>> > #3 0x00007ffff7658150 in _dbus_warn_check_failed () from
>> > /lib64/libdbus-1.so.3
>> > #4 0x000000000048b281 in start_service (proxy=0x70a4f0) at
>> > gdbus/client.c:505
>> > #5 g_dbus_proxy_new (client=<optimized out>, path=path@entry=0x49b
>> > cad "/org/freedesktop/hostname1", interface=interface@entry=0x49bcc
>> > 8 "org.freedesktop.hostname1") at gdbus/client.c:527
>> > #6 0x000000000040cb9d in hostname_init () at
>> > plugins/hostname.c:287
>> > #7 0x000000000045617a in plugin_init (enable=<optimized out>,
>> > disable=<optimized out>) at src/plugin.c:200
>> > #8 0x000000000040bc9e in main (argc=<optimized out>,
>> > argv=<optimized out>) at src/main.c:744
>> >
>> > Looks like g_dbus_send_message() takes ownership of the reference
>> > to
>> > the message. Removing that call in your patch makes it work.
>> >
>> > Might want to double-check though.
>>
>> Does it fixes the problem after that?
>
> Yes, the hostname plugin works correctly, and the adapter name matches
> the hostname.
Applied after removing the unref.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-11-28 14:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-28 10:57 [PATCH BlueZ] gdbus: Force service to start if proxy is created while not connected Luiz Augusto von Dentz
2017-11-28 13:47 ` Bastien Nocera
2017-11-28 13:49 ` Luiz Augusto von Dentz
2017-11-28 13:58 ` Bastien Nocera
2017-11-28 14:23 ` Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox