* [PATCH BlueZ] obexd: Request the bus name after initialisation
@ 2026-11-25 10:55 Chris Bainbridge
2026-11-25 14:40 ` [BlueZ] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Chris Bainbridge @ 2026-11-25 10:55 UTC (permalink / raw)
To: linux-bluetooth
obexd requests the well-known name org.bluez.obex in manager_init(),
which runs before plugin_init(), obex_server_init() and
client_manager_init(). Some of them perform blocking D-Bus round
trips: the ebook phonebook backend activates Evolution Data Server
(e_source_registry_new_sync() and e_book_client_connect_sync()) and the
bluetooth plugin connects to the system bus. Until the main loop runs
obexd dispatches no messages, so the name is visible but the daemon
cannot answer during the whole init window.
Clients that react to the name appearing with a synchronous call - for
example blueman-applet's TransferService - then hit the 25 s GDBus
default timeout and report "g-io-error-quark: Timeout was reached (24)"
at login. On a cold session where EDS is being activated at the same
time this is routinely exceeded, which makes blueman-applet the most
reported crash in Ubuntu.
manager_init() now only connects to the bus. The name is requested once
all plugins, servers and client interfaces are ready, right before
entering the main loop, unless SIGINT or SIGTERM arrived while signals
were masked during initialisation. Activation completes only when the
daemon can serve requests; messages sent earlier are queued by the bus
instead of being delivered to a daemon that cannot answer. If
initialisation fails, activation fails as well instead of exposing a
name that disappears immediately afterwards.
This delays the Type=dbus "started" state of obex.service by the init
duration. Because both irmc and pbap call phonebook_init() and retry if
the first call fails, two back-to-back EDS timeouts (25 s GDBus proxy
timeout plus 30 s e_book_client_connect_sync() timeout per call) can
exceed systemd's 90 s default TimeoutStartSec and kill all OBEX
services. Raise TimeoutStartSec to 180 in obex.service to cover that
worst case.
Link: https://bugs.launchpad.net/bugs/2066094
Link: https://github.com/blueman-project/blueman/issues/2930
---
obexd/src/main.c | 40 +++++++++++++++++++++++++++++++++++++++
obexd/src/manager.c | 7 ++++++-
obexd/src/obex.service.in | 1 +
3 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/obexd/src/main.c b/obexd/src/main.c
index 5114104..8d6c59f 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
@@ -36,6 +36,7 @@
#include "log.h"
#include "logind.h"
+#include "manager.h"
#include "obexd.h"
#include "server.h"
@@ -258,6 +259,8 @@ int main(int argc, char *argv[])
{
GOptionContext *context;
GError *err = NULL;
+ DBusError dbus_err;
+ sigset_t pending;
guint signal;
context = g_option_context_new(NULL);
@@ -327,8 +330,45 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
+ /*
+ * Signals are masked in setup_signalfd() before plugin_init() so
+ * worker threads inherit the mask, and are not dispatched until the
+ * main loop runs. Skip claiming the bus name if termination is
+ * already pending.
+ */
+ sigemptyset(&pending);
+
+ if (sigpending(&pending) == 0 && (sigismember(&pending, SIGINT) ||
+ sigismember(&pending, SIGTERM))) {
+ info("Terminating");
+ goto done;
+ }
+
+ /*
+ * Request the well-known name only now that all plugins and servers
+ * are initialised. Several of them perform blocking D-Bus round trips
+ * during init: the ebook phonebook backend activates Evolution Data
+ * Server and the bluetooth plugin connects to the system bus. Owning
+ * the name earlier made clients see obexd on the bus while it could
+ * not answer any request yet, so synchronous clients timed out.
+ */
+ dbus_error_init(&dbus_err);
+
+ if (!g_dbus_request_name(connection, OBEXD_SERVICE, &dbus_err)) {
+ if (dbus_error_is_set(&dbus_err)) {
+ error("Failed to request name %s: %s", OBEXD_SERVICE,
+ dbus_err.message);
+ dbus_error_free(&dbus_err);
+ } else {
+ error("Failed to request name %s", OBEXD_SERVICE);
+ }
+
+ exit(EXIT_FAILURE);
+ }
+
g_main_loop_run(main_loop);
+done:
g_source_remove(signal);
client_manager_exit();
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 89b3d04..5029b42 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -488,7 +488,12 @@ gboolean manager_init(void)
dbus_error_init(&err);
- connection = obex_setup_dbus_connection(OBEXD_SERVICE, &err);
+ /*
+ * Only connect here. The well-known name must not be requested until
+ * everything is initialised (see main()), otherwise obexd is visible
+ * on the bus while it is still unable to process any message.
+ */
+ connection = obex_setup_dbus_connection(NULL, &err);
if (connection == NULL) {
if (dbus_error_is_set(&err) == TRUE) {
fprintf(stderr, "%s\n", err.message);
diff --git a/obexd/src/obex.service.in b/obexd/src/obex.service.in
index cf4d8c9..3785c1e 100644
--- a/obexd/src/obex.service.in
+++ b/obexd/src/obex.service.in
@@ -5,6 +5,7 @@ Description=Bluetooth OBEX service
Type=dbus
BusName=org.bluez.obex
ExecStart=@PKGLIBEXECDIR@/obexd
+TimeoutStartSec=180
[Install]
Alias=dbus-org.bluez.obex.service
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [BlueZ] obexd: Request the bus name after initialisation
2026-11-25 10:55 [PATCH BlueZ] obexd: Request the bus name after initialisation Chris Bainbridge
@ 2026-11-25 14:40 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-11-25 14:40 UTC (permalink / raw)
To: linux-bluetooth, chris.bainbridge
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1221956/
---Test result---
Test Summary:
CheckPatch PASS 0.57 seconds
GitLint PASS 0.33 seconds
BuildEll PASS 20.28 seconds
BluezMake PASS 312.63 seconds
CheckSmatch PASS 315.35 seconds
bluezmakeextell PASS 100.14 seconds
TestFunctional PASS 1232.00 seconds
IncrementalBuild PASS 314.34 seconds
ScanBuild PASS 1205.09 seconds
https://github.com/bluez/bluez/pull/2919
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 14:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 10:55 [PATCH BlueZ] obexd: Request the bus name after initialisation Chris Bainbridge
2026-11-25 14:40 ` [BlueZ] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox