public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Sayers <kernel.org@pileofstuff.org>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, pav@iki.fi,
	Andrew Sayers <kernel.org@pileofstuff.org>
Subject: [PATCH BlueZ v4 0/6] obexd: unregister profiles when the user is inactive
Date: Mon, 28 Apr 2025 14:15:29 +0100	[thread overview]
Message-ID: <20250428131842.488921-1-kernel.org@pileofstuff.org> (raw)

This is a follow-up to "obexd: only run one instance at once".
Instead of refusing to run parallel services, it unregisters
profiles when the user is inactive.  This avoids the need
for tmpfiles, and avoids issues where the user with the
obex service logs out, leaving obex disabled altogether.

Luiz previously suggested moving this to systemd, but I haven't had much
luck getting the systemd devs to accept changes, and Pauli's mention of
elogind (i.e. logind without systemd) suggests it's probably better
to avoid the dependency anyway.

I considered writing a separate D-Bus service that would notify you
when the session became (in)active, but D-Bus doesn't have particularly
strong guarantees about how long messages take to deliver, which could
lead to race conditions between instances on overloaded systems.

I also considered writing some kind of library, but there's not much
code to deduplicate, and most of it would need to be reworked for every
service that uses it.  So I wrote a gist for people to copy/paste:

https://gist.github.com/andrew-sayers/1c4a24f86a9a4c1b1e38d109f1bd1d1e

Signed-off-by: Andrew Sayers <kernel.org@pileofstuff.org>
---

Pauli pointed out timeout_handler() isn't required by the implementation,
even though the documentation implies otherwise.  Having thought about it
over the weekend, it seems hard to avoid concluding both that
timeout_handler() cannot be fully tested in the real world right now;
and that any change to the API would likely happen in many years' time,
when we've all forgotten how to fix the problem.  So I've moved that bit
to a separate patch, which can be bisected and reverted if necessary.

Pauli - I appreciate the feedback and wanted to note it in the patch,
without implying you wanted that function kept in.  I've settled on
a Cc: line, but happy to change it if you'd prefer.

V1 -> V2 Open/close private DBus connections instead of
           calling UnregisterProfile (thanks Pauli Virtanen)
         Add obex_setup_dbus_connection_private() (to enable the above)
         Fix CI errors
         Minor issues I missed last time...
           s/regster/register/ in e-mail subject lines
           s/login_.*_cb/logind_$1_cb/g in logind.[ch]
           remove watches on exit in pbap.c and bluetooth.c
V2 -> V3 Fix checkpatch.pl errors - thanks Luiz
           Note: false positive warning about commit #4 is still present -
           this URL can't be split or shortened without causing issues.
V3 -> V4 Fix various bugs - thanks Pauli
         Split timeout_handler() into a separate patch - see above

Andrew Sayers (6):
      pbap: Support calling pbap_init() after pbap_exit()
      obexd/bluetooth: Support calling bluetooth_init() after bluetooth_exit()
      obexd: Support creating private system/session bus connections
      obexd: Unregister profiles when the user is inactive
      obexd: Support sd_login_monitor_get_timeout()
      Revert "obexd: only run one instance at once"

 Makefile.obexd            |  10 ++
 obexd/client/pbap.c       |  33 +++++-
 obexd/plugins/bluetooth.c |  30 +++++-
 obexd/src/logind.c        | 260 ++++++++++++++++++++++++++++++++++++++++++++++
 obexd/src/logind.h        |  26 +++++
 obexd/src/main.c          |  12 +++
 obexd/src/obex.service.in |   9 --
 obexd/src/obexd.h         |   2 +
 8 files changed, 364 insertions(+), 18 deletions(-)


             reply	other threads:[~2025-04-28 13:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28 13:15 Andrew Sayers [this message]
2025-04-28 13:15 ` [PATCH BlueZ v4 1/6] pbap: Support calling pbap_init() after pbap_exit() Andrew Sayers
2025-04-28 14:57   ` obexd: unregister profiles when the user is inactive bluez.test.bot
2025-04-28 21:47   ` [PATCH BlueZ v4 1/6] pbap: Support calling pbap_init() after pbap_exit() Luiz Augusto von Dentz
2025-04-28 13:15 ` [PATCH BlueZ v4 2/6] obexd/bluetooth: Support calling bluetooth_init() after bluetooth_exit() Andrew Sayers
2025-04-28 13:15 ` [PATCH BlueZ v4 3/6] obexd: Support creating private system/session bus connections Andrew Sayers
2025-04-28 13:15 ` [PATCH BlueZ v4 4/6] obexd: Unregister profiles when the user is inactive Andrew Sayers
2025-04-28 13:15 ` [PATCH BlueZ v4 5/6] obexd: Support sd_login_monitor_get_timeout() Andrew Sayers
2025-04-28 17:11   ` Pauli Virtanen
2025-04-28 13:15 ` [PATCH BlueZ v4 6/6] Revert "obexd: only run one instance at once" Andrew Sayers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250428131842.488921-1-kernel.org@pileofstuff.org \
    --to=kernel.org@pileofstuff.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=pav@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox