|
From: <jgr...@us...> - 2003-09-10 14:00:45
|
Update of /cvsroot/popfile/engine/Proxy
In directory sc8-pr-cvs1:/tmp/cvs-serv1158/Proxy
Modified Files:
NNTP.pm POP3.pm Proxy.pm SMTP.pm
Log Message:
Add mechanism for proxies to flush child data when non-forked; this is needed by Windows Perl which has trouble with pipes getting full
Index: NNTP.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/NNTP.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** NNTP.pm 10 Sep 2003 04:33:33 -0000 1.16
--- NNTP.pm 10 Sep 2003 14:00:41 -0000 1.17
***************
*** 120,124 ****
sub child__
{
! my ( $self, $client, $download_count, $pipe ) = @_;
# Number of messages downloaded in this session
--- 120,124 ----
sub child__
{
! my ( $self, $client, $download_count, $pipe, $ppipe, $pid ) = @_;
# Number of messages downloaded in this session
***************
*** 249,252 ****
--- 249,253 ----
print $pipe "CLASS:$class$eol";
print $pipe "NEWFL:$history_file$eol";
+ $self->yield_( $ppipe, $pid );
}
***************
*** 331,334 ****
--- 332,336 ----
close $client;
print $pipe "CMPLT$eol";
+ $self->yield_( $ppipe, $pid );
close $pipe;
Index: POP3.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/POP3.pm,v
retrieving revision 1.73
retrieving revision 1.74
diff -C2 -d -r1.73 -r1.74
*** POP3.pm 10 Sep 2003 04:33:33 -0000 1.73
--- POP3.pm 10 Sep 2003 14:00:41 -0000 1.74
***************
*** 125,135 ****
# The worker method that is called when we get a good connection from a client
#
! # $client - an open stream to a POP3 client
# $download_count - The unique download count for this session
#
# ---------------------------------------------------------------------------------------------
sub child__
{
! my ( $self, $client, $download_count, $pipe ) = @_;
# Hash of indexes of downloaded messages
--- 125,138 ----
# The worker method that is called when we get a good connection from a client
#
! # $client - an open stream to a POP3 client
# $download_count - The unique download count for this session
+ # $pipe - The pipe to the parent process to send messages to
+ # $ppipe - 0 or the parent's end of the pipe
+ # $pid - 0 if this is a child process
#
# ---------------------------------------------------------------------------------------------
sub child__
{
! my ( $self, $client, $download_count, $pipe, $ppipe, $pid ) = @_;
# Hash of indexes of downloaded messages
***************
*** 170,173 ****
--- 173,177 ----
if ( $1 ne '' ) {
print $pipe "LOGIN:$4$eol";
+ $self->yield_( $ppipe, $pid );
if ( $mail = $self->verify_connected_( $mail, $client, $1, $3 || 110 ) ) {
***************
*** 329,332 ****
--- 333,337 ----
print $pipe "CLASS:$class$eol";
print $pipe "NEWFL:$history_file$eol";
+ $self->yield_( $ppipe, $pid );
}
}
***************
*** 426,429 ****
--- 431,435 ----
print $pipe "CLASS:$class$eol";
+ $self->yield_( $ppipe, $pid );
}
***************
*** 445,448 ****
--- 451,455 ----
print $pipe "NEWFL:$history_file$eol";
print $pipe "CLASS:$class$eol";
+ $self->yield_( $ppipe, $pid );
# Note locally that file has been retrieved
***************
*** 486,489 ****
--- 493,497 ----
close $client;
print $pipe "CMPLT$eol";
+ $self->yield_( $ppipe, $pid );
close $pipe;
Index: Proxy.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/Proxy.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** Proxy.pm 10 Sep 2003 04:33:33 -0000 1.34
--- Proxy.pm 10 Sep 2003 14:00:41 -0000 1.35
***************
*** 346,350 ****
if ( !defined( $pid ) || ( $pid == 0 ) ) {
! $self->{child_}( $self, $client, $self->global_config_( 'download_count' ), $pipe );
exit(0) if ( defined( $pid ) );
}
--- 346,350 ----
if ( !defined( $pid ) || ( $pid == 0 ) ) {
! $self->{child_}( $self, $client, $self->global_config_( 'download_count' ), $pipe, 0, $pid );
exit(0) if ( defined( $pid ) );
}
***************
*** 352,356 ****
pipe my $reader, my $writer;
! $self->{child_}( $self, $client, $self->global_config_( 'download_count' ), $writer );
$self->{flush_child_data_}( $self, $reader );
}
--- 352,356 ----
pipe my $reader, my $writer;
! $self->{child_}( $self, $client, $self->global_config_( 'download_count' ), $writer, $reader, $$ );
$self->{flush_child_data_}( $self, $reader );
}
***************
*** 362,365 ****
--- 362,383 ----
return 1;
+ }
+
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # yield_
+ #
+ # Called by a proxy child process to allow the parent to do work, this only does anything
+ # in the case where we didn't fork for the child process
+ #
+ # ---------------------------------------------------------------------------------------------
+ sub yield_
+ {
+ my ( $self, $pipe, $pid ) = @_;
+
+ if ( $pid != 0 ) {
+ $self->{flush_child_data_}( $self, $pipe )
+ }
}
Index: SMTP.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/SMTP.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** SMTP.pm 10 Sep 2003 04:33:33 -0000 1.17
--- SMTP.pm 10 Sep 2003 14:00:41 -0000 1.18
***************
*** 121,125 ****
sub child__
{
! my ( $self, $client, $download_count, $pipe ) = @_;
# Number of messages downloaded in this session
--- 121,125 ----
sub child__
{
! my ( $self, $client, $download_count, $pipe, $ppipe, $pid ) = @_;
# Number of messages downloaded in this session
***************
*** 227,230 ****
--- 227,231 ----
print $pipe "CLASS:$class$eol";
print $pipe "NEWFL:$history_file$eol";
+ $self->yield_( $ppipe, $pid );
my $response = <$mail>;
***************
*** 262,265 ****
--- 263,267 ----
close $client;
print $pipe "CMPLT$eol";
+ $self->yield_( $ppipe, $pid );
close $pipe;
}
|