9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Russ Cox" <rsc@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] fs error msg: didn't like (1460 274) byte message
Date: Wed, 25 Sep 2002 14:24:23 -0400	[thread overview]
Message-ID: <a14e85571895b8ff58bc08d27aa878ae@plan9.bell-labs.com> (raw)

The problem is the buffer can be arbitrarily sized, though
typically 8192+IOHDRSZ is the max a client and server will
agree on.  Cpu uses a much larger max size to improve graphics
performance.

Here's a fixed xfer9p.  I forgot that the initial count
includes itself.

void
xfer9p(int from, int to)
{
	char *buf;
	uint nbuf;
	int n;

	nbuf = 256;
	buf = malloc(nbuf);
	if(buf == nil)
		sysfatal("xfer: malloc %ud: %r", nbuf);

	for(;;){
		if(readn(from, buf, 4) != 4)
			break;
		n = GBIT32(buf);
		if(n > nbuf){
			nbuf = n+8192;	/* 8192: slop */
			buf = realloc(buf, nbuf);
			if(buf == nil)
				sysfatal("xfer: realloc %ud: %r", nbuf);
		}
		if(readn(from, buf+4, n-4) != n-4)
			break;
		if(write(to, buf, n) != n)
			break;
	}
}

Russ


             reply	other threads:[~2002-09-25 18:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-25 18:24 Russ Cox [this message]
2002-09-25 18:44 ` Axel Belinfante
2002-09-25 21:12 ` Axel Belinfante
  -- strict thread matches above, loose matches on Subject: below --
2002-09-25 21:30 Russ Cox
2002-09-26  8:49 ` Axel Belinfante
2002-09-25 21:21 Russ Cox
2002-09-24 23:42 Russ Cox
2002-09-25 11:45 ` Axel Belinfante
2002-09-25 18:19 ` Axel Belinfante
2002-09-24 23:25 Axel Belinfante

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a14e85571895b8ff58bc08d27aa878ae@plan9.bell-labs.com \
    --to=rsc@plan9.bell-labs.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).