Fossil SCM
checkin/8da6e3590a1ad6b194fe877474af1571404852afdd173ec4b7273b7bad6e04a7
2 months, 1 week ago by drh
A clone or sync over HTTP/HTTPS could block when the peer stopped sending without closing the connection. The client sat in a blocking read on the socket with no timeout. The trick was to fix it without breaking the TLS handshake.
http_socket.c: set SO_RCVTIMEO and SO_SNDTIMEO (30s) on the connection socket. The fd stays in blocking mode so the TLS handshake is unaffected.
http_ssl.c: when reads time out with SO_RCVTIMEO, there is no data and BIO_should_retry() is true. Count consecutive retries without progress in ssl_send()/ssl_receive() and give up after a few.