-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: stream needs to be spawned in new thread #47
Comments
Looking into this, it seems like the reason the initial case (where we spawn the connect in a separate thread) is passing is only b/c we're not awaiting the handle. At least locally, if we await the handle in the first case, then we get the same error as emitted in the second case. |
I was able to modify the above test to reach a passing state #[tokio::test]
async fn test_transfer_100k_bytes() {
// set-up test
tracing_subscriber::fmt::init();
let sender_addr = SocketAddr::from(([127, 0, 0, 1], 3400));
let receiver_addr = SocketAddr::from(([127, 0, 0, 1], 3401));
let sender = UtpSocket::bind(sender_addr).await.unwrap();
let receiver = UtpSocket::bind(receiver_addr).await.unwrap();
let config = ConnectionConfig::default();
// write 100k bytes data to the remote peer over the stream.
let data = vec![0xef; 100_000];
let rx_handle = tokio::spawn(async move {
receiver.accept(config).await.unwrap();
});
let mut tx_stream = sender.connect(receiver_addr, config).await.unwrap();
tx_stream
.write(data.as_slice())
.await
.expect("Should send 100k bytes");
rx_handle.await.unwrap();
} Imo, it doesn't appear as though this issue identified a bug, but it is an indication that this library needs better documentation on how to use it's public api.
|
Great work! Standard is to document public API. @njgheorghita |
Closed for #53 |
The
connect
method onUtpSocket<P>
fails when called in the same thread that we bound to theUtpSocket
.This code with a stream created in
tokio::spawn
ran in stream.rs passesand this code creating a stream in the same thread fails with error
thread 'stream::test::test_start_stream panicked at 'called Result::unwrap() on an Err value: Kind(TimedOut)', src/stream.rs:137:76
, on my branch improving error handling the error is more helpfulthread 'stream::test::test_start_stream panicked at 'called Result::unwrap() on an Err value: ConnInit(MaxConnAttempts)', src/stream.rs:146:76
.The reason for why this is the case needs to be identified, it might be the root of several bugs. It could be that the explanation is straight forward and then the thread spawning code should simply be abstracted away into the
connect
function sinceconnect
is part of the public API and this peculiar requirement is not documented.The text was updated successfully, but these errors were encountered: