Skip to content

Commit efba9c9

Browse files
author
Rain
authored
Merge pull request #6 from Andrepuel/main
BindingState is set before spawning task
2 parents 3d7a140 + 0cfb16a commit efba9c9

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

crates/turn/src/client/relay_conn.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,13 @@ impl<T: RelayConnObserver + Send + Sync> RelayConnInternal<T> {
259259
let rc_obs = Arc::clone(&self.obs);
260260
let nonce = self.nonce.clone();
261261
let integrity = self.integrity.clone();
262-
tokio::spawn(async move {
263-
{
264-
let mut bm = binding_mgr.lock().await;
265-
if let Some(b) = bm.get_by_addr(&bind_addr) {
266-
b.set_state(BindingState::Request);
267-
}
262+
{
263+
let mut bm = binding_mgr.lock().await;
264+
if let Some(b) = bm.get_by_addr(&bind_addr) {
265+
b.set_state(BindingState::Request);
268266
}
269-
267+
}
268+
tokio::spawn(async move {
270269
let result = RelayConnInternal::bind(
271270
rc_obs,
272271
bind_addr,
@@ -321,14 +320,13 @@ impl<T: RelayConnObserver + Send + Sync> RelayConnInternal<T> {
321320
let rc_obs = Arc::clone(&self.obs);
322321
let nonce = self.nonce.clone();
323322
let integrity = self.integrity.clone();
324-
tokio::spawn(async move {
325-
{
326-
let mut bm = binding_mgr.lock().await;
327-
if let Some(b) = bm.get_by_addr(&bind_addr) {
328-
b.set_state(BindingState::Refresh);
329-
}
323+
{
324+
let mut bm = binding_mgr.lock().await;
325+
if let Some(b) = bm.get_by_addr(&bind_addr) {
326+
b.set_state(BindingState::Refresh);
330327
}
331-
328+
}
329+
tokio::spawn(async move {
332330
let result =
333331
RelayConnInternal::bind(rc_obs, bind_addr, bind_number, nonce, integrity)
334332
.await;

0 commit comments

Comments
 (0)