From: <jgr...@us...> - 2003-02-17 22:19:01
|
Update of /cvsroot/popfile/engine In directory sc8-pr-cvs1:/tmp/cvs-serv1781 Modified Files: popfile.pl Log Message: New pipready() helper subroutine in popfile.pl to test in a platform independent way whether a pipe is ready since Windows and non-Windows differ; new Proxy::POP3::flush_child_data routine used to move data out of the child pipes; flush_child_data now called in service and the reaper for POP3 so that we handle pipe data all the time and not just when a child dies; this fixes bug 685032 where when you downloaded a large amount of mail the counter would get messed up because of the pipe seeming to get full; also set autoflush on the pipe writer Index: popfile.pl =================================================================== RCS file: /cvsroot/popfile/engine/popfile.pl,v retrieving revision 1.200 retrieving revision 1.201 diff -C2 -d -r1.200 -r1.201 *** popfile.pl 17 Feb 2003 11:31:56 -0000 1.200 --- popfile.pl 17 Feb 2003 22:18:25 -0000 1.201 *************** *** 37,40 **** --- 37,43 ---- # used as the key for this module in %components # + # pipeready - This is a reference to the pipeready() function in this file that it used + # to determine if a pipe if ready for reading + # # alive - Gets set to 1 when the parent wants to kill all the running sub modules # *************** *** 87,90 **** --- 90,127 ---- # --------------------------------------------------------------------------------------------- # + # pipeready + # + # Returns 1 if there is data available to be read on the passed in pipe handle + # + # $pipe Pipe handle + # + # --------------------------------------------------------------------------------------------- + sub pipeready + { + my ( $pipe ) = @_; + + if ( $on_windows ) { + + # I am NOT doing a select() here because that does not work + # on Perl running on Windows. -s returns the "size" of the file + # (in this case a pipe) and will be non-zero if there is data to read + + return ( ( -s $pipe ) > 0 ); + } else { + + # Here I do a select because we are not running on Windows where + # you can't select() on a pipe + + my $rin = ''; + vec( $rin, fileno( $pipe ), 1 ) = 1; + my $ready = select( $rin, undef, undef, 0.01 ); + return ( $ready > 0 ); + } + } + + + + # --------------------------------------------------------------------------------------------- + # # reaper # *************** *** 145,148 **** --- 182,192 ---- close $reader; + + # Set autoflush on the write handle so that output goes straight through + # to the parent without buffering it until the socket closes + + use IO::Handle; + $writer->autoflush(1); + return (0, $writer); } *************** *** 273,277 **** $components{$type}{$name}->{alive} = 1; ! $components{$type}{$name}->{forker} = \&forker; } } --- 317,322 ---- $components{$type}{$name}->{alive} = 1; ! $components{$type}{$name}->{forker} = \&forker; ! $components{$type}{$name}->{pipeready} = \&pipeready; } } |