net_Read: rewrite, fix corner cases (fix #8972)
This new implementation opportunistically tries to read data before invoking poll(). This reduces latency when data is already waiting in buffers, allows receiving pending data in non-blocking fashion even if the object has been killed. This also gives GnuTLS a chance to dequeue data from internal buffers. Also the corner case of 0 read should now be handled correctly. The corner case of an error after success read is no longer handled. This was race-prone and useless.
Showing with 50 additions and 94 deletions