cvsuser 03/05/27 12:05:30
Modified: . io.ops
docs faq.pod
io io_buf.c
Log:
The following patch fixes the internal problem that was causing the core
dumps I mentioned in follow-ups to #22330. Both fixes within io.ops are
obviously incomplete - an exception needs to be generated for attempting
to conduct IO operations on a bad file descriptor. It's not clear to me
whether sufficient exceptions exist, nor how to use them if they do.
Courtesy of Bryan Warnock <[EMAIL PROTECTED]>
Revision Changes Path
1.19 +17 -10 parrot/io.ops
Index: io.ops
===================================================================
RCS file: /cvs/public/parrot/io.ops,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -w -r1.18 -r1.19
--- io.ops 20 May 2003 11:11:08 -0000 1.18
+++ io.ops 27 May 2003 19:05:25 -0000 1.19
@@ -144,10 +144,15 @@
=cut
inline op close(inout INT) {
- ParrotIOTable table = ((ParrotIOData*)interpreter->piodata)->table;
- ParrotIO *io = table[$1];
+ ParrotIOTable table;
+ ParrotIO *io;
+
+ if ($1 >= 0) {
+ table = ((ParrotIOData*)interpreter->piodata)->table;
+ io = table[$1];
table[$1] = NULL;
PIO_close(interpreter, io);
+ }
goto NEXT();
}
@@ -379,15 +384,17 @@
=cut
inline op readline(out STR, in INT) {
- ParrotIO *io = ((ParrotIOData*)interpreter->piodata)->table[$2];
- size_t len;
-
+ ParrotIO *io;
+ size_t len = 0;
$1 = string_make(interpreter, NULL, 65535, NULL, 0, NULL);
memset(($1)->strstart, 0, 65535);
+ if ($2 >= 0) {
+ io = ((ParrotIOData*)interpreter->piodata)->table[$2];
PIO_setlinebuf(interpreter, io);
len = PIO_read(interpreter, io, ($1)->strstart, 65534);
($1)->strlen = ($1)->bufused = len;
+ }
goto NEXT();
}
1.9 +4 -0 parrot/docs/faq.pod
Index: faq.pod
===================================================================
RCS file: /cvs/public/parrot/docs/faq.pod,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- faq.pod 15 Dec 2002 19:17:56 -0000 1.8
+++ faq.pod 27 May 2003 19:05:27 -0000 1.9
@@ -339,6 +339,10 @@
L<Really.|"LINKS">
+=head2 You're not using reference counting. Why not?
+
+=head2 Could we do a partial refcounting scheme?
+
=head1 LINKS
April Fool's Joke: http://www.perl.com/pub/a/2001/04/01/parrot.htm
1.5 +5 -1 parrot/io/io_buf.c
Index: io_buf.c
===================================================================
RCS file: /cvs/public/parrot/io/io_buf.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -r1.4 -r1.5
--- io_buf.c 20 May 2003 11:11:10 -0000 1.4
+++ io_buf.c 27 May 2003 19:05:30 -0000 1.5
@@ -1,7 +1,7 @@
/* io_buf.c
* Copyright: (When this is determined...it will go here)
* CVS Info
- * $Id: io_buf.c,v 1.4 2003/05/20 11:11:10 leo Exp $
+ * $Id: io_buf.c,v 1.5 2003/05/27 19:05:30 dan Exp $
* Overview:
* The "buf" layer of Parrot IO. Buffering and all the fun stuff.
*
@@ -96,6 +96,10 @@
}
io = (*l->api->Open) (interpreter, l, path, flags);
+ if (!io) {
+ /* error creating IO stream */
+ return NULL;
+ }
/*
* We have an IO stream now setup stuff
* for our layer before returning it.