Date: | Tue, 01 Apr 2003 13:49:15 +0200 |
From: | Arnaud Taddei <Arnaud.Taddei [...] sun.com> |
To: | bug-Mail-IMAPClient [...] rt.cpan.org |
Subject: | [Fwd: About IMAPClient.pm] |
repost, I just read the podified version of IMAPClient.pm.
So I am not sure that these are bugs but here is a diff of what I
modified. I am working on Linux Suse 8.0. I attack 2 Sun ONE Messaging
Servers 5.2 hot fix 1.14. The CPAN version is 2.2.6 for this module.
Perl is
taddei@gandalf:/usr/lib/perl5/site_perl/5.6.1/Mail> perl -v
This is perl, v5.6.1 built for i586-linux
Let me know if anything is unclear
A++
Message-ID: <3E895EC3.7070402@sun.com>
Date: Tue, 01 Apr 2003 11:41:23 +0200
From: Arnaud Taddei <Arnaud.Taddei@sun.com>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: "David J. Kernen" <djkernen@cpan.org>
Subject: About IMAPClient.pm
Content-Type: multipart/mixed;
boundary="------------060206020905030506010708"
This is a multi-part message in MIME format.
--------------060206020905030506010708
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Dear Sir, as I needed a perl IMAP client library I found what looks like
being the result of your work in the tarball Mail-IMAPClient-2.2.6. So
if this is your own work, thanks a lot as this is very useful to me.
While playing with the migration example and modifying it for my own
purposes, I found some glitches in IMAPClient.pm and here I attach a
diff file. I don't know if you take input on this code or what is the
status. I am just starting so let me know how life looks like from your
side.
Again thanks for this code it helps me a lot.
A++
--------------060206020905030506010708
Content-Type: application/x-perl;
name="diff-IMAPClient.pm"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="diff-IMAPClient.pm"
517c517
< $rights =~ s/\"//g;
---
> $rights =~ s/"//g;
911a912,913
> my $temperrs = 0;
> my $optimize = 0;
930,931c932,975
< &ensure_the_syswrite($!,$ret,$self);
<
---
> if ($! == &EAGAIN ) {
> if ( $self->{Maxtemperrors} !~ /^unlimited/i
> and $temperrs++ > ($self->{Maxtemperrors}||10)
> ) {
> $self->LastError("Persistent '${!}' errors\n");
> $self->_debug("Persistent '${!}' errors\n");
> return undef;
> }
> $optimize = 1;
> } else {
> # avoid infinite loops on syswrite error
> return undef unless(defined $ret);
> }
> # Optimization of wait time between syswrite calls
> # only runs if syscalls run too fast and fill the
> # buffer causing "EAGAIN: Resource Temp. Unavail" errors. The
> # premise is that $maxwrite will be approx. the same as
> # the smallest buffer between the sending and receiving side.
> # Waiting time between syscalls should ideally be exactly as
> # long as it takes the receiving side to empty that buffer,
> # minus a little bit to prevent it from
> # emptying completely and wasting time in the select call.
> if ($optimize) {
> $maxwrite = $ret if $maxwrite < $ret;
> push( @last5writes, $ret );
> shift( @last5writes ) if $#last5writes > 5;
> my $bufferavail = 0;
> $bufferavail += $_ for ( @last5writes );
> $bufferavail /= ($#last5writes||1);
> # Buffer is staying pretty full;
> # we should increase the wait period
> # to reduce transmission overhead/number of packets sent
> if ( $bufferavail < .4 * $maxwrite ) {
> $waittime *= 1.3;
>
> # Buffer is nearly or totally empty;
> # we're wasting time in select
> # call that could be used to send data,
> # so reduce the wait period
> } elsif ( $bufferavail > .9 * $maxwrite ) {
> $waittime *= .5;
> }
> CORE::select(undef, undef, undef, $waittime);
> }
935c979
< $peer->_debug("Chunk $chunkCount: " .
---
> $peer->_debug("Chunk $chunkCount: " +
1407a1452,1456
> my $temperrs = 0;
> my $optimize = 0;
> my $maxwrite = 0;
> my $waittime = .02;
> my @last5writes = (1);
1410d1458
<
1416,1419c1464,1509
< )||0;
<
< &ensure_the_syswrite($!,$ret,$self);
<
---
> );
> if ($! == &EAGAIN ) {
> if ( $self->{Maxtemperrors} !~ /^unlimited/i
> and $temperrs++ > ($self->{Maxtemperrors}||10)
> ) {
> $self->LastError("Persistent '${!}' errors\n");
> $self->_debug("Persistent '${!}' errors\n");
> return undef;
> }
> $optimize = 1;
> } else {
> # avoid infinite loops on syswrite error
> return undef unless(defined $ret);
> }
> # Optimization of wait time between syswrite calls
> # only runs if syscalls run too fast and fill the
> # buffer causing "EAGAIN: Resource Temp. Unavail" errors. The
> # premise is that $maxwrite will be approx. the same as
> # the smallest buffer between the sending and receiving side.
> # Waiting time between syscalls should ideally be exactly as
> # long as it takes the receiving side to empty that buffer,
> # minus a little bit to prevent it from
> # emptying completely and wasting time in the select call.
> if ($optimize) {
> $maxwrite = $ret if $maxwrite < $ret;
> push( @last5writes, $ret );
> shift( @last5writes ) if $#last5writes > 5;
> my $bufferavail = 0;
> $bufferavail += $_ for ( @last5writes );
> $bufferavail /= $#last5writes;
> # Buffer is staying pretty full;
> # we should increase the wait period
> # to reduce transmission overhead/number of packets sent
> if ( $bufferavail < .4 * $maxwrite ) {
> $waittime *= 1.3;
>
> # Buffer is nearly or totally empty;
> # we're wasting time in select
> # call that could be used to send data,
> # so reduce the wait period
> } elsif ( $bufferavail > .9 * $maxwrite ) {
> $waittime *= .5;
> }
> $self->_debug("Output buffer full; waiting $waittime seconds for relief\n");
> CORE::select(undef, undef, undef, $waittime);
> }
1429,1496d1518
< sub ensure_the_syswrite {
< my($bang,$ret,$self) = @_;
<
< my $temperrs = 0;
< my $optimize = 0;
<
< if ($bang == &EAGAIN ) {
< if ( $self->{Maxtemperrors} !~ /^unlimited/i
< and $temperrs++ > ($self->{Maxtemperrors}||10)
< ) {
< $self->LastError("Persistent '$bang' errors\n");
< $self->_debug("Persistent '$bang' errors\n");
< return undef;
< }
< $optimize = 1;
< } else {
< # avoid infinite loops on syswrite error
< return undef unless(defined $ret);
< }
<
< if ($optimize) {
< &wait_time_optimisation($ret,$self);
< }
<
< }
<
< sub wait_time_optimisation {
< my($ret,$self) = @_;
<
< my $maxwrite = 0;
< my $waittime = .02;
< my @last5writes = (1);
< my $bufferavail = 0;
<
< # Optimization of wait time between syswrite calls
< # only runs if syscalls run too fast and fill the
< # buffer causing "EAGAIN: Resource Temp. Unavail" errors. The
< # premise is that $maxwrite will be approx. the same as
< # the smallest buffer between the sending and receiving side.
< # Waiting time between syscalls should ideally be exactly as
< # long as it takes the receiving side to empty that buffer,
< # minus a little bit to prevent it from
< # emptying completely and wasting time in the select call.
<
< $maxwrite = $ret if $maxwrite < $ret;
< push( @last5writes, $ret );
< shift( @last5writes ) if $#last5writes > 5;
<
< $bufferavail += $_ for ( @last5writes );
< $bufferavail /= $#last5writes;
< # Buffer is staying pretty full;
< # we should increase the wait period
< # to reduce transmission overhead/number of packets sent
< if ( $bufferavail < .4 * $maxwrite ) {
< $waittime *= 1.3;
<
< # Buffer is nearly or totally empty;
< # we're wasting time in select
< # call that could be used to send data,
< # so reduce the wait period
< } elsif ( $bufferavail > .9 * $maxwrite ) {
< $waittime *= .5;
< }
< $self->_debug("Output buffer full; waiting $waittime seconds for relief\n");
< CORE::select(undef, undef, undef, $waittime);
< }
<
<
5083c5105
< list of UID\'s for the newly copied messages. The list will be in the
---
> list of UID's for the newly copied messages. The list will be in the
--------------060206020905030506010708--