Comments (5)
This is the normal ZMQ behavior, unless I'm missing something.
ZMQ supports two modes for shutting down the context. The first and default is that zmq_ctx_destroy
will block until all the sockets are shut down across all of the threads. This is so ZMQ can guarantee all the messages have hit the underlying OS sockets. However this mechanism can cause a deadlock, because a ZMQ_REQ
could be stuck waiting for a reply that may never happen. To avoid this scenario, you can set the socket option ZMQ_LINGER on the socket, as in socket.set_linger(100)
. This will give that ZMQ socket 100ms to finish it's IO before ZMQ will kill the OS socket and destroy the context.
I'm going to close this issue, but please feel free to reopen if I misinterpreted your problem.
from rust-zmq.
I can't reopen, but I think it should. I know this is how zmq works, but I think the wrapper is potentially incorrect. If you create sockets, and if their destructors don't get called before the context's destructor does, there will be an accidental hang.
from rust-zmq.
Note that it's not anything the user can control, it's the order the compiler decides to call constructors in. I imagine it'd do it in reverse creation order, but it needs to be verified.
from rust-zmq.
I get what you are saying, but is there any way to express this destructor dependency between contexts and sockets? Someone could always write:
fn bad() -> zmq::Socket {
Let ctx = zmq::Context::new().unwrap();
ctx.socket(zmq::ZMQ_REQ)
}
I don't think we can prevent that at compile time. Especially as we want to support moving sockets between threads.
The only other option I can think of is to just remove the destructors and potentially leak sockets/contexts. I'm not crazy about that idea though.
from rust-zmq.
Hrm, tricky. Don't think there's a nice way to do this "properly" :\
from rust-zmq.
Related Issues (20)
- [feature] `Hash`able `SocketType`
- libstdc++ not found 'cargo run'
- Uft8Error when reciving HOT 3
- Target armv7-unknown-linux-musleabihf HOT 1
- Vendor Feature removed for version 10? HOT 1
- Sockets are Send but not thread-safe HOT 4
- Cannot build with stable-x86_64-pc-windows-gnu
- Example in README.md hangs HOT 1
- Compilation troubles with msys2 HOT 1
- Cannot cross-compile to x86_64-pc-windows-gnu HOT 2
- Checking curve support fails in 0.10.0 HOT 1
- set_xpub_verboser method is missing
- Static linking issue with x86_64-unknown-linux-gnu on a linux x86_64 system
- Dropping socket over which data has been sent (but no receiver has connected to) hangs. HOT 1
- What happened to dynamic linking?
- fails to build with glibc 2.38 HOT 5
- Memory leak in test `test_z85`
- ipc with XPUB and XSUB not working HOT 1
- Error: "failure to bind zmq socket", but the publisher still behaves functionally despite this.
- [Github Repo Issue] Wiki Permission HOT 1
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 rust-zmq.