Steve Hay wrote:
Stas Bekman wrote:
Steve Hay wrote:
Stas Bekman wrote:
Steve Hay wrote:
Me again!
One more test failure on the usual Win32 setup (2.0.47 / [EMAIL PROTECTED] / mp2-cvs):
=====
C:\Temp\modperl-2.0>perl t/TEST -verbose t/apr/perlio.t
C:\apache2/bin/Apache.exe -d C:/Temp/modperl-2.0/t -f C:/Temp/modperl-2.0/t/con
# testing : read/write a dupped file # expected: This is a test: 3384 # received: This is a test: 3384 not ok 10
Thanks Steve, Randy has already reported this issue, but he didn't have a chance to debug it. Can you try and see why does it prepend the space when reading from a file? e.g. test the file itself, it could be that it wrote the space in there.
You need to poke in xs/APR/PerlIO/apr_perlio.c
most likely inside: PerlIOAPR_read
Right. I've put a breakpoint on the apr_file_read() call (apr_perlio.c, line 166) so I catch the offending test as soon as it reaches the "my $received = <$dup_fh>;" bit. (The other tests are commented out.)
What I find is that when we first go inside apr_file_read(), thefile->ungetchar is 0. This makes it put that value (i.e. a null char, 0x00) into the space pointed to by buf, advances the buf pointer itself (ready for reading in the next character) and returns APR_SUCCESS.
Thus, the first character put into *(char *)vbuf by PerlIOAPR_read() is a null char. Presumably this is the problem?
(Check: Adding:
my $char = $received; $char =~ s/^(.).*$/$1/; print "First character is ", ord($char), "\n";
after the failing read produces this output:
First character is 0
i.e. it is a leading null character (0), not a space character (32).)
I don't know what to do about this. I tried slipping "apr_file_ungetc(-1, st->file);" into PerlIOAPR_open() and PerlIOAPR_dup(), but that just leads to thefile->ungetchar being set to 255 (because apr_file_ungetc() casts the supplied char to an unsigned char before assigning it!). So the ungetchar is still done since 255 != -1 either. Obviously not the way to fix it :-(
very nice ;) looks like a bug in apr, obviously untested :
Excellent - your patch (below) fixes this test:
C:\Temp\modperl-2.0>perl t/TEST -verbose t/apr/perlio.t ... # testing : read/write a dupped file # expected: This is a test: 2108 # received: This is a test: 2108 ok 10 ...
(and the rest of the testsuite (skipping filter, hooks and modules) also still passes OK too).
Shall I leave you to submit that to the Apache guys, then, seeing as you cracked it?
- Steve
Index: apr/file_io/win32/filedup.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/win32/filedup.c,v
retrieving revision 1.54
diff -u -r1.54 filedup.c
--- apr/file_io/win32/filedup.c 7 Jan 2003 00:52:53 -0000 1.54
+++ apr/file_io/win32/filedup.c 18 Sep 2003 21:13:11 -0000
@@ -81,7 +81,8 @@
(*new_file)->fname = apr_pstrdup(p, old_file->fname);
(*new_file)->append = old_file->append;
(*new_file)->buffered = FALSE;
-
+ (*new_file)->ungetchar = old_file->ungetchar;
+
apr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file), file_cleanup,
apr_pool_cleanup_null);
@@ -150,6 +151,7 @@ new_file->fname = apr_pstrdup(new_file->pool, old_file->fname); new_file->append = old_file->append; new_file->buffered = FALSE; + new_file->ungetchar = old_file->ungetchar;
return APR_SUCCESS;
#endif /* !defined(_WIN32_WCE) */
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
