Skip to contentSkip to conversation

sco-tester: Fix closing the socket

PATCH Applied Luiz Augusto von Dentz 3 participants 4 messages Mar 11, 2025 – Mar 12, 2025 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 sco-tester: Fix closing the socket

From: Luiz Augusto von Dentz <[email protected]>

When writting data the socket shall not be closed until all the data could be transmitted or the test times out.

---
 tools/sco-tester.c | 3 +++
 1 file changed, 3 insertions(+)
tools/sco-tester.c +3 -0
index e6888348bfab..b88631d89034 100644
@@ -821,6 +821,9 @@ static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond,
 					errno);
 			err = -errno;
 		}
+
+		/* Don't close the socket until all data is sent */
+		g_io_channel_set_close_on_unref(io, FALSE);
 	}
 
 	if (scodata->shutdown) {
Signature · 1 line
2.48.1
author maintainer
#1 lore raw

PATCH 2/2 btdev: Fix double lookup

From: Luiz Augusto von Dentz <[email protected]>

This fixes the existing double lookup when calling num_completed_packets but passing the conn->handle instead of passing the conn pointer directly since num_completed_packets would then attempt to do another lookup by handle to resolve the conn pointer again.

---
 emulator/btdev.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)
emulator/btdev.c +9 -15
index 976c1125d66e..1b7b75c21399 100644
@@ -7460,21 +7460,15 @@ void btdev_set_send_handler(struct btdev *btdev, btdev_send_func handler,
 	btdev->send_data = user_data;
 }
 
-static void num_completed_packets(struct btdev *btdev, uint16_t handle)
+static void num_completed_packets(struct btdev *btdev, struct btdev_conn *conn)
 {
-	struct btdev_conn *conn;
+	struct bt_hci_evt_num_completed_packets ncp;
 
-	conn = queue_find(btdev->conns, match_handle, UINT_TO_PTR(handle));
-	if (conn) {
-		struct bt_hci_evt_num_completed_packets ncp;
+	ncp.num_handles = 1;
+	ncp.handle = cpu_to_le16(conn->handle);
+	ncp.count = cpu_to_le16(1);
 
-		ncp.num_handles = 1;
-		ncp.handle = cpu_to_le16(handle);
-		ncp.count = cpu_to_le16(1);
-
-		send_event(btdev, BT_HCI_EVT_NUM_COMPLETED_PACKETS,
-							&ncp, sizeof(ncp));
-	}
+	send_event(btdev, BT_HCI_EVT_NUM_COMPLETED_PACKETS, &ncp, sizeof(ncp));
 }
 
 static const struct btdev_cmd *run_cmd(struct btdev *btdev,
@@ -7672,7 +7666,7 @@ static void send_acl(struct btdev *dev, const void *data, uint16_t len)
 	if (!conn)
 		return;
 
-	num_completed_packets(dev, conn->handle);
+	num_completed_packets(dev, conn);
 
 	/* ACL_START_NO_FLUSH is only allowed from host to controller.
 	 * From controller to host this should be converted to ACL_START.
@@ -7709,7 +7703,7 @@ static void send_sco(struct btdev *dev, const void *data, uint16_t len)
 		return;
 
 	if (dev->sco_flowctl)
-		num_completed_packets(dev, conn->handle);
+		num_completed_packets(dev, conn);
 
 	if (conn->link)
 		send_packet(conn->link->dev, iov, 2);
@@ -7734,7 +7728,7 @@ static void send_iso(struct btdev *dev, const void *data, uint16_t len)
 	if (!conn)
 		return;
 
-	num_completed_packets(dev, conn->handle);
+	num_completed_packets(dev, conn);
 
 	if (conn->link)
 		send_packet(conn->link->dev, iov, 2);
Signature · 1 line
2.48.1
#2 lore raw
In reply to Luiz Augusto von Dentz

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/project/bluetooth/list/?series=942846

---Test result---

Test Summary:

CheckPatch                    PENDING   0.18 seconds
GitLint                       PENDING   0.23 seconds
BuildEll                      PASS      20.37 seconds
BluezMake                     PASS      1467.50 seconds
MakeCheck                     PASS      13.22 seconds
MakeDistcheck                 PASS      157.13 seconds
CheckValgrind                 PASS      214.41 seconds
CheckSmatch                   WARNING   284.15 seconds
bluezmakeextell               PASS      97.80 seconds
IncrementalBuild              PENDING   0.33 seconds
ScanBuild                     PASS      867.64 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
tools/sco-tester.c: note: in included file:./lib/bluetooth.h:232:15: warning: array of flexible structures./lib/bluetooth.h:237:31: warning: array of flexible structuresemulator/btdev.c:451:29: warning: Variable length array is used.
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:

---
Regards,
Linux Bluetooth

#3 lore raw
In reply to Luiz Augusto von Dentz
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 7 lines · On Tue, 11 Mar 2025 15:42:25 -0400 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

When writting data the socket shall not be closed until all the data could be transmitted or the test times out.

---
 tools/sco-tester.c | 3 +++
 1 file changed, 3 insertions(+)

Here is the summary with links:
- [BlueZ,v1,1/2] sco-tester: Fix closing the socket

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=df891f0ff44e
  - [BlueZ,v1,2/2] btdev: Fix double lookup
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=adcd73901831

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html