[net.news.b] Bug fix for vnews

lee@west44.UUCP (Lee McLoughlin) (06/04/84)

There is a bug in vnews where while flushing output an interrupt may occur
when part of the output has been done.  When the interrupt has been handled
the flush is restart from scratch NOT from where it left off, resulting in
a corrupt screen.

Replace vflush() in visual.c by this fixed version:

/*
 * Flush the output buffer
 */

vflush()
{
	register char *p;
	register int i;
	unsigned oldalarm;
	
	/* LMCL: On getting a clock interrupt the write was failing and having
	 * to be redone.  This caused the screen to be corrupted since it meant
	 * that (for example) if five lines had been output when the interrupt
	 * occurred then the same five lines would be output again at a
	 * different position.  By disabling the timer and restarting it once
	 * the write was complete this is avoided.
	 */
	oldalarm = alarm( (unsigned)0 ); /* Suspend clock interrupts while writing */

	for (p = outbuf ; p < outnext ; p += i) {
		if ((i = write(1, p, outnext - p)) < 0) {
			if (errno != EINTR)
				abort();	/* "Can't happen" */
			i = 0;
		}
	}
	outnleft = BUFSIZ;
	outnext = outbuf;

	alarm( oldalarm );	/* LMCL: Reset the timer. */
}
-- 
"The wizard of OS"	Lee McLoughlin	....!ukc!root44!west44!lee
					....!ukc!lmcl