From xemacs-m  Mon Dec 16 18:38:10 1996
Received: from altair.xemacs.org (steve@xemacs.miranova.com [206.190.83.19]) by xemacs.cs.uiuc.edu (8.8.3/8.8.3) with ESMTP id SAA28047 for <xemacs-beta@xemacs.org>; Mon, 16 Dec 1996 18:38:09 -0600 (CST)
Received: (from steve@localhost)
          by altair.xemacs.org (8.8.4/8.8.4)
	  id QAA00709; Mon, 16 Dec 1996 16:48:07 -0800
Sender: steve@xemacs.org
To: xemacs-beta@xemacs.org
Subject: Re: Writing at end of disk -- critical XEmacs bug
References: <m2n2ve3ul0.fsf@altair.xemacs.org>
X-Url: http://www.miranova.com/%7Esteve/
Mail-Copies-To: never
X-Face: #!T9!#9s-3o8)*uHlX{Ug[xW7E7Wr!*L46-OxqMu\xz23v|R9q}lH?cRS{rCNe^'[`^sr5"
 f8*@r4ipO6Jl!:Ccq<xoV[Qz2u8<8-+Vwf2gzJ44lf_/y9OaQ`@#Q65{U4/TC)i2`~/M&QI$X>p:9I
 OSS'2{-)-4wBnVeg0S\O4Al@)uC[pD|+
X-Attribution: sb
From: Steven L Baur <steve@miranova.com>
In-Reply-To: Steven L Baur's message of 16 Dec 1996 16:03:55 -0800
Mime-Version: 1.0 (generated by tm-edit 7.96)
Content-Type: text/plain; charset=US-ASCII
Date: 16 Dec 1996 16:48:05 -0800
Message-ID: <m2k9qi3sje.fsf@altair.xemacs.org>
Lines: 46
X-Mailer: Red Gnus v0.72/XEmacs 19.15

The bug is indicated (there is no error being reported).  Could
someone who is familiar with the disk code (Ben?) suggest a safe fix?

In my test case, 31,744 bytes get written out of 40,208 which should
still be reported as an error.

lstream.c:
int
Lstream_flush_out (Lstream *lstr)
{
  int num_written;

...
      num_written =
	(lstr->imp->writer) (lstr, lstr->out_buffer, size);
      if (num_written == 0)
	/* If nothing got written, then just hold the data.  This may
	   occur, for example, if this stream does non-blocking I/O;
	   the attempt to write the data might have resulted in an
	   EWOULDBLOCK error. */
	return 0;
      else if (num_written >= lstr->out_buffer_ind)
	lstr->out_buffer_ind = 0;
      else if (num_written > 0)            <===========
	{                                  <===========
	  memmove (lstr->out_buffer, lstr->out_buffer + num_written,
		   lstr->out_buffer_ind - num_written);
	  lstr->out_buffer_ind -= num_written;
	}
      else
	/* If error, just hold the data, for similar reasons as above. */
	return -1;
    }

  if (lstr->imp->flusher)
    return (lstr->imp->flusher) (lstr);

  return 0;
}


-- 
steve@miranova.com baur
Unsolicited commercial e-mail will be billed at $250/message.
"That Bill Clinton.  He probably doesn't know how to log on to the
Internet."  -- Rush Limbaugh, noted Computer Expert

