Comments (2)
This is an interesting issue.
I think that we are going to need to cancel in-flight operations and wait for them to finish terminating. Unfortunately, for soundness reasons you cannot simply drop tasks exit the runtime like you can with normal tokio. Because these operations are in-flight with the kernel, we cannot exit until they complete because the kernel may be using buffers and other state that we have pinned within the runtime.
I'm gonna take some time today to think about this.
from tokio-uring.
I've ran into the same problem which makes it impossible for me to run integration tests in CI since they never exit properly. I can't use the same hack @dpc used. I have a custom socket type based on Udp spawning the following task:
// Net loop
tokio_uring::spawn(async move {
let mut recv_buf = vec![0; 1024 * 1024];
loop {
// process_incomming doesn't spawn any tasks and net_loop_socket is a UdpSocket
tokio::select! {
buf = process_incomming(&net_loop_socket, &streams_clone, &accept_chan, std::mem::take(&mut recv_buf)) => {
recv_buf = buf;
}
_ = &mut shutdown_receiver => {
log::info!("Shutting down network loop");
// TODO shutdown all streams gracefully
break;
}
}
}
});
Within the process_incomming
function a call to UdpSocket
recv_from
is blocking at the beginning of the function:
async fn process_incomming(
socket: &Rc<UdpSocket>,
connections: &Rc<RefCell<HashMap<StreamKey, WeakUtpStream>>>,
accept_chan: &Rc<RefCell<Option<tokio::sync::oneshot::Sender<UtpStream>>>>,
recv_buf: Vec<u8>,
) -> Vec<u8> {
let (result, buf) = socket.recv_from(recv_buf).await;
/// snip...
}
Here is the socket drop implementation
fn drop(&mut self) {
// a tokio oneshot channel
println!("Droppping!");
let _ = self.shutdown_signal.take().unwrap().send(());
}
What I can see from the output of my tests is the following:
Dropping!
[2022-09-18T10:09:16Z TRACE mio::poll] deregistering event source from poller
I would expect to see Shutting down network loop
to be printed and that the tokio_uring::start
to exit without hanging. I tried to get rid of the oneshot
channel and instead use the JoinHandle
of the task directly to abort the spawned task but still end up with the same problem. @Noah-Kennedy I presume the underlying issue is the same here?
from tokio-uring.
Related Issues (20)
- Support for reference counted buffers
- Proposal for overhaul of buffer representation HOT 11
- multi_thread support HOT 5
- Direct IO HOT 2
- Support _msg syscalls HOT 4
- impl Clone for stream types?
- Add chunks() for BoundedBuf
- Not in a runtime context is not always true HOT 5
- Return msghdr from `recvmsg`
- DPDK support? HOT 5
- Dead or dying? HOT 9
- Support for windows IOCP (input/output completion ports) another completion-based async API HOT 1
- Is it support `splice` operation now?
- New Release? HOT 3
- tokio-uring missing similar tokio runtime builder options
- io_uring command support? HOT 3
- Support for IO_LINK feature
- Restructuring HOT 2
- __io_uring_buf_ring_cq_advance broken? HOT 1
- [BUG] Hangs when using iopoll without sqpoll HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokio-uring.