POSIX states errno is only valid when the return value indicates an
error. recv() sets errno only on -1; when it returns 0 (peer closed)
errno is unspecified.
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Mon Apr 20 09:59:27 2026
(Merged from https://github.com/openssl/openssl/pull/30877)
ret = readsocket(b->num, out, outl);
BIO_clear_retry_flags(b);
if (ret <= 0) {
- if (BIO_sock_should_retry(ret))
- BIO_set_retry_read(b);
- else if (ret == 0)
+ if (ret == 0)
b->flags |= BIO_FLAGS_IN_EOF;
+ else if (BIO_sock_should_retry(ret))
+ BIO_set_retry_read(b);
}
}
return ret;