stas 2002/08/21 08:40:17
Modified: xs/APR/PerlIO apr_perlio.c
Log:
- try to go without the dup() in the non-perlio case, leave enough
comments to easily reconstruct the dupping code correctly if that proves
to be wrong.
- add some debug tracing code
Revision Changes Path
1.23 +24 -7 modperl-2.0/xs/APR/PerlIO/apr_perlio.c
Index: apr_perlio.c
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/PerlIO/apr_perlio.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- apr_perlio.c 21 Aug 2002 04:46:44 -0000 1.22
+++ apr_perlio.c 21 Aug 2002 15:40:17 -0000 1.23
@@ -525,15 +525,32 @@
/* convert to the OS representation of file */
rc = apr_os_file_get(&os_file, file);
if (rc != APR_SUCCESS) {
- croak("filedes retrieval failed!");
+ Perl_croak(aTHX_ "filedes retrieval failed!");
}
-
- fd = PerlLIO_dup(os_file);
- /* Perl_warn(aTHX_ "fd old: %d, new %d\n", os_file, fd); */
-
- if (!(retval = PerlIO_fdopen(fd, mode))) {
+
+#ifdef PERLIO_APR_DEBUG
+ Perl_warn(aTHX_ "converting fd %d\n", os_file);
+#endif
+
+ /* let's try without the dup, it seems to work fine:
+
+ fd = PerlLIO_dup(os_file);
+ Perl_warn(aTHX_ "fd old: %d, new %d\n", os_file, fd);
+ if (!(retval = PerlIO_fdopen(fd, mode))) {
+ ...
+ }
+
+ in any case if we later decide to dup, remember to:
+
+ apr_file_close(file);
+
+ after PerlIO_fdopen() or that fh will be leaked
+
+ */
+
+ if (!(retval = PerlIO_fdopen(os_file, mode))) {
PerlLIO_close(fd);
- croak("fdopen failed!");
+ Perl_croak(aTHX_ "fdopen failed!");
}
return retval;