Do not invoke accept() on an already-established connection #105
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
First of all, thanks a lot for writing and maintaining the Rust reference implementation of varlink!
Here's a proposed fix for #73; the
Listener::new()
method already records the fact that this listener is actually a connection that has already been established via socket activation, and lets theListener::accept()
method honor that flag.I have written a trivial
varlink
server - my varlink-hello GitLab project - to demonstrate the need for this change. Without it, with the stockvarlink 11.0.1
crate, thevarlink-hello
program fails, sinceListener::accept()
attempts to invoke theaccept()
method of the "Unix listener" which is actually an already-connected socket.Now, there are three things I don't completely like about this patch:
unsafe { ... }
inListener::accept()
. A cleaner way to do that would be to add two new values to theListener
enum, e.g.TCPAccepted
andUNIXAccepted
, and makeListener::new()
create aTcpListener
or aUnixListener
directly, in its ownunsafe { ... }
blocks. This might cause a bit of code churn; let me know if I should do it.varlink-hello
program under Windows and see if a) it fails with the currently-releasedvarlink
crate, and b) this change fixes it.test_listen()
function invarlink/src/tests.rs
, create a socketpair, and go for it, but the problem is that to really test it, theLISTEN_FDS
,LISTEN_FDNAMES
, andLISTEN_PID
environment variables need to be set, which might influence other tests run either at the same time or later. I'd be grateful for any ideas on how to approach this; writing a new binary crate that will only be used for testing almost seems like a viable approach, even though Cargo currently does not support test-only binary crates.Thanks in advance for your time, and keep up the great work!
G'luck,
Peter