From a05b2d5b015c45138fe1d070c73380ffebab2070 Mon Sep 17 00:00:00 2001 From: Packit Date: Sep 15 2020 11:20:59 +0000 Subject: Apply patch libtirpc-1.1.4-fix-EOF-non-block.patch patch_name: libtirpc-1.1.4-fix-EOF-non-block.patch present_in_specfile: true location_in_specfile: 3 --- diff --git a/src/svc_vc.c b/src/svc_vc.c index 97a76a3..c23cd36 100644 --- a/src/svc_vc.c +++ b/src/svc_vc.c @@ -502,9 +502,14 @@ read_vc(xprtp, buf, len) cfp = (struct cf_conn *)xprt->xp_p1; if (cfp->nonblock) { + /* Since len == 0 is returned on zero length + * read or EOF errno needs to be reset before + * the read + */ + errno = 0; len = read(sock, buf, (size_t)len); if (len < 0) { - if (errno == EAGAIN) + if (errno == EAGAIN || errno == EWOULDBLOCK) len = 0; else goto fatal_err; diff --git a/src/xdr_rec.c b/src/xdr_rec.c index 7d535cf..676cc82 100644 --- a/src/xdr_rec.c +++ b/src/xdr_rec.c @@ -61,6 +61,7 @@ #include #include #include +#include #include "rpc_com.h" static bool_t xdrrec_getlong(XDR *, long *); static bool_t xdrrec_putlong(XDR *, const long *); @@ -537,7 +538,13 @@ __xdrrec_getrec(xdrs, statp, expectdata) n = rstrm->readit(rstrm->tcp_handle, rstrm->in_hdrp, (int)sizeof (rstrm->in_header) - rstrm->in_hdrlen); if (n == 0) { - *statp = expectdata ? XPRT_DIED : XPRT_IDLE; + /* EAGAIN or EWOULDBLOCK means a zero length + * read not an EOF. + */ + if (errno == EAGAIN || errno == EWOULDBLOCK) + *statp = XPRT_IDLE; + else + *statp = expectdata ? XPRT_DIED : XPRT_IDLE; return FALSE; } if (n < 0) { @@ -564,6 +571,7 @@ __xdrrec_getrec(xdrs, statp, expectdata) rstrm->in_header &= ~LAST_FRAG; rstrm->last_frag = TRUE; } + rstrm->in_haveheader = 1; } n = rstrm->readit(rstrm->tcp_handle, @@ -576,7 +584,13 @@ __xdrrec_getrec(xdrs, statp, expectdata) } if (n == 0) { - *statp = expectdata ? XPRT_DIED : XPRT_IDLE; + /* EAGAIN or EWOULDBLOCK means a zero length + * read not an EOF. + */ + if (errno == EAGAIN || errno == EWOULDBLOCK) + *statp = XPRT_IDLE; + else + *statp = expectdata ? XPRT_DIED : XPRT_IDLE; return FALSE; }