You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code of perform_dial_back goes into an infinity loop when an error occurs. I did found out where the error is coming from but I am not sure on how it should be fixed.
let nonce = match protocol::recv_dial_back(&mut state.stream).await{
Ok(nonce) => nonce,
Err(err) => {
returnSome((Err(err), state));
}
};
let(sender, receiver) = oneshot::channel();
state.oneshot = Some(receiver);
Some((Ok(IncomingNonce{ nonce, sender }), state))
})
}
The problem is that, when a result is received from receiver.await, if this result is an error, then the stream fires an Err event but don't do anything to either reset the oneshot channel that was just used, or to terminate the stream.
In my opinion, there is two possible solutions:
1. Terminate the stream
When receiver.await returns Err (meaning the channel is closed), we return None effectively closing the stream.
match receiver.await{Ok(Ok(())) => {}Ok(Err(e)) => returnSome((Err(e), state)),Err(_) => returnNone,// <----------}
2. Reset the oneshot channel
We take the state.oneshot, which will garantee that a receiver can only be polled once.
I am not sure on what is the expected behaviour in such cases, that is why, @umgefahren, if you could look at this and tell me what you think it would be amazing. I will open a PR as soon as I know what is the expected behaviour: stop performing dial_back when any error occurs, or if an error occurs, restart from the beginning.
Summary
The code of
perform_dial_back
goes into an infinity loop when an error occurs. I did found out where the error is coming from but I am not sure on how it should be fixed.rust-libp2p/protocols/autonat/src/v2/client/handler/dial_back.rs
Lines 100 to 136 in 9d3688d
The problem is that, when a result is received from
receiver.await
, if this result is an error, then the stream fires anErr
event but don't do anything to either reset theoneshot
channel that was just used, or to terminate the stream.In my opinion, there is two possible solutions:
1. Terminate the stream
When
receiver.await
returnsErr
(meaning the channel is closed), we returnNone
effectively closing the stream.2. Reset the
oneshot
channelWe
take
thestate.oneshot
, which will garantee that areceiver
can only be polled once.I am not sure on what is the expected behaviour in such cases, that is why, @umgefahren, if you could look at this and tell me what you think it would be amazing. I will open a PR as soon as I know what is the expected behaviour: stop performing dial_back when any error occurs, or if an error occurs, restart from the beginning.
Expected behavior
Do not got into an infinity loop.
Actual behavior
Goes into an infinity loop.
Relevant log output
Possible Solution
No response
Version
Master.
Would you like to work on fixing this bug?
Yes
The text was updated successfully, but these errors were encountered: