Title: Trouble with sysread in modperl

There appears to be a bug with the read and sysread functions when being used in a loop to read STDIN.  We're using a loop to read from STDIN in 4k blocks, and the read or sysread appears to work great until the very last read to pick up the final partial block.  Here is the code:

   $readSize = &min($bytesLeft, $blockReadSize);                          
   $bufferLength  = length($buffer);                                      
   $bytesRead = sysread(STDIN, $dataRead, $readSize);                     
   &html("bytesRead=[$bytesRead . $bufferLength . $dataRead]") if ($debug);
   if (!(defined $bytesRead)) {                                           
       $bytesRead = 0;                                                    
   }                                                                      
   $buffer .= $dataRead;                                                  
In the last loop, the values that are returned in the debug statement are:   674 . 3268 .
So sysread says that 674 bytes were read, however $dataRead is empty.  Both read and sysread exhibit the same behavior, returning the right number of bytes to be read, but not populating the variable with the actual data.  This code works fine in versions of Perl other than Apache modperl.  Has anyone experienced this behavior and have any suggestions?

Reply via email to