public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [bluez/bluez] a5513f: shared/io: add helper for asynchronous shutdown() ...
@ 2025-09-14 12:20 Pauli Virtanen
  0 siblings, 0 replies; only message in thread
From: Pauli Virtanen @ 2025-09-14 12:20 UTC (permalink / raw)
  To: linux-bluetooth

  Branch: refs/heads/1002158
  Home:   https://github.com/bluez/bluez
  Commit: a5513fa0d83aa3ece6c6f9c8ebc3ac65b16fbeea
      https://github.com/bluez/bluez/commit/a5513fa0d83aa3ece6c6f9c8ebc3ac65b16fbeea
  Author: Pauli Virtanen <pav@iki.fi>
  Date:   2025-09-14 (Sun, 14 Sep 2025)

  Changed paths:
    M src/shared/io-ell.c
    M src/shared/io-glib.c
    M src/shared/io-mainloop.c
    M src/shared/io.h

  Log Message:
  -----------
  shared/io: add helper for asynchronous shutdown() with SO_LINGER

Add io_glib_shutdown_linger() for socket shutdown with wait for
remote ACK via SO_LINGER. E.g. wait for L2CAP Disconnect Rsp.

We don't want to block the main loop for the linger timeout, so call
shutdown() in a separate thread, as socket API seems to provide only the
blocking way to do it.

Implement it with Glib source API, as that's more convenient for the
AVDTP plugin that needs this.


  Commit: 24912664b9093d88a14d2effae32951a36b02dba
      https://github.com/bluez/bluez/commit/24912664b9093d88a14d2effae32951a36b02dba
  Author: Pauli Virtanen <pav@iki.fi>
  Date:   2025-09-14 (Sun, 14 Sep 2025)

  Changed paths:
    M profiles/audio/avdtp.c

  Log Message:
  -----------
  avdtp: wait for L2CAP Disconnect Rsp before CLOSING->IDLE

Delay CLOSING->IDLE until remote acknowledges L2CAP channel closure.

It is not explicitly stated in AVDTP v1.3 Sec. 6.13, but some devices
refuse commands sent immediately after L2CAP Disconnect Req, so wait
until Rsp.

Fails:

> ACL Data RX: Handle 6 flags 0x02 dlen 6
      Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
      AVDTP: Close (0x08) Response Accept (0x02) type 0x00 label 0 nosp 0
< ACL Data TX: Handle 6 flags 0x00 dlen 12
      L2CAP: Disconnection Request (0x06) ident 16 len 4
        Destination CID: 65
        Source CID: 65
< ACL Data TX: Handle 6 flags 0x00 dlen 22
      Channel: 64 len 18 [PSM 25 mode Basic (0x00)] {chan 0}
      AVDTP: Set Configuration (0x03) Command (0x00) type 0x00 label 1 nosp 0
        ACP SEID: 7
        INT SEID: 1
        Service Category: Media Transport (0x01)
        Service Category: Media Codec (0x07)
          Media Type: Audio (0x00)
          Media Codec: MPEG-2,4 AAC (0x02)
            Object Type: MPEG-4 AAC LC (0x40)
            Frequency: 44100 (0x100)
            Channels: 2 (0x04)
            Bitrate: 220000bps
            VBR: No
        Service Category: Delay Reporting (0x08)
> ACL Data RX: Handle 6 flags 0x02 dlen 12
      L2CAP: Disconnection Response (0x07) ident 16 len 4
        Destination CID: 65
        Source CID: 65
> ACL Data RX: Handle 6 flags 0x02 dlen 8
      Channel: 64 len 4 [PSM 25 mode Basic (0x00)] {chan 0}
      AVDTP: Set Configuration (0x03) Response Reject (0x03) type 0x00 label 1 nosp 0
        Service Category: Reserved (0x29)
        Error code: UNSUPPORTED_CONFIGURATION (0x29)

Works:

> ACL Data RX: Handle 4 flags 0x02 dlen 6
      Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
      AVDTP: Close (0x08) Response Accept (0x02) type 0x00 label 12 nosp 0
< ACL Data TX: Handle 4 flags 0x00 dlen 12
      L2CAP: Disconnection Request (0x06) ident 16 len 4
        Destination CID: 65
        Source CID: 65
> ACL Data RX: Handle 4 flags 0x02 dlen 12
      L2CAP: Disconnection Response (0x07) ident 16 len 4
        Destination CID: 65
        Source CID: 65
< ACL Data TX: Handle 4 flags 0x00 dlen 22
      Channel: 64 len 18 [PSM 25 mode Basic (0x00)] {chan 0}
      AVDTP: Set Configuration (0x03) Command (0x00) type 0x00 label 13 nosp 0
        ACP SEID: 9
        INT SEID: 2
        Service Category: Media Transport (0x01)
        Service Category: Media Codec (0x07)
          Media Type: Audio (0x00)
          Media Codec: MPEG-2,4 AAC (0x02)
            Object Type: MPEG-4 AAC LC (0x40)
            Frequency: 44100 (0x100)
            Channels: 2 (0x04)
            Bitrate: 220000bps
            VBR: No
        Service Category: Delay Reporting (0x08)
> ACL Data RX: Handle 4 flags 0x02 dlen 6
      Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
      AVDTP: Set Configuration (0x03) Response Accept (0x02) type 0x00 label 13 nosp 0

Fixes: https://github.com/bluez/bluez/issues/1471
Fixes: aa118e965b ("a2dp: Don't wait to reconfigure")


Compare: https://github.com/bluez/bluez/compare/a5513fa0d83a%5E...24912664b909

To unsubscribe from these emails, change your notification settings at https://github.com/bluez/bluez/settings/notifications

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-09-14 12:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-14 12:20 [bluez/bluez] a5513f: shared/io: add helper for asynchronous shutdown() Pauli Virtanen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox