cvsuser 04/01/18 02:24:34
Modified: . CREDITS
io io_buf.c
Log:
biofixes.patch
The attached patch fixes the above two bugs:
a) when the buffer is full, it is not completely flushed; fixed.
b) setbuf sets b->size to PIO_GRAIN (and wrongly sets io->flags) when
passed 0. The patch sets b->size to 0 - hope it is the expected
behavior.
Courtesy of Arvindh Rajesh Tamilmani
Revision Changes Path
1.16 +7 -4 parrot/CREDITS
Index: CREDITS
===================================================================
RCS file: /cvs/public/parrot/CREDITS,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -w -r1.15 -r1.16
--- CREDITS 13 Jan 2004 09:21:17 -0000 1.15
+++ CREDITS 18 Jan 2004 10:24:32 -0000 1.16
@@ -19,18 +19,21 @@
N: Aldo Calpini
+N: Alex Gough
+
N: Andy Dougherty
D: Config and building.
-N: Alex Gough
-
N: Angel Faus
D: CFG and live analysis.
-N: Ask Bjoern Hansen
-
N: Arthur Bergman
D: Trying to ride a Ponie - build and compat fixes.
+
+N: Arvindh Rajesh Tamilmani
+D: Buffered IO fix
+
+N: Ask Bjoern Hansen
N: Benjamin Goldberg
D: Numerous improvements and proposals.
1.21 +20 -11 parrot/io/io_buf.c
Index: io_buf.c
===================================================================
RCS file: /cvs/public/parrot/io/io_buf.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -w -r1.20 -r1.21
--- io_buf.c 9 Dec 2003 17:44:55 -0000 1.20
+++ io_buf.c 18 Jan 2004 10:24:34 -0000 1.21
@@ -1,7 +1,7 @@
/* io_buf.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: io_buf.c,v 1.20 2003/12/09 17:44:55 boemmels Exp $
+ * $Id: io_buf.c,v 1.21 2004/01/18 10:24:34 leo Exp $
* Overview:
* The "buf" layer of Parrot IO. Buffering and all the fun stuff.
*
@@ -119,11 +119,16 @@
PIO_buf_flush(interpreter, l, io);
/* Choose an appropriate buffer size for caller */
- if (bufsize == PIO_UNBOUND) {
+ switch (bufsize) {
+ case 0:
+ b->size = 0;
+ break;
+ case PIO_UNBOUND:
b->size = PIO_getblksize(io->fd);
- }
- else {
+ break;
+ default:
b->size = (bufsize >= PIO_GRAIN ? bufsize : PIO_GRAIN);
+ break;
}
if (b->startb && (b->flags & PIO_BF_MALLOC)) {
@@ -135,8 +140,10 @@
b->startb = b->next = mem_sys_allocate(b->size);
b->flags |= PIO_BF_MALLOC;
}
+ else
+ b->flags &= ~PIO_BF_MALLOC;
- if (bufsize != 0)
+ if (b->size != 0)
io->flags |= PIO_F_BLKBUF;
else
io->flags &= ~(PIO_F_BLKBUF | PIO_F_LINEBUF);
@@ -442,11 +449,13 @@
io->b.flags |= PIO_BF_WRITEBUF;
/* Fill remainder, flush, then try to buffer more */
- memcpy(io->b.next, buffer, diff);
+ memcpy(io->b.next, buffer, avail);
+ io->b.next += avail;
+ io->fpos += avail;
PIO_buf_flush(interpreter, layer, io);
- memcpy(io->b.startb, ((const char *)buffer + diff), len - diff);
- io->b.next = io->b.startb + (len - diff);
- io->fpos += len;
+ memcpy(io->b.startb, ((const char *)buffer + avail), diff);
+ io->b.next += diff;
+ io->fpos += diff;
return len;
}
return (size_t)-1;