[mew-dist 24094] Re: IM fails with Perl 5.8.1
Tatsuya Kinoshita
tats at example.com
2003年 10月 22日 (水) 23:31:22 JST
On October 22, 2003, [mew-dist 24091],
NAKAMURA Motonori <motonori at example.com> wrote:
> while ループを抜けるということであれば、while の後で判定を
> しないといけませんね(もし必要なら)。
おっしゃるとおりです。中断したのかどうかwhileのうしろで判定する
ようにしてみました。
--
木下達也
--- im-145-4/IM/Imap.pm
+++ im-145/IM/Imap.pm
@@ -195,15 +195,8 @@
if ($resp =~ /^\* \d+ FETCH \((UID $num )?RFC822 \{(\d+)\}/i) {
my $size = $2;
alarm(imap_timeout()) unless win95p();
- $! = 0;
while (<$HANDLE>) {
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_warn("lost connection for FETCH(get).\n");
- return (-1, 0);
- }
- }
+ alarm(0) unless win95p();
$size -= length($_);
s/\r\n$/\n/;
im_debug($_) if (&debug('imap'));
@@ -211,6 +204,11 @@
last if ($size <= 0);
}
alarm(0) unless win95p();
+ if ($size > 0) {
+ # may be channel trouble
+ im_warn("lost connection for FETCH(get).\n");
+ return (-1, 0);
+ }
$resp = &next_response($HANDLE);
return (-1, 0) if ($resp !~ /^\)/ &&
$resp !~ /^( FLAGS \(.*\)| UID $num)+\)/);
@@ -240,15 +238,8 @@
my($size, $len) = ($2, $3);
my $field = '';
alarm(imap_timeout()) unless win95p();
- $! = 0;
while (<$HANDLE>) {
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_warn("lost connection for FETCH(head).\n");
- return (-1, 0);
- }
- }
+ alarm(0) unless win95p();
$len -= length($_);
s/\r?\n$//;
im_debug("$_\n") if (&debug('imap'));
@@ -269,6 +260,11 @@
last if ($len <= 0);
}
alarm(0) unless win95p();
+ if ($len > 0) {
+ # may be channel trouble
+ im_warn("lost connection for FETCH(head).\n");
+ return (-1, 0);
+ }
# $head{'bytes:'} = $size;
$head{'kbytes:'} = int(($size + 1023) / 1024);
$resp = &next_response($HANDLE);
@@ -299,15 +295,8 @@
my $found = 0;
my $f;
alarm(imap_timeout()) unless win95p();
- $! = 0;
while (<$HANDLE>) {
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_warn("lost connection for FETCH(from).\n");
- return -1;
- }
- }
+ alarm(0) unless win95p();
$size -= length($_);
s/\r\n$/\n/;
im_debug($_) if (&debug('imap'));
@@ -322,6 +311,11 @@
last if ($size <= 0);
}
alarm(0) unless win95p();
+ if ($size > 0) {
+ # may be channel trouble
+ im_warn("lost connection for FETCH(from).\n");
+ return -1;
+ }
$f =~ s/\n[ \t]*/ /g;
$f = '(sender unknown)' unless ($f);
print "From $f\n";
@@ -793,15 +787,8 @@
($uid, $size, $len) = ($2, $3, $4);
my @hdr;
alarm(imap_timeout()) unless win95p();
- $! = 0;
while (<$HANDLE>) {
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_warn("lost connection for FETCH(scan).\n");
- return -1;
- }
- }
+ alarm(0) unless win95p();
$len -= length;
s/\r?\n$/\n/;
im_warn($_) if (&debug('imap'));
@@ -809,6 +796,11 @@
last if ($len <= 0);
}
alarm(0) unless win95p();
+ if ($len > 0) {
+ # may be channel trouble
+ im_warn("lost connection for FETCH(scan).\n");
+ return -1;
+ }
$resp = &next_response($HANDLE);
if (!$uid) {
return -1 if ($resp !~ /^ UID (\d+)\)/);
--- im-145-4/IM/Nntp.pm
+++ im-145/IM/Nntp.pm
@@ -170,23 +170,15 @@
im_notice("getting article $i.\n");
$rc = &tcp_command(\*NNTPd, "HEAD $i", '');
- next if ($rc > 0);
- if ($rc < 0) {
+ if ($rc != 0) {
im_warn("HEAD command failed.\n");
return -1;
}
$count++;
my($found, $f) = (0, '');
alarm(nntp_timeout()) unless win95p();
- $! = 0;
while (<NNTPd>) {
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_warn("lost connection for HEAD.\n");
- return -1;
- }
- }
+ alarm(0) unless win95p();
s/\r\n$/\n/;
last if ($_ =~ /^\.\n$/);
s/^\.//;
@@ -194,6 +186,11 @@
$f .= $_;
}
alarm(0) unless win95p();
+ if (!defined($_)) {
+ # may be channel trouble
+ im_warn("lost connection for HEAD.\n");
+ return -1;
+ }
return $f;
}
@@ -214,15 +211,8 @@
$count++;
my($found, $f) = (0, '');
alarm(nntp_timeout()) unless win95p();
- $! = 0;
while (<NNTPd>) {
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_warn("lost connection for HEAD.\n");
- return -1;
- }
- }
+ alarm(0) unless win95p();
s/\r\n$/\n/;
last if ($_ =~ /^\.\n$/);
s/^\.//;
@@ -236,6 +226,12 @@
$found = 0;
}
}
+ alarm(0) unless win95p();
+ if (!defined($_)) {
+ # may be channel trouble
+ im_warn("lost connection for HEAD.\n");
+ return -1;
+ }
$f =~ s/\n[ \t]*/ /g;
$f = '(sender unknown)' unless ($f);
print "From $f\n";
@@ -285,15 +281,8 @@
}
my @Article = ();
alarm(nntp_timeout()) unless win95p();
- $! = 0;
while (<NNTPd>) {
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_warn("lost connection for ARTICLE.\n");
- return(-1, '');
- }
- }
+ alarm(0) unless win95p();
s/\r\n$/\n/;
last if ($_ =~ /^\.\n$/);
s/^\.//;
@@ -301,6 +290,11 @@
im_debug($_) if (&debug('nntp'));
}
alarm(0) unless win95p();
+ if (!defined($_)) {
+ # may be channel trouble
+ im_warn("lost connection for ARTICLE.\n");
+ return(-1, '');
+ }
return(0, \@Article);
}
--- im-145-4/IM/Pop.pm
+++ im-145/IM/Pop.pm
@@ -148,15 +148,8 @@
return -1;
}
alarm(pop_timeout()) unless win95p();
- $! = 0;
while (<POPd>) {
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_warn("lost connection for RETR.\n");
- return -1;
- }
- }
+ alarm(0) unless win95p();
s/\r\n$/\n/;
last if ($_ =~ /^\.\n$/);
s/^\.//;
@@ -164,6 +157,11 @@
push (@Message, $_);
}
alarm(0) unless win95p();
+ if (!defined($_)) {
+ # may be channel trouble
+ im_warn("lost connection for RETR.\n");
+ return -1;
+ }
return -1 if (store_message(\@Message, $dst, $noscan) < 0);
&exec_getsbrfile($dst);
@@ -184,15 +182,8 @@
my(%head);
undef %head;
alarm(pop_timeout()) unless win95p();
- $! = 0;
while (<POPd>) {
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_warn("lost connection for HEAD.\n");
- return 0;
- }
- }
+ alarm(0) unless win95p();
s/\r?\n$//;
last if ($_ =~ /^\.$/);
s/^\.//;
@@ -214,6 +205,11 @@
}
}
alarm(0) unless win95p();
+ if (!defined($_)) {
+ # may be channel trouble
+ im_warn("lost connection for HEAD.\n");
+ return 0;
+ }
return \%head;
}
@@ -238,15 +234,8 @@
return -1;
}
alarm(pop_timeout()) unless win95p();
- $! = 0;
while (<POPd>) {
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_warn("lost connection for UIDL.\n");
- return -1;
- }
- }
+ alarm(0) unless win95p();
s/\r\n$/\n/;
last if ($_ =~ /^\.\n$/);
im_debug($_) if (&debug('pop'));
@@ -255,6 +244,11 @@
}
}
alarm(0) unless win95p();
+ if (!defined($_)) {
+ # may be channel trouble
+ im_warn("lost connection for UIDL.\n");
+ return -1;
+ }
return 0;
}
--- im-145-4/IM/TcpTransaction.pm
+++ im-145/IM/TcpTransaction.pm
@@ -207,7 +207,7 @@
im_notice("<<< $logcmd\n");
$Session_log .= "<<< $logcmd\n" if ($Logging);
unless (print $CHAN "$command\r\n") {
- # may be channel truoble
+ # may be channel trouble
@Response = ($!);
return 1;
}
@@ -220,14 +220,15 @@
}
do {
alarm(command_timeout()) unless win95p();
- $! = 0;
$resp = <$CHAN>;
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- @Response = ("$!");
- return 1;
- }
+ if (!defined($resp)) {
+ # may be channel trouble
+ @Response = ("$!");
+ }
+ alarm(0) unless win95p();
+ if (!defined($resp)) {
+ # may be channel trouble
+ return 1;
}
$resp =~ s/[\r\n]+$//;
if ($resp =~ /^([0-9][0-9][0-9])/) {
@@ -268,14 +269,15 @@
$0 = progname() . ": greeting ($Cur_server)";
}
alarm(command_timeout()) unless win95p();
- $! = 0;
$resp = <$CHAN>;
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_notice("$!\n");
- return '';
- }
+ if (!defined($resp)) {
+ # may be channel trouble
+ im_notice("$!\n");
+ }
+ alarm(0) unless win95p();
+ if (!defined($resp)) {
+ # may be channel trouble
+ return '';
}
$resp =~ s/[\r\n]+/\n/;
im_notice(">>> $resp");
@@ -303,14 +305,15 @@
my $resp;
alarm(command_timeout()) unless win95p();
- $! = 0;
$resp = <$CHAN>;
- unless (win95p()) {
- alarm(0);
- if ($!) { # may be channel truoble
- im_notice("$!\n");
- return '';
- }
+ if (!defined($resp)) {
+ # may be channel trouble
+ im_notice("$!\n");
+ }
+ alarm(0) unless win95p();
+ if (!defined($resp)) {
+ # may be channel trouble
+ return '';
}
$resp =~ s/[\r\n]+/\n/;
im_notice(">>> $resp");
Mew-dist メーリングリストの案内