Skip to content

obexd: unregister profiles when the user is inactive

Andrew Sayers linux-bluetooth 7 versions – Applied

Status from this message: This series was applied to bluetooth/bluez.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest3 patches 7 repliesApplied
  2. v56 patches 4 repliesSuperseded
  3. v46 patches 3 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v35 patches5 repliesSuperseded
v2 posting 2/25 patches1 replySuperseded
v2 posting 1/20 of 4 patches1 replySuperseded
v14 patches2 repliesSuperseded

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/3obexd: Unregister profiles when the user is inactiveMakefile.obexd obexd/client/pbap.c obexd/plugins/bluetooth.c +3 more+316 -57 replies
2/3obexd: Support sd_login_monitor_get_timeout()obexd/src/logind.c+43 -00 replies
3/3Revert "obexd: only run one instance at once"obexd/src/obex.service.in+0 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.

Read the v6 thread

Cover letter [PATCH BlueZ v6 0/3] obexd: unregister profiles when the user is inactive

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

---

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
V4 -> V5 Add #include <stdlib.h> based on CI tests - thanks Luiz
Update the timeout on event_handler calls (and handle a couple of
edge cases that could have misbehaved before) - thanks Pauli
Discuss how the API assumes poll() in the penultimate
commit message - thanks Pauli
V5 -> V6 Remove commits that were upstreamed in v5 (thanks Luiz)
Replace dummy macros with inline functions in logind.h
(silences some checkpatch.pl warnings, function solution recommended by Luiz)

Andrew Sayers (3):
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       |  17 ++-
 obexd/plugins/bluetooth.c |  14 ++-
 obexd/src/logind.c        | 282 ++++++++++++++++++++++++++++++++++++++++++++++
 obexd/src/logind.h        |  37 ++++++
 obexd/src/main.c          |   4 +
 obexd/src/obex.service.in |   9 --
 7 files changed, 359 insertions(+), 14 deletions(-)