Non blocking svc std::net::TcpStream gets stuck in the WouldBlock loop even though clt TcpStream is shutdown

This only happens on Linux but works fine on Darwin and when criterion is used to do clt.read , however when a standard for loop is used all works fine

  • Example contains a main function which in-turn calls two for the most part identical functions
let _ = clt2svc_without_criterion();
let _ = clt2svc_with_criterion();
  • Both functions have the same objective
    • create and connect two non-blocking TcpStream’s to each other
      1. clt TcpStream, will connect from main thread
      2. svc TcpStream, will be accepted from Svc-Thread thread
    • svc TcpSteam will continually write to the socket untill it gets an io::std::Error
    • clt TcpStream will continually read N number of times and then issue clt.shutdown(Shutdown::Both)
    • The only difference between two functions is one uses criterion to measure the read speed and the other a standard for loop. However the one that uses criterion variant hangs as the svc TcpStrem gets ErrorKind::WouldBlock instead of ErrorKind::BrokenPipe

Full Example