[PATCH] non blocking RPC-code, found reproducable error

From: Martin Blapp <mb_at_imp.ch>
Date: Sat, 17 May 2003 17:43:14 +0200 (CEST)
Hi all,

Here is a patch to solve the problems with amd(8) and mountd(8)
(and maybe other programs):

The patch can also be found here.

http://people.freebsd.org/~mbr/patches/xdr_nonblock_eof_fix.diff

------------------------------------------------------------------------------

Remove the special treatment of non-blocking mode in
xdrrec_eof(). This broke seriously reading serialzed
xdr records. The end of a request could sometimes not
be regognized.

Initialize in_reclen and in_received in a second case.

Return always FALSE in set_input_fragment() for non-blocking
mode.

--- lib/libc/xdr/xdr_rec.c.orig	Thu Feb 27 13:40:01 2003
+++ lib/libc/xdr/xdr_rec.c	Sat May 17 17:20:24 2003
_at__at_ -491,14 +491,6 _at__at_
 	RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
 	enum xprt_stat xstat;

-	if (rstrm->nonblock) {
-		if (__xdrrec_getrec(xdrs, &xstat, FALSE))
-			return FALSE;
-		if (!rstrm->in_haveheader && xstat == XPRT_IDLE)
-			return TRUE;
-		return FALSE;
-	}
-
 	while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) {
 		if (! skip_input_bytes(rstrm, rstrm->fbtbc))
 			return (TRUE);
_at__at_ -617,6 +609,7 _at__at_
 	}

 	*statp = XPRT_MOREREQS;
+	rstrm->in_reclen = rstrm->in_received = 0;
 	return FALSE;
 }

_at__at_ -719,6 +712,8 _at__at_
 {
 	u_int32_t header;

+	if (rstrm->nonblock)
+		return FALSE;
 	if (! get_input_bytes(rstrm, (char *)(void *)&header, sizeof(header)))
 		return (FALSE);
 	header = ntohl(header);

------------------------------------------------------------------------------

Martin

Martin Blapp, <mb_at_imp.ch> <mbr_at_FreeBSD.org>
------------------------------------------------------------------
ImproWare AG, UNIXSP & ISP, Zurlindenstrasse 29, 4133 Pratteln, CH
Phone: +41 61 826 93 00 Fax: +41 61 826 93 01
PGP: <finger -l mbr_at_freebsd.org>
PGP Fingerprint: B434 53FC C87C FE7B 0A18 B84C 8686 EF22 D300 551E
------------------------------------------------------------------
Received on Sat May 17 2003 - 06:43:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:08 UTC