Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_packages_modules_Bluetooth
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid
platform_packages_modules_Bluetooth
Commits
92a4c663
Commit
92a4c663
authored
1 year ago
by
Yun-hao Chung
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Floss: Retry socket bind on EINVAL" into main
parents
31d3970d
9f5c0969
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
system/gd/rust/linux/mgmt/Cargo.toml
+1
-0
1 addition, 0 deletions
system/gd/rust/linux/mgmt/Cargo.toml
system/gd/rust/linux/mgmt/src/state_machine.rs
+34
-11
34 additions, 11 deletions
system/gd/rust/linux/mgmt/src/state_machine.rs
with
35 additions
and
11 deletions
system/gd/rust/linux/mgmt/Cargo.toml
+
1
−
0
View file @
92a4c663
...
...
@@ -32,6 +32,7 @@ regex = "1.5"
serde_json
=
"1.0"
syslog
=
"6"
tokio
=
{
version
=
"1.0"
,
features
=
[
"fs"
,
"macros"
,
"rt-multi-thread"
,
"sync"
]
}
libc
=
"0.2"
[build-dependencies]
pkg-config
=
"0.3.19"
...
...
This diff is collapsed.
Click to expand it.
system/gd/rust/linux/mgmt/src/state_machine.rs
+
34
−
11
View file @
92a4c663
...
...
@@ -5,6 +5,7 @@ use bt_utils::socket::{
BtSocket
,
HciChannels
,
MgmtCommand
,
MgmtCommandResponse
,
MgmtEvent
,
HCI_DEV_NONE
,
};
use
libc
;
use
log
::{
debug
,
error
,
info
,
warn
};
use
nix
::
sys
::
signal
::{
self
,
Signal
};
use
nix
::
unistd
::
Pid
;
...
...
@@ -36,6 +37,10 @@ pub const INDEX_REMOVED_DEBOUNCE_TIME: Duration = Duration::from_millis(150);
/// to avoid dead process + PID not cleaned up from happening.
pub
const
PID_RUNNING_CHECK_PERIOD
:
Duration
=
Duration
::
from_secs
(
60
);
const
HCI_BIND_MAX_RETRY
:
i32
=
2
;
const
HCI_BIND_RETRY_INTERVAL
:
Duration
=
Duration
::
from_millis
(
10
);
#[derive(Debug,
PartialEq,
Copy,
Clone)]
#[repr(u32)]
pub
enum
ProcessState
{
...
...
@@ -362,19 +367,37 @@ fn configure_hci(hci_tx: mpsc::Sender<Message>) {
x
=>
debug!
(
"Socket open at fd: {}"
,
x
),
}
// Bind to control channel (which is used for mgmt commands). We provide
// HCI_DEV_NONE because we don't actually need a valid HCI dev for some MGMT commands.
match
btsock
.bind_channel
(
HciChannels
::
Control
,
HCI_DEV_NONE
)
{
-
1
=>
{
panic!
(
"Failed to bind control channel with errno={}"
,
std
::
io
::
Error
::
last_os_error
()
.raw_os_error
()
.unwrap_or
(
0
)
);
tokio
::
spawn
(
async
move
{
// Bind to control channel (which is used for mgmt commands). We provide
// HCI_DEV_NONE because we don't actually need a valid HCI dev for some MGMT commands.
let
mut
bind_succ
=
false
;
for
_i
in
0
..
HCI_BIND_MAX_RETRY
{
match
btsock
.bind_channel
(
HciChannels
::
Control
,
HCI_DEV_NONE
)
{
-
1
=>
{
match
std
::
io
::
Error
::
last_os_error
()
.raw_os_error
()
.unwrap_or
(
0
)
{
libc
::
EINVAL
=>
{
// If MGMT hasn't been initialized EINVAL will be returned.
// Just wait for a short time and try again.
debug!
(
"Got EINVAL in bind. Wait and try again"
);
tokio
::
time
::
sleep
(
HCI_BIND_RETRY_INTERVAL
)
.await
;
continue
;
}
others
=>
{
panic!
(
"Failed to bind control channel with errno={}"
,
others
);
}
}
}
_
=>
{
bind_succ
=
true
;
break
;
}
};
}
if
!
bind_succ
{
panic!
(
"bind failed too many times!!"
);
}
_
=>
(),
};
tokio
::
spawn
(
async
move
{
debug!
(
"Spawned hci notify task"
);
// Make this into an AsyncFD and start using it for IO
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment