Jackson-gjh commented on code in PR #21536:
URL: https://github.com/apache/nuttx/pull/21536#discussion_r4506172353
##########
net/bluetooth/bluetooth_sockif.c:
##########
@@ -640,8 +771,29 @@ static int bluetooth_close(FAR struct socket *psock)
{
/* Yes... free the connection structure */
- conn->bc_crefs = 0; /* No more references on
the connection */
- bluetooth_conn_free(psock->s_conn); /* Free network resources */
+#ifndef CONFIG_WIRELESS_BLUETOOTH_HOST
+ if (conn->bc_proto == BTPROTO_HCI)
+ {
+ FAR struct radio_driver_s *radio;
+
+ net_lock();
+ radio = bluetooth_hci_find_device(conn->bc_ldev);
+
+ if (radio != NULL && !bluetooth_hci_has_other(conn))
Review Comment:
I treated the carrier state as indicating that an external HCI Host is
currently attached, rather than merely that the Controller is registered.
After the final bound HCI socket is closed, no Host remains to consume
Controller events or submit HCI commands. Leaving IFF_RUNNING set would
therefore report the raw HCI transport as operational without a consumer.
A later successful bind enables the carrier again.
The carrier is turned off only for the final independent HCI socket;
duplicated references and other sockets bound to the same controller keep it
enabled.
If the intended carrier lifetime should persist after the Host socket closes,
I can remove the close-side transition.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]