Unlisten sockets after they disconnect#580
Conversation
44242ce to
40571fe
Compare
src/hostnet_test/test_half_close.ml
Outdated
| (* Now that a server is running, connect to an invalid port and ensure it fails quickly *) | ||
| let open Slirp_stack in | ||
| let ip = Ipaddr.V4.localhost in | ||
| let port = server.Server.port + 1 in |
There was a problem hiding this comment.
Perhaps on the Windows machine server.Server.port + 1 was used?
**** Starting test TCP: test server invalid port
...
9.09694 [ERROR] Connected to localhost:1986
Maybe quickly allocating and deallocating a port will be more reliable, like
with_server (fun _ -> Lwt.return_unit) (fun server -> Server.destroy server >>= fun () -> Lwt.return server.Server.port)
>>= fun invalid_port ->There was a problem hiding this comment.
Probably, in that case, it becomes pretty similar than the next test which ensure connection succeeds first and then destroys the server (which is also closer to the actual reported issue)
9e3849a to
5dfdfcd
Compare
|
Regarding the Windows failure: it might be a Windows firewall issue on the test running machine. Perhaps the test should be gated with something like if Sys.os_type = "Win32" then begin
...
end else begin
...
endOr maybe a timeout problem? This Go program: package main
import (
"fmt"
"net"
"time"
)
func main(){
start := time.Now()
_, err := net.Dial("tcp", "127.0.0.1:8080")
if err != nil {
fmt.Printf("rejected after %s\n", time.Since(start))
return
}
fmt.Printf("connected after %s\n", time.Since(start))
}takes >2s: |
After a successful connection forwarding to a server, if the server disappears, a tentative to connect the server again will be accepted by vpnkit even if vpnkit failed to reach the server. Ensure this does not occur by calling unlisten. Add test for valid and invalid connection cases Signed-off-by: Frédéric Dalleau <frederic.dalleau@docker.com>
5dfdfcd to
a64974d
Compare
djs55
left a comment
There was a problem hiding this comment.
LGTM (and Mac and Windows CI are green!)
|
i feel lucky today because this bug i hit today has already been fixed. thank you! (i was investigating something not working well, which polls the availability of a service by tcp-connecting it.) |
After a successful connection forwarding to a server, if the server
disappears, a tentative to connect the server again will be accepted by
vpnkit even if vpnkit failed to reach the server.
Ensure this does not occur by calling unlisten.
Add test for valid and invalid connection cases
Signed-off-by: Frédéric Dalleau frederic.dalleau@docker.com