Subject: | Patch to be more tolerant of syswrite failures |
On Mac OS X 10.3 I'm getting an error where imapd gets confused and seems to shut down the socket; then Mail::IMAPClient.pm gets confused because syswrite always returns 0 bytes written. This enters Mail::IMAPClient.pm into an infinite loop.
Perl version is 5.8.1, threading enabled.
Here's a patch on the 2.2.9 IMAPClient.pm that allows me to avoid the infinite loop (through the use of Maxtemperrors).
Also, I think a great improvement would be to allow the user to set a timeout period rather than the error count. Would anybody be interested if I added that code?
Patch follows:
--- IMAPClient.pm Wed Dec 17 12:21:25 2003
+++ IMAPClient_old.pm Wed Dec 17 12:30:25 2003
@@ -1465,7 +1465,7 @@
$total
);
$ret||=0;
- if ($! == &EAGAIN or $ret == 0 ) {
+ if ($! == &EAGAIN ) {
if ( $self->{Maxtemperrors} !~ /^unlimited/i
and $temperrs++ > ($self->{Maxtemperrors}||10)
) {
@@ -1510,7 +1510,7 @@
$self->_debug("Output buffer full; waiting $waittime seconds for relief\n");
CORE::select(undef, undef, undef, $waittime);
}
- if ( defined($ret) and $ret>0 ) {
+ if ( defined($ret) ) {
$temperrs = 0 ;
$total += $ret ;
}