Change 13913 by jhi@alpha on 2001/12/27 23:57:34
Subject: [PATCH] because (sys)?read doesn't reset buffers
From: Nicholas Clark <[EMAIL PROTECTED]>
Date: Fri, 28 Dec 2001 00:43:02 +0000
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
.... //depot/perl/ext/Socket/socketpair.t#4 edit
Differences ...
==== //depot/perl/ext/Socket/socketpair.t#4 (text) ====
Index: perl/ext/Socket/socketpair.t
--- perl/ext/Socket/socketpair.t.~1~ Thu Dec 27 17:00:06 2001
+++ perl/ext/Socket/socketpair.t Thu Dec 27 17:00:06 2001
@@ -60,9 +60,11 @@
# stream socket, so our writes will become joined:
my ($buffer, $expect);
$expect = join '', @right;
+undef $buffer;
is (read (LEFT, $buffer, length $expect), length $expect, "read on left");
is ($buffer, $expect, "content what we expected?");
$expect = join '', @left;
+undef $buffer;
is (read (RIGHT, $buffer, length $expect), length $expect, "read on right");
is ($buffer, $expect, "content what we expected?");
@@ -99,6 +101,7 @@
ok (!eof LEFT, "left is not at EOF");
$expect = join '', @gripping;
+undef $buffer;
is (read (LEFT, $buffer, length $expect), length $expect, "read on left");
is ($buffer, $expect, "content what we expected?");
@@ -126,11 +129,13 @@
my ($total);
$total = join '', @right;
foreach $expect (@right) {
+ undef $buffer;
is (sysread (LEFT, $buffer, length $total), length $expect, "read on left");
is ($buffer, $expect, "content what we expected?");
}
$total = join '', @left;
foreach $expect (@left) {
+ undef $buffer;
is (sysread (RIGHT, $buffer, length $total), length $expect, "read on right");
is ($buffer, $expect, "content what we expected?");
}
@@ -144,6 +149,7 @@
local $SIG{ALRM} = sub { $alarmed = 1; };
print "# Approximate forever as 3 seconds. Wait 'forever'...\n";
alarm 3;
+ undef $buffer;
is (sysread (RIGHT, $buffer, 1), undef,
"read on right should be interrupted");
is ($alarmed, 1, "alarm should have fired");
@@ -158,6 +164,7 @@
$total = join '', @gripping;
foreach $expect (@gripping) {
+ undef $buffer;
is (sysread (LEFT, $buffer, length $total), length $expect, "read on left");
is ($buffer, $expect, "content what we expected?");
}
End of Patch.