`tcpip.stack-unix` has a bug about `accept` when we initiate a TCP connection
dinosaure opened this issue · 4 comments
This is related to the recent update on #457 when, if we only initiate a TCP connection and we don't use Tcpip_socket.V4V6.connect
, the switched_off
fiber is never updated into the TCP stack and we always cancel the listen
fiber here:
mirage-tcpip/src/stack-unix/tcpv4v6_socket.ml
Line 154 in 3ab30ab
A solution should be to set by default a fiber on the switched_off
value which never finish:
let never, _ = Lwt.wait () in
Lwt.return {interface; active_connections = []; listen_sockets = Hashtbl.create 7; switched_off = never}
sorry about this. I'll have a PR later today to fix the issue you encountered.
see #465 - does this fix your issue appropriately? (I still do not understand the switched_off
code completely, i.e. who's evercancelling that promise?
do we need to somehow forward a cancellation of the tcpip_stack_socket switched_off
promise to the udp & tcp switched_off promises?
I think your first version is right (and disconnect
should cancel every listen
as you did before). The problem is mostly when we only want the TCP stack and we don't use Stack.connect
which sets switched_off
correctly. The behavior with my patch below says that, by default and if you want to only create a TCP stack, nothing can cancel the listening loop (for the Unix purpose).
May be a composition between the default switched_off
and the switched_off
created under Stack.connect
should be the best solution. I will try to figure out a proper solution.