Hi,
In using mod_perl 1.28 on Linux (Slackware 8.1) with Apache
(Server: Apache/1.3.24 (Unix) mod_ssl/2.8.8 OpenSSL/0.9.6c mod_perl/1.28 PHP/4.3.1)
I have had problems with scripts that read from STDIN.
In particular the problem arises when attempting to call read() to read from
STDIN into a buffer. The result was that read would return the correct number
of bytes read, but the buffer would be empty.
Further investigation showed that if the requested number of bytes was less
than or equal to the available amount of input then the call would be
successful, otherwise the buffer would come back undefined. In the case that
the requested number of bytes was larger than the available number of bytes,
the returned number of bytes would still equal the available number of bytes.
This ultimately lead to looking at the implementation of read() in Apache.pm.
It would seem that there is a slight bug in the handling of the return values
from read_client_block().
The patch below will change the behaviour to be more in line with the expected
behaviour of read().
Thanks
Stewart
--
Stewart Gebbie <[EMAIL PROTECTED]>
--- Apache.pm-1.28 2003-07-24 10:58:26.000000000 +0200
+++ Apache.pm-fixed-read 2003-07-24 10:58:55.000000000 +0200
@@ -76,7 +76,7 @@
while($bufsiz) {
$nrd = $r->read_client_block($buf, $bufsiz) || 0;
- if(defined $nrd and $nrd > 0) {
+ if(defined $nrd and $nrd >= 0) {
$bufsiz -= $nrd;
if ($offset) {
substr($_[1], $offset) .= $buf;
@@ -86,6 +86,7 @@
$_[1] .= $buf;
}
$total += $nrd;
+ last if $nrd == 0;
next if $bufsiz;
last;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]